3. GStreamer command samples#

3.1. C1#

3.1.1. Display the output from the camera#

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. Record video as 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. Display framerate#

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. Simultaneous image displaying and recording#

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. Simultaneous image displaying and recording with multiple cameras#

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. Display the output from the camera#

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. Record video as 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. Display framerate#

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. Scale down (to 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. Crop (to 200x200 from top-left)#

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. Shrinking & simultaneous display (using 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

Note

As nvv4l2camerasrc requires the 256 Bytes alignment, you need to set width=2944 first and crop the image. Please refer to the following Nvidia forum for the details.

YUV camera(5.4M) preview issue