3. GStreamer コマンドサンプル集#

3.1. C1#

3.1.1. カメラからの画像出力#

gst-launch-1.0 v4l2src io-mode=0 device=/dev/video0 do-timestamp=true ! 'video/x-raw, width=1920, height=1280, framerate=30/1, format=UYVY' ! videoscale ! xvimagesink sync=false

3.1.2. mp4として記録する#

gst-launch-1.0 -ve v4l2src io-mode=0 device=/dev/video0 do-timestamp=true ! 'video/x-raw, width=1920, height=1280, framerate=30/1, format=UYVY' ! nvvidconv ! nvv4l2h265enc bitrate=3000000 ! h265parse ! qtmux ! filesink location=out.mp4

3.1.3. フレームレートを表示する#

gst-launch-1.0 v4l2src io-mode=0 device=/dev/video0 do-timestamp=true '!' 'video/x-raw, width=1920, height=1280, framerate=30/1, format=UYVY' '!' videoscale '!' fpsdisplaysink video-sink=xvimagesink  sync=false -v

3.1.4. 画像を表示しながらmp4として記録する#

gst-launch-1.0 -ve v4l2src io-mode=0 device=/dev/video0 do-timestamp=true ! "video/x-raw, width=1920, height=1280, framerate=30/1, format=UYVY" ! videoconvert ! tee name=para ! queue ! x264enc ! h264parse ! qtmux ! filesink location=out.mp4 async=false para. ! queue ! fpsdisplaysink video-sink=xvimagesink fps-update-interval=5000 text-overlay=false sync=false

3.1.5. 画像を表示しながらmp4として記録する#

gst-launch-1.0 -ve \

v4l2src io-mode=0 device=/dev/video0 do-timestamp=true ! "video/x-raw, width=1920, height=1280, framerate=30/1, format=UYVY" ! tee name=camera1 \
v4l2src io-mode=0 device=/dev/video1 do-timestamp=true ! "video/x-raw, width=1920, height=1280, framerate=30/1, format=UYVY" ! tee name=camera2 \
camera1. ! nvvidconv ! nvv4l2h265enc bitrate=10000000 ! h265parse !  qtmux ! filesink location=out_1.mp4 \
camera1. ! queue ! fpsdisplaysink video-sink=xvimagesink fps-update-interval=5000 text-overlay=false sync=false \
camera2. ! nvvidconv ! nvv4l2h265enc bitrate=10000000 ! h265parse !  qtmux ! filesink location=out_2.mp4 \
camera2. ! queue ! fpsdisplaysink video-sink=xvimagesink fps-update-interval=5000 text-overlay=false sync=false

3.1.6. nvv4l2camerasrc#

gst-launch-1.0 nvv4l2camerasrc device=/dev/video0 '!' 'video/x-raw(memory:NVMM), width=1920, height=1280, framerate=30/1, format=UYVY' '!' nvvidconv ! 'video/x-raw(memory:NVMM)' ! nv3dsink  sync=false -v

3.2. C2#

3.2.1. カメラからの画像出力#

gst-launch-1.0 v4l2src io-mode=0 device=/dev/video0 do-timestamp=true '!' 'video/x-raw, width=2880, height=1860, framerate=30/1, format=UYVY' '!' videoscale '!' xvimagesink sync=false -v

3.2.2. mp4として記録する#

gst-launch-1.0 -ve v4l2src io-mode=0 device=/dev/video0 do-timestamp=true ! 'video/x-raw, width=2880, height=1860, framerate=30/1, format=UYVY' ! nvvidconv ! nvv4l2h265enc bitrate=3000000 ! h265parse ! qtmux ! filesink location=out.mp4

3.2.3. フレームレートを表示する#

gst-launch-1.0 v4l2src io-mode=0 device=/dev/video0 do-timestamp=true '!' 'video/x-raw, width=2880, height=1860, framerate=30/1, format=UYVY' '!' videoscale '!' fpsdisplaysink video-sink=xvimagesink sync=false -v

3.2.4. 1920x1080にスケールする#

gst-launch-1.0 v4l2src io-mode=0 device=/dev/video0 do-timestamp=true ! 'video/x-raw, width=2880, height=1860, framerate=10/1, format=UYVY' ! nvvidconv ! 'video/x-raw(memory:NVMM),format=RGBA,width=1920,height=1280' ! nv3dsink sync=false

3.2.5. 200x200にクロップする#

gst-launch-1.0 v4l2src io-mode=0 device=/dev/video0 do-timestamp=true ! 'video/x-raw, width=2880, height=1860, framerate=30/1, format=UYVY' ! nvvidconv top=0 bottom=200 left=0 right=200 ! 'video/x-raw(memory:NVMM), width=200, height=200, framerate=30/1, format=RGBA' ! nv3dsink sync=false

3.2.6. nvcompositorを使用した縮小+同時再生#

gst-launch-1.0 -v \
nvcompositor name=m \
sink_0::xpos=0 sink_0::ypos=0 \
sink_1::xpos=1440 sink_1::ypos=0  \
sink_2::xpos=0 sink_2::ypos=930 \
sink_3::xpos=1440 sink_3::ypos=930 ! \
nvegltransform ! \
nveglglessink sync=no \
v4l2src device=/dev/video0 io-mode=0 ! \
'video/x-raw, width=2880, height=1860, framerate=30/1, format=UYVY' ! \
queue ! \
nvvidconv ! \
"video/x-raw(memory:NVMM), width=1440, height=930, format=RGBA" ! \
m.sink_0 \
v4l2src device=/dev/video1 io-mode=0 ! \
'video/x-raw, width=2880, height=1860, framerate=30/1, format=UYVY' ! \
queue ! \
nvvidconv ! \
"video/x-raw(memory:NVMM), width=1440, height=930, format=RGBA" ! \
m.sink_1 \
v4l2src device=/dev/video2 io-mode=0 ! \
'video/x-raw, width=2880, height=1860, framerate=30/1, format=UYVY' ! \
queue ! \
nvvidconv ! \
"video/x-raw(memory:NVMM), width=1440, height=930, format=RGBA" ! \
m.sink_2 \
v4l2src device=/dev/video3 io-mode=0 ! \
'video/x-raw, width=2880, height=1860, framerate=30/1, format=UYVY' ! \
queue ! \
nvvidconv ! \
"video/x-raw(memory:NVMM), width=1440, height=930, format=RGBA" ! \
m.sink_3\

3.2.7. nvv4l2camerasrc#

gst-launch-1.0 nvv4l2camerasrc  device=/dev/video0 do-timestamp=true ! 'video/x-raw(memory:NVMM), width=2944, height=1860, framerate=30/1, format=UYVY' ! nvvidconv top=0 bottom=1860 left=0 right=2880 ! 'video/x-raw(memory:NVMM), width=2880, height=1860, framerate=30/1, format=NV12' ! nv3dsink

注釈

nvv4l2camerasrcは256byte単位でのアライメントが必要なため、nvv4l2camerasrcで取り込む際にはwidth=2944と設定し、後段で2880pixに切り出す必要があります。詳細は以下の Nvidia forum を参照して下さい。

YUV camera(5.4M) preview issue