flowchart LR
videotestsrc[videotestsrc]
autovideosink[videotestsrc/ximagesink]
videotestsrc --> autovideosink
gst-launch-1.0 videotestsrc \
! clockoverlay time-format=\"%D %H:%M:%S\" \
! autovideosink
gst-launch-1.0 videotestsrc \
! clockoverlay time-format=\"%D %H:%M:%S\" \
! ximagesink
flowchart LR
audiotestsrc[audiotestsrc]
autoaudiosink[autoaudiosink]
audiotestsrc --> autoaudiosink
$ gst-launch-1.0 audiotestsrc \
! audioconvert \
! autoaudiosink
flowchart LR
filesrc[filesrc]
autoaudiosink[alsasink/pulsesink/autoaudiosink]
filesrc --> autoaudiosink
export MUSIC_FILE="/work/BeethovenFurElise.mp3"
export MUSIC_FILE="/work/BeethovenFurElise.wav"
gst-launch-1.0 filesrc \
location=$MUSIC_FILE \
! decodebin \
! audioconvert \
! alsasink
gst-launch-1.0 filesrc \
location=$MUSIC_FILE \
! decodebin \
! audioconvert \
! pulsesink
gst-launch-1.0 filesrc \
location=$MUSIC_FILE \
! decodebin \
! audioconvert \
! autoaudiosink
flowchart LR
filesrc[filesrc]
udpsink[udpsink]
udpsrc[udpsrc]
alsasink[alsasink]
filesrc --> udpsink ..-> |rtpL16pay,:51000| udpsrc --> |rtpL16depay| alsasink
export UDP_SINK="udpsink host=127.0.0.1 port=51000"
export UDP_SINK="udpsink host=192.168.56.1 port=51000"
export UDP_SINK="udpsink host=224.0.0.1 port=51000 auto-multicast=true"
export MUSIC_FILE="/work/BeethovenFurElise.mp3"
gst-launch-1.0 filesrc \
location=$MUSIC_FILE \
! decodebin \
! audioconvert \
! rtpL16pay \
! $UDP_SINK
export UDP_SRC="multicast-group=224.0.0.1 port=51000 auto-multicast=true"
export UDP_SRC="port=51000"
gst-launch-1.0 -v udpsrc \
$UDP_SRC \
caps='application/x-rtp, media=(string)audio, clock-rate=(int)44100, encoding-name=(string)L16, payload=(int)10' \
! rtpL16depay \
! audioconvert \
! pulsesink
gst-launch-1.0 -v udpsrc \
$UDP_SRC \
caps='application/x-rtp, media=(string)audio, clock-rate=(int)44100, encoding-name=(string)L16, payload=(int)10' \
! rtpL16depay \
! audioconvert \
! autoaudiosink
-e, put EOS
flowchart LR
filesrc[filesrc]
filesink[filesink]
filesrc --> filesink
gst-launch-1.0 -e filesrc \
location=$MUSIC_FILE \
! wavparse \
! audioconvert \
! audioresample \
! audio/x-raw,format=S16BE,channels=2,rate=44100 \
! filesink location="/work/BeethovenFurElise-S16BE.pcm"
gst-launch-1.0 -e filesrc \
location=$MUSIC_FILE \
! wavparse \
! audioconvert \
! audioresample \
! audio/x-raw,format=S16LE,channels=2,rate=44100 \
! filesink location="/work/BeethovenFurElise-S16LE.pcm"
gst-launch-1.0 -e filesrc \
location=$MUSIC_FILE \
! decodebin \
! audioconvert \
! audioresample \
! audio/x-raw,format=S16LE,channels=2,rate=44100 \
! filesink location="/work/BeethovenFurElise-S16LE.pcm"
gst-launch-1.0 -e filesrc \
location=$MUSIC_FILE \
! wavparse \
! audioconvert \
! audioresample \
! opusenc \
! oggmux \
! filesink location="/work/BeethovenFurElise-opus.ogg"
gst-launch-1.0 -e filesrc \
location=$MUSIC_FILE \
! wavparse \
! audioconvert \
! audioresample \
! vorbisenc \
! oggmux \
! filesink location="/work/BeethovenFurElise-vorbis.ogg"
flowchart LR
filesrc[filesrc]
autoaudiosink[alsasink/pulsesink/autoaudiosink]
filesrc --> autoaudiosink
gst-launch-1.0 filesrc \
location="/work/BeethovenFurElise-S16BE.pcm" \
! audio/x-raw,format=S16BE,channels=2,rate=44100,layout=interleaved \
! audioconvert \
! audioresample \
! autoaudiosink
gst-launch-1.0 filesrc \
location="/work/BeethovenFurElise-S16LE.pcm" \
! audio/x-raw,format=S16LE,channels=2,rate=44100,layout=interleaved \
! audioconvert \
! audioresample \
! autoaudiosink
gst-launch-1.0 filesrc \
location="/work/BeethovenFurElise-S16LE.pcm" \
! rawaudioparse format=pcm pcm-format=s16le sample-rate=44100 num-channels=2 \
! audioconvert \
! autoaudiosink
flowchart LR
filesrc[filesrc]
filesink[filesink]
filesrc --> filesink
gst-launch-1.0 -e filesrc \
location="/work/BeethovenFurElise-S16BE.pcm" \
! rawaudioparse use-sink-caps=false format=pcm pcm-format=s16be sample-rate=44100 num-channels=2 \
! audioconvert \
! wavenc \
! filesink location="/work/BeethovenFurElise.wav"
gst-launch-1.0 -e filesrc \
location="/work/BeethovenFurElise-S16LE.pcm" \
! rawaudioparse use-sink-caps=false format=pcm pcm-format=s16le sample-rate=44100 num-channels=2 \
! audioconvert \
! wavenc \
! filesink location="/work/BeethovenFurElise.wav"
gst-launch-1.0 -e filesrc \
location="/work/BeethovenFurElise-S16BE.pcm" \
! rawaudioparse use-sink-caps=false format=pcm pcm-format=s16be sample-rate=44100 num-channels=2 \
! audioconvert \
! audioresample \
! opusenc \
! oggmux \
! filesink location="/work/BeethovenFurElise-opus.ogg"
gst-launch-1.0 -e filesrc \
location="/work/BeethovenFurElise-S16LE.pcm" \
! audio/x-raw,format=S16LE,channels=2,rate=44100,layout=interleaved \
! audioconvert \
! wavenc \
! filesink location="/work/BeethovenFurElise.wav"
flowchart LR
multifilesrc[multifilesrc]
autoaudiosink[alsasink/pulsesink/autoaudiosink]
multifilesrc --> autoaudiosink
gst-launch-1.0 multifilesrc \
location="/work/%04d.mp3" \
! decodebin \
! audioconvert \
! alsasink
# loop
gst-launch-1.0 multifilesrc \
location="/work/BeethovenFurElise.mp3" loop=true \
! decodebin \
! audioconvert \
! alsasink
flowchart LR
appsrc[appsrc]
udpsink[udpsink]
udpsrc[udpsrc]
autovideosink[autovideosink]
appsrc --> udpsink
udpsink ..-> |224.0.0.1:50000| udpsrc
udpsrc --> autovideosink
appsrc name=source is-live=TRUE do-timestamp=TRUE block=TRUE max-bytes=-1 emit-signals=TRUE \
! videoparse width=720 height=480 format=i420 framerate=20/1 \
! x264enc byte-stream=TRUE rc-lookahead=0 tune=zerolatency speed-preset=ultrafast sync-lookahead=0 bitrate=500 \
! rtph264pay \
! udpsink host=224.0.0.1 port=50000 auto-multicast=true
gst-launch-1.0 -v udpsrc \
multicast-group=224.0.0.1 port=50000 auto-multicast=true \
caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96' \
! rtph264depay \
! decodebin \
! videoconvert \
! autovideosink
v=0
m=video 50000 RTP/AVP 96
c=IN IP4 224.0.0.1
a=rtpmap:96 H264/90000
flowchart LR
uri[(http://relay.slayradio.org:800)]
playbin[playbin]
uri --> playbin
gst-launch-1.0 -v playbin \
uri=http://relay.slayradio.org:8000/
gst-launch-1.0 -v playbin \
uri=file:///work/BeethovenFurElise.mp3
#https://github.com/ytdl-org/youtube-dl
$ sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
$ sudo chmod a+rx /usr/local/bin/youtube-dl
$ youtube-dl --list-formats https://www.youtube.com/watch?v=rSgzrSyQZc0
$ youtube-dl --format "best[ext=mp4][protocol=https]" --get-url https://www.youtube.com/watch?v=rSgzrSyQZc0
gst-launch-1.0 souphttpsrc is-live=true \
location="$(youtube-dl --format 134 --get-url https://www.youtube.com/watch?v=rSgzrSyQZc0)" \
! decodebin ! videoconvert ! autovideosink
$ sudo apt-get --yes install v4l-utils
$ v4l2-ctl --list-devices
w300: w300 (usb-0000:00:0b.0-1):
/dev/video0
/dev/video1
$ v4l2-ctl --all
Driver Info:
Driver name : uvcvideo
Card type : w300: w300
Bus info : usb-0000:00:0b.0-1
Driver version : 5.15.143
Capabilities : 0x84a00001
Video Capture
Metadata Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04200001
Video Capture
Streaming
Extended Pix Format
Priority: 2
Video input : 0 (Input 1: ok)
Format Video Capture:
Width/Height : 640/480
Pixel Format : 'YUYV' (YUYV 4:2:2)
Field : None
Bytes per Line : 1280
Size Image : 614400
Colorspace : sRGB
Transfer Function : Rec. 709
YCbCr/HSV Encoding: ITU-R 601
Quantization : Default (maps to Limited Range)
Flags :
Crop Capability Video Capture:
Bounds : Left 0, Top 0, Width 640, Height 480
Default : Left 0, Top 0, Width 640, Height 480
Pixel Aspect: 1/1
Selection Video Capture: crop_default, Left 0, Top 0, Width 640, Height 480, Flags:
Selection Video Capture: crop_bounds, Left 0, Top 0, Width 640, Height 480, Flags:
Streaming Parameters Video Capture:
Capabilities : timeperframe
Frames per second: 30.000 (30/1)
Read buffers : 0
User Controls
brightness 0x00980900 (int) : min=-64 max=64 step=1 default=0 value=0
contrast 0x00980901 (int) : min=0 max=64 step=1 default=32 value=32
saturation 0x00980902 (int) : min=0 max=128 step=1 default=64 value=64
hue 0x00980903 (int) : min=-40 max=40 step=1 default=0 value=0
white_balance_automatic 0x0098090c (bool) : default=1 value=1
gamma 0x00980910 (int) : min=72 max=500 step=1 default=100 value=100
gain 0x00980913 (int) : min=0 max=100 step=1 default=0 value=0
power_line_frequency 0x00980918 (menu) : min=0 max=2 default=2 value=2
0: Disabled
1: 50 Hz
2: 60 Hz
white_balance_temperature 0x0098091a (int) : min=2800 max=6500 step=1 default=4600 value=4600 flags=inactive
sharpness 0x0098091b (int) : min=0 max=6 step=1 default=4 value=4
backlight_compensation 0x0098091c (int) : min=0 max=160 step=1 default=80 value=80
Camera Controls
auto_exposure 0x009a0901 (menu) : min=0 max=3 default=3 value=3
1: Manual Mode
3: Aperture Priority Mode
exposure_time_absolute 0x009a0902 (int) : min=1 max=5000 step=1 default=157 value=157 flags=inactive
exposure_dynamic_framerate 0x009a0903 (bool) : default=0 value=1
iris_absolute 0x009a0911 (int) : min=0 max=0 step=0 default=0 value=0
flowchart LR
v4l2src[v4l2src]
autovideosink[videotestsrc/ximagesink]
v4l2src --> autovideosink
gst-launch-1.0 v4l2src device=/dev/video0 \
! videoconvert \
! ximagesink
gst-launch-1.0 v4l2src device=/dev/video0 \
! videoconvert \
! clockoverlay time-format="%D %H:%M:%S" \
! autovideosink
gst-launch-1.0 v4l2src device=/dev/video0 \
! videoconvert \
! video/x-raw,width=640,height=480,framerate=30/1 \
! ximagesink
gst-launch-1.0 v4l2src device=/dev/video0 \
! videoconvert \
! video/x-raw,width=640,height=480,framerate=30/1 \
! autovideosink
gst-launch-1.0 v4l2src device=/dev/video0 \
! videoconvert \
! video/x-raw,width=640,height=480,framerate=30/1,format=YUY2 \
! autovideosink
gst-launch-1.0 -v v4l2src device=/dev/video0 \
! image/jpeg, width=640, height=480, framerate=30/1, format=MJPG \
! jpegdec \
! videoconvert \
! autovideosink
flowchart LR
v4l2src[v4l2src]
udpsink[udpsink]
v4l2src --> udpsink
gst-launch-1.0 v4l2src device=/dev/video0 \
! videoconvert \
! video/x-raw,width=640,height=480,framerate=30/1 \
! clockoverlay time-format="%D %H:%M:%S" \
! x264enc \
! rtph264pay \
! udpsink host=127.0.0.1 port=50000
flowchart LR
v4l2src[v4l2src]
multiudpsink[multiudpsink]
v4l2src --> multiudpsink
gst-launch-1.0 v4l2src device=/dev/video0 \
! videoconvert \
! video/x-raw,width=640,height=480,framerate=30/1 \
! clockoverlay time-format="%D %H:%M:%S" \
! x264enc \
! rtph264pay \
! multiudpsink clients=192.168.0.2:50000,192.168.0.3:50000,192.168.0.4:50000
flowchart LR
alsasrc[alsasrc]
filesink[filesink]
alsasrc --> |vorbisenc,oggmux| filesink
gst-launch-1.0 -e alsasrc \
! queue \
! audioconvert \
! vorbisenc \
! oggmux \
! filesink location="record-vorbis.ogg"
flowchart LR
alsasrc[alsasrc]
autoaudiosink[autoaudiosink]
alsasrc --> autoaudiosink
gst-launch-1.0 alsasrc \
! queue \
! audioconvert \
! audioresample \
! autoaudiosink
flowchart LR
autoaudiosrc[autoaudiosrc]
autoaudiosink[autoaudiosink]
autoaudiosrc --> autoaudiosink
$ gst-launch-1.0 autoaudiosrc \
! audioconvert \
! audioresample \
! autoaudiosink
flowchart LR
rtspsrc[rtspsrc]
autovideosink[autovideosink]
rtspsrc --> autovideosink
gst-launch-1.0 rtspsrc \
location=rtsp://192.168.50.21:554 user-id=admin user-pw=admin protocols=4 \
! rtph264depay \
! h264parse \
! avdec_h264 ! autovideosink
gst-launch-1.0 rtspsrc \
location=rtsp://192.168.50.21:554 user-id=admin user-pw=admin protocols=4 \
! rtph264depay \
! h264parse \
! decodebin \
! videoconvert ! autovideosink
gst-launch-1.0 rtspsrc \
location=rtsp://192.168.50.21:554 user-id=admin user-pw=admin protocols=4 \
! rtph264depay \
! decodebin \
! videoconvert ! autovideosink
flowchart LR
rtspsrc[rtspsrc]
autovideosink[autovideosink]
autoaudiosink[autoaudiosink]
rtspsrc --> autovideosink
rtspsrc --> autoaudiosink
gst-launch-1.0 rtspsrc \
location="rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mp4" protocols=tcp name=src \
src. ! queue ! decodebin ! videoconvert ! autovideosink \
src. ! queue ! decodebin ! audioconvert ! audioresample ! autoaudiosink
flowchart LR
rtspsrc[rtspsrc]
udpsink[udpsink]
udpsrc[udpsrc]
autovideosink[autovideosink]
rtspsrc --> udpsink
udpsink ..-> |224.0.0.1:5000| udpsrc
udpsrc --> autovideosink
gst-launch-1.0 rtspsrc \
location=rtsp://192.168.50.21:554 user-id=admin user-pw=admin protocols=4 \
! udpsink host=224.0.0.1 port=50000 auto-multicast=true
gst-launch-1.0 -v udpsrc \
multicast-group=224.0.0.1 port=50000 auto-multicast=true \
caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96' \
! rtph264depay \
! decodebin ! videoconvert ! autovideosink
flowchart LR
rtspsrc[rtspsrc]
udpsink[udpsink]
udpsrc[udpsrc]
autovideosink[autovideosink]
rtspsrc --> udpsink
udpsink ..-> |:5000| udpsrc
udpsrc --> autovideosink
gst-launch-1.0 rtspsrc \
location=rtsp://192.168.50.21:554 user-id=admin user-pw=admin protocols=4 \
! udpsink host=127.0.0.1 port=50000 sync=false -v
export VIDEO_PORT="50000"
gst-launch-1.0 -v rtspsrc \
location=rtsp://192.168.50.21:554 user-id=admin user-pw=admin protocols=4 name=src \
src. \
! decodebin ! autovideoconvert ! x264enc tune=zerolatency ! rtph264pay \
! udpsink host=127.0.0.1 port=$VIDEO_PORT
export VIDEO_PORT="50000"
gst-launch-1.0 -v udpsrc \
port=$VIDEO_PORT \
caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96' \
! rtph264depay \
! decodebin \
! videoconvert ! autovideosink
flowchart LR
rtspsrc[rtspsrc]
kvssink[kvssink]
rtspsrc --> kvssink
gst-launch-1.0 rtspsrc location=rtsp://192.168.50.21:554 user-id=admin user-pw=admin protocols=4 \
! rtph264depay \
! h264parse \
! kvssink stream-name="HelloLanka" storage-size=512 \
access-key="AKI12345678901234567" \
secret-key="1234567890123456789012345678901234567890" \
aws-region="ap-northeast-1"
flowchart LR
filesrc[filesrc]
udpsink[udpsink]
udpsrc[udpsrc]
alsasink[???sink]
filesrc --> udpsink ..-> |:51000| udpsrc --> alsasink
export UDP_SINK="udpsink host=127.0.0.1 port=51000"
export UDP_SINK="udpsink host=192.168.56.1 port=51000"
export UDP_SINK="udpsink host=192.168.50.9 port=52000"
export UDP_SINK="udpsink host=192.168.50.51 port=52000"
export UDP_SINK="udpsink host=224.0.0.1 port=51000 auto-multicast=true"
gst-launch-1.0 filesrc \
location=/work/wav/0001.wav \
! wavparse \
! audioconvert \
! audioresample \
! opusenc ! rtpopuspay \
! $UDP_SINK
gst-launch-1.0 filesrc \
location=./0001be.pcm \
! rawaudioparse use-sink-caps=false format=pcm pcm-format=s16be sample-rate=44100 num-channels=2 \
! audioconvert \
! audioresample \
! opusenc ! rtpopuspay \
! $UDP_SINK
gst-launch-1.0 filesrc \
location="/work/BeethovenFurElise.mp3" \
! decodebin \
! audioconvert \
! audioresample \
! opusenc ! rtpopuspay \
! $UDP_SINK
export UDP_SRC="multicast-group=224.0.0.1 port=51000 auto-multicast=true"
export UDP_SRC="port=51000"
gst-launch-1.0 udpsrc \
$UDP_SRC \
! application/x-rtp,payload=96,encoding-name=OPUS \
! rtpopusdepay \
! opusdec \
! autoaudiosink
gst-launch-1.0 udpsrc \
port=51000 \
caps='application/x-rtp, media=(string)audio, payload=(int)0, clock-rate=(int)8000' \
! rtppcmudepay \
! autoaudiosink
gst-launch-1.0 udpsrc \
$UDP_SRC \
! application/x-rtp,payload=96,encoding-name=OPUS \
! rtpopusdepay \
! opusdec \
! queue \
! audioconvert \
! audioresample \
! audio/x-raw,format=S16LE,channels=2,rate=44100 \
! autoaudiosink
gst-launch-1.0 -e udpsrc \
$UDP_SRC \
! application/x-rtp,payload=96,encoding-name=OPUS \
! rtpopusdepay \
! opusdec \
! audioconvert \
! audioresample \
! audio/x-raw,format=S16LE,channels=2,rate=44100 \
! filesink location="0001le.pcm"
flowchart LR
udpsink[udpsink]
udpsrc[udpsrc]
autoaudiosink[autoaudiosink]
udpsink --> |Video:50000|udpsrc
udpsink --> |Audio:51000|udpsrc
udpsrc --> autoaudiosink
gst-launch-1.0 audiotestsrc \
! audioconvert \
! audioresample \
! opusenc \
! rtpopuspay \
! udpsink host=127.0.0.1 port=51000 \
videotestsrc \
! clockoverlay time-format=\"%D %H:%M:%S\" \
! x264enc \
! rtph264pay \
! udpsink host=127.0.0.1 port=50000
gst-launch-1.0 -v udpsrc port=50000 \
! application/x-rtp,payload=96 \
! rtph264depay \
! decodebin ! videoconvert ! autovideosink \
udpsrc port=51000 \
! application/x-rtp,payload=97,encoding-name=OPUS \
! rtpopusdepay \
! opusdec \
! autoaudiosink
12. [Raspberry Pi] libcamerasrc
$ git clone https://git.libcamera.org/libcamera/libcamera.git
$ cd libcamera
$ mkdir build_xxx
$ meson setup build_xxx
$ ninja -C build_xxx
$ ninja -C build_xxx install
使用 x264 庫進行 H.264 軟件編碼。x264 是一種流行的開源 H.264 編碼器,提供了豐富的編碼參數和質量控制選項。
flowchart LR
libcamerasrc[libcamerasrc]
filesink[filesink]
libcamerasrc --> |x264enc,h264| filesink
# libcamerasrc -> |x264enc,h264| filesink
# -e, put EOS
$ gst-launch-1.0 -e libcamerasrc \
! videoconvert \
! video/x-raw,width=640,height=480,framerate=30/1 \
! clockoverlay time-format=\"%D %H:%M:%S\" \
! x264enc \
! queue \
! filesink location=libcamerasrc-x264.h264
# filesrc -> autovideosink
$ gst-launch-1.0 -v filesrc \
location="./libcamerasrc-x264.h264" \
! decodebin \
! videoconvert \
! autovideosink
flowchart LR
libcamerasrc[libcamerasrc]
filesink[filesink]
libcamerasrc --> |x264enc,mp4| filesink
# libcamerasrc -> |x264enc,mp4| filesink
$ gst-launch-1.0 -e libcamerasrc \
! videoconvert \
! video/x-raw,width=640,height=480,framerate=30/1 \
! x264enc \
! mp4mux \
! queue \
! filesink location=libcamerasrc-x264.mp4
$ gst-launch-1.0 -v filesrc \
location="./libcamerasrc-x264.mp4" \
! decodebin \
! videoconvert \
! autovideosink
使用 V4L2 接口提供的硬件編碼器進行 H.264 編碼。這意味著它通常會直接利用設備上的硬件編碼器,比如一些支持 H.264 編碼的硬件視頻編碼器。
flowchart LR
libcamerasrc[libcamerasrc]
filesink[filesink]
libcamerasrc --> |v4l2h264enc,h264| filesink
# libcamerasrc -> |v4l2h264enc,h264| filesink
$ gst-launch-1.0 -e libcamerasrc \
! videoconvert \
! video/x-raw,width=640,height=480,framerate=30/1 \
! clockoverlay time-format=\"%D %H:%M:%S\" \
! v4l2h264enc \
! 'video/x-h264,level=(string)4' \
! filesink location=libcamerasrc-v4l2.h264
$ gst-launch-1.0 -e libcamerasrc \
! videoconvert \
! video/x-raw,width=640,height=480,framerate=30/1,format=I420 \
! clockoverlay time-format=\"%D %H:%M:%S\" \
! v4l2h264enc \
! 'video/x-h264,level=(string)4' \
! filesink location=libcamerasrc-v4l2.h264
# filesrc -> autovideosink
$ gst-launch-1.0 -v filesrc \
location="libcamerasrc-v4l2.h264" \
! decodebin \
! videoconvert \
! autovideosink
flowchart LR
libcamerasrc[libcamerasrc]
filesink[filesink]
libcamerasrc --> |v4l2h264enc,h264| filesink
# libcamerasrc -> |v4l2h264enc,mp4| filesink
$ gst-launch-1.0 -e libcamerasrc \
! videoconvert \
! video/x-raw,width=640,height=480,framerate=30/1,format=I420 \
! clockoverlay time-format=\"%D %H:%M:%S\" \
! v4l2h264enc \
! 'video/x-h264,profile=high,level=(string)4' \
! h264parse \
! mp4mux \
! queue \
! filesink location=libcamerasrc-v4l2.mp4
# filesrc -> autovideosink
$ gst-launch-1.0 -v filesrc \
location="libcamerasrc-v4l2.mp4" \
! decodebin \
! videoconvert \
! autovideosink
13. gst-rtsp-server
RTSP server based on GStreamer (>= 1.19). This module has been merged into the main GStreamer repo for further development.
$ git clone https://github.com/GStreamer/gst-rtsp-server.git
$ cd gst-rtsp-server
$ mkdir build_xxx
$ meson setup build_xxx
$ ninja -C build_xxx
$ ninja -C build_xxx install
flowchart LR
audiotestsrc[audiotestsrc]
videotestsrc[videotestsrc]
rtspsink[rtspsink]
videotestsrc --> rtspsink
audiotestsrc -->rtspsink
$ cd build_xxx/examples
$ ./test-video
stream ready at rtsp://127.0.0.1:8554/test
# audio + video -> rtspsink
$ ./test-launch "( \
audiotestsrc \
! audioconvert \
! audioresample \
! opusenc \
! rtpopuspay name=pay1 pt=97 \
videotestsrc \
! x264enc \
! rtph264pay name=pay0 pt=96 \
)"
# video -> rtspsink
$ ./test-launch "( \
videotestsrc \
! x264enc \
! rtph264pay name=pay0 pt=96 \
)"
stream ready at rtsp://127.0.0.1:8554/test
$ gst-launch-1.0 rtspsrc \
location="rtsp://127.0.0.1:8554/test" name=src \
src. ! queue ! decodebin ! videoconvert ! autovideosink \
src. ! queue ! decodebin ! audioconvert ! audioresample ! autoaudiosink
$ gst-launch-1.0 rtspsrc \
location=rtsp://127.0.0.1:8554/test \
! decodebin \
! videoconvert ! autovideosink
flowchart LR
v4l2src[v4l2src]
rtspsink[rtspsink]
v4l2src --> |x264enc|rtspsink
$ export CAMERA_DEVICE=/dev/video0
$ cd build_xxx/examples
$ ./test-launch --gst-debug=1 "( \
v4l2src device=$CAMERA_DEVICE \
! videoconvert \
! video/x-raw,width=640,height=480,framerate=30/1,format=I420 \
! clockoverlay time-format=\"%D %H:%M:%S\" \
! x264enc \
! rtph264pay name=pay0 pt=96 \
)"
$ gst-launch-1.0 -v udpsrc \
port=50000 \
caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96' \
! rtph264depay \
! decodebin \
! videoconvert \
! autovideosink
# 如果沒有 repeat_sequence_header=1。你就必須先啟動上面的接收指令
$ gst-launch-1.0 -e v4l2src device=$CAMERA_DEVICE \
! videoconvert \
! video/x-raw,width=640,height=480,framerate=30/1,format=I420 \
! clockoverlay time-format=\"%D %H:%M:%S\" \
! x264enc \
! 'video/x-h264,stream-format=byte-stream,level=(string)4,profile=baseline' \
! queue \
! rtph264pay \
! udpsink host=127.0.0.1 port=50000
flowchart LR
libcamerasrc[libcamerasrc]
rtspsink[rtspsink]
libcamerasrc --> |x264enc|rtspsink
$ ./test-launch --gst-debug=1 "( \
libcamerasrc \
! videoconvert \
! video/x-raw,width=640,height=480,framerate=30/1,format=I420 \
! clockoverlay time-format=\"%D %H:%M:%S\" \
! x264enc \
! rtph264pay name=pay0 pt=96 \
)"
flowchart LR
libcamerasrc[libcamerasrc]
rtspsink[rtspsink]
libcamerasrc --> |v4l2h264enc|rtspsink
always hang at 1st frame,穩定度不高,時好時壞
$ ./test-launch --gst-debug=3 "( \
libcamerasrc \
! videoconvert \
! video/x-raw,width=640,height=480,framerate=30/1,format=I420 \
! clockoverlay time-format=\"%D %H:%M:%S\" \
! v4l2h264enc extra-controls=\"controls,repeat_sequence_header=1\" \
! video/x-h264,stream-format=byte-stream,level=(string)4,profile=baseline \
! queue \
! rtph264pay name=pay0 pt=96 \
)"
$ ./test-launch --gst-debug=3 "( \
libcamerasrc \
! videoconvert \
! video/x-raw,width=640,height=480,framerate=30/1,format=I420 \
! clockoverlay time-format=\"%D %H:%M:%S\" \
! v4l2h264enc output-io-mode=2 extra-controls=\"controls,force_key_frame=1,video_b_frames=1,h264_i_frame_period=1,repeat_sequence_header=1\" \
! 'video/x-h264,stream-format=byte-stream,level=(string)4,profile=baseline' \
! queue \
! rtph264pay name=pay0 pt=96 \
)"
輔助測試用。
$ gst-launch-1.0 -v udpsrc \
port=50000 \
caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96' \
! rtph264depay \
! decodebin \
! videoconvert \
! autovideosink
# 如果沒有 repeat_sequence_header=1。你就必須先啟動上面的接收指令
$ gst-launch-1.0 -e libcamerasrc \
! videoconvert \
! video/x-raw,width=640,height=480,framerate=30/1,format=I420 \
! clockoverlay time-format=\"%D %H:%M:%S\" \
! v4l2h264enc extra-controls="controls,repeat_sequence_header=1" \
! 'video/x-h264,stream-format=byte-stream,level=(string)4,profile=baseline' \
! queue \
! rtph264pay \
! udpsink host=127.0.0.1 port=50000
flowchart LR
alsasrc[alsasrc/autoaudiosrc]
v4l2src[v4l2src]
rtspsink[rtspsink]
alsasrc --> rtspsink
v4l2src --> rtspsink
穩定度不高,時好時壞
$ cd build_xxx/examples
$ ./test-launch --gst-debug=1 "( \
alsasrc \
! queue \
! audioconvert \
! audioresample \
! opusenc \
! rtpopuspay name=pay1 pt=97 \
libcamerasrc \
! videoconvert \
! video/x-raw,width=640,height=480,framerate=30/1,format=I420 \
! clockoverlay time-format=\"%D %H:%M:%S\" \
! x264enc \
! rtph264pay name=pay0 pt=96 \
)"
$ ./test-launch --gst-debug=1 "( \
autoaudiosrc \
! queue \
! audioconvert \
! audioresample \
! opusenc \
! rtpopuspay name=pay1 pt=97 \
libcamerasrc \
! videoconvert \
! video/x-raw,width=640,height=480,framerate=30/1,format=I420 \
! clockoverlay time-format=\"%D %H:%M:%S\" \
! x264enc \
! rtph264pay name=pay0 pt=96 \
)"
$ export CAMERA_DEVICE=/dev/video0
$ ./test-launch --gst-debug=1 "( \
autoaudiosrc \
! queue \
! audioconvert \
! volume volume=1.0 \
! audioresample \
! queue \
! opusenc \
! rtpopuspay name=pay1 pt=97 \
v4l2src device=$CAMERA_DEVICE \
! videoconvert \
! video/x-raw,width=640,height=480,framerate=30/1,format=I420 \
! clockoverlay time-format=\"%D %H:%M:%S\" \
! queue \
! x264enc \
! rtph264pay name=pay0 pt=96 \
)"
flowchart LR
filesrc[filesrc/multifilesrc]
v4l2src[v4l2src]
rtspsink[rtspsink]
filesrc --> rtspsink
v4l2src --> rtspsink
$ export CAMERA_DEVICE=/dev/video0
$ cd build_xxx/examples
$ ./test-launch --gst-debug=1 "( \
filesrc location="/work/BeethovenFurElise.mp3" \
! queue \
! decodebin \
! audioconvert \
! audioresample \
! opusenc \
! rtpopuspay name=pay1 pt=97 \
v4l2src device=$CAMERA_DEVICE \
! videoconvert \
! video/x-raw,width=640,height=480,framerate=30/1,format=I420 \
! clockoverlay time-format=\"%D %H:%M:%S\" \
! x264enc \
! rtph264pay name=pay0 pt=96 \
)"
$ export CAMERA_DEVICE=/dev/video0
$ cd build_xxx/examples
$ ./test-launch --gst-debug=1 "( \
multifilesrc location="/work/BeethovenFurElise.mp3" loop=true \
! queue \
! decodebin \
! audioconvert \
! audioresample \
! opusenc \
! rtpopuspay name=pay1 pt=97 \
v4l2src device=$CAMERA_DEVICE \
! videoconvert \
! video/x-raw,width=640,height=480,framerate=30/1,format=I420 \
! clockoverlay time-format=\"%D %H:%M:%S\" \
! x264enc \
! rtph264pay name=pay0 pt=96 \
)"
sudo apt update
sudo apt install software-properties-common
$ gst-launch-1.0 --help
Usage:
gst-launch-1.0 [OPTION…] PIPELINE-DESCRIPTION
Help Options:
-h, --help Show help options
--help-all Show all help options
--help-gst Show GStreamer Options
Application Options:
-t, --tags Output tags (also known as metadata)
-c, --toc Output TOC (chapters and editions)
-v, --verbose Output status information and property notifications
-q, --quiet Do not print any progress information
-m, --messages Output messages
-X, --exclude=PROPERTY-NAME Do not output status information for the specified property if verbose output is enabled (can be used multiple times)
-f, --no-fault Do not install a fault handler
-e, --eos-on-shutdown Force EOS on sources before shutting the pipeline down
--version Print version information and exit
$ gst-inspect-1.0 --help
Usage:
gst-inspect-1.0 [OPTION…] [ELEMENT-NAME | PLUGIN-NAME]
Help Options:
-h, --help Show help options
--help-all Show all help options
--help-gst Show GStreamer Options
Application Options:
-a, --print-all Print all elements
-b, --print-blacklist Print list of blacklisted files
--print-plugin-auto-install-info Print a machine-parsable list of features the specified plugin or all plugins provide.
Useful in connection with external automatic plugin installation mechanisms
--plugin List the plugin contents
-t, --types A slashes ('/') separated list of types of elements (also known as klass) to list. (unordered)
--exists Check if the specified element or plugin exists
--atleast-version When checking if an element or plugin exists, also check that its version is at least the version specified
-u, --uri-handlers Print supported URI schemes, with the elements that implement them
--no-colors Disable colors in output. You can also achieve the same by setting'GST_INSPECT_NO_COLORS' environment variable to any value.
--version Print version information and exit
$ v4l2-ctl
General/Common options:
--all display all information available
-C, --get-ctrl <ctrl>[,<ctrl>...]
get the value of the controls [VIDIOC_G_EXT_CTRLS]
-c, --set-ctrl <ctrl>=<val>[,<ctrl>=<val>...]
set the value of the controls [VIDIOC_S_EXT_CTRLS]
-D, --info show driver info [VIDIOC_QUERYCAP]
-d, --device <dev> use device <dev> instead of /dev/video0
if <dev> starts with a digit, then /dev/video<dev> is used
Otherwise if -z was specified earlier, then <dev> is the entity name
or interface ID (if prefixed with 0x) as found in the topology of the
media device with the bus info string as specified by the -z option.
-e, --out-device <dev> use device <dev> for output streams instead of the
default device as set with --device
if <dev> starts with a digit, then /dev/video<dev> is used
Otherwise if -z was specified earlier, then <dev> is the entity name
or interface ID (if prefixed with 0x) as found in the topology of the
media device with the bus info string as specified by the -z option.
-E, --export-device <dev> use device <dev> for exporting DMA buffers
if <dev> starts with a digit, then /dev/video<dev> is used
Otherwise if -z was specified earlier, then <dev> is the entity name
or interface ID (if prefixed with 0x) as found in the topology of the
media device with the bus info string as specified by the -z option.
-z, --media-bus-info <bus-info>
find the media device with the given bus info string. If set, then
-d, -e and -E options can use the entity name or interface ID to refer
to the device nodes.
-h, --help display this help message
--help-all all options
--help-io input/output options
--help-meta metadata format options
--help-misc miscellaneous options
--help-overlay overlay format options
--help-sdr SDR format options
--help-selection crop/selection options
--help-stds standards and other video timings options
--help-streaming streaming options
--help-subdev sub-device options
--help-tuner tuner/modulator options
--help-vbi VBI format options
--help-vidcap video capture format options
--help-vidout vidout output format options
--help-edid edid handling options
-k, --concise be more concise if possible.
-l, --list-ctrls display all controls and their values [VIDIOC_QUERYCTRL]
-L, --list-ctrls-menus
display all controls and their menus [VIDIOC_QUERYMENU]
-r, --subset <ctrl>[,<offset>,<size>]+
the subset of the N-dimensional array to get/set for control <ctrl>,
for every dimension an (<offset>, <size>) tuple is given.
-w, --wrapper use the libv4l2 wrapper library.
--list-devices list all v4l devices. If -z was given, then list just the
devices of the media device with the bus info string as
specified by the -z option.
--log-status log the board status in the kernel log [VIDIOC_LOG_STATUS]
--get-priority query the current access priority [VIDIOC_G_PRIORITY]
--set-priority <prio>
set the new access priority [VIDIOC_S_PRIORITY]
<prio> is 1 (background), 2 (interactive) or 3 (record)
--silent only set the result code, do not print any messages
--sleep <secs> sleep <secs>, call QUERYCAP and close the file handle
--verbose turn on verbose ioctl status reporting
#sudo apt-get remove *gstreamer*
sudo add-apt-repository ppa:tidewise/gstreamer-1.20
sudo apt list --upgradable
sudo apt-get upgrade
sudo apt-get --yes install gstreamer1.0-tools
gst-inspect-1.0 --version
#sudo apt-get --yes install gstreamer1.0
sudo apt-get --yes install gstreamer1.0-plugins-base
sudo apt-get --yes install gstreamer1.0-plugins-good
sudo apt-get --yes install gstreamer1.0-plugins-base-apps
sudo apt-get --yes install gstreamer1.0-plugins-bad
sudo apt-get --yes install gstreamer1.0-plugins-ugly
sudo apt-get --yes install libgstreamer1.0-dev
sudo apt-get --yes install libgstreamer-plugins-base1.0-dev
sudo apt-get --yes install libgstreamer-plugins-good1.0-dev
sudo apt-get --yes install libgstreamer-plugins-bad1.0-dev
# gstreamer Missing element: H.264 (Constrained Baseline Profile) decoder
sudo apt-get --yes install gstreamer1.0-libav
# WARNING: erroneous pipeline: no element "alsasrc"
sudo apt-get --yes install gstreamer1.0-alsa
export GST_PLUGIN_PATH=`pwd`
export LD_LIBRARY_PATH=`pwd`
- Amazon Kinesis Video Streams CPP Producer, GStreamer Plugin and JNI
- GstApp.AppSrc
- IPv4 Multicast Address Space Registry
sudo apt install gnome-sound-recorder
Created and designed by Lanka Hsu.
HelperX is available under the BSD-3-Clause license. See the LICENSE file for more info.