Skip to content

Instantly share code, notes, and snippets.

@fweller
Created April 19, 2022 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fweller/f5a12b79d1ee16e18a3a04e9b42ed80f to your computer and use it in GitHub Desktop.
Save fweller/f5a12b79d1ee16e18a3a04e9b42ed80f to your computer and use it in GitHub Desktop.
Flint's cheat-sheet for GStreamer on the NXP i.MX 8M Plus
Flint's cheat-sheet for GStreamer on the NXP i.MX 8M Plus
Most of these Gists assume the use of two pieces of hardware:
NXP i.MX 8M Plus Evaluation Kit: 8MPLUSLPD4-EVK i.MX 8M Plus EVK
NXP Basler MIPI 8 Mpixel (4K) camera kit
--------------------------------------------------
Send camera video to HDMI display
export caps="video/x-raw, format=(string)YUY2, width=(int)3840, height=(int)2160, framerate=(fraction)30/1, colorimetry=(string)2:6:5:1, interlace-mode=(string)progressive"
gst-launch-1.0 -v v4l2src device=/dev/video0 ! $caps ! waylandsink
--------------------------------------------------
Use 2D GPU to resize video
export input="video/x-raw,width=1920,height=1080,framerate=30/1"
gst-launch-1.0 -v v4l2src device=/dev/video0 ! imxvideoconvert_g2d ! $input ! waylandsink
--------------------------------------------------
Use tee to split video into multiple streams, then resize video, before sending to display
export size-1k="video/x-raw,width=1920,height=1080,framerate=30/1"
export size-vga="video/x-raw,width=640,height=480,framerate=30/1"
export size-qvga="video/x-raw,width=320,height=240,framerate=30/1"
gst-launch-1.0 -v v4l2src device=/dev/video0 ! imxvideoconvert_g2d ! $size-1k \
! tee name=t \
t. ! queue ! imxvideoconvert_g2d ! $size-vga ! waylandsink \
t. ! queue ! imxvideoconvert_g2d ! $size-qvga ! waylandsink
--------------------------------------------------
AVC (h.264) encode multiple streams, save to file, while watching live
NOTE: h264parse is required after vpuenc_h264 before sending to mp4mux.
export size-1k="video/x-raw,width=1920,height=1080,framerate=30/1"
export size-vga="video/x-raw,width=640,height=480,framerate=30/1"
export size-qvga="video/x-raw,width=320,height=240,framerate=30/1"
gst-launch-1.0 -v v4l2src device=/dev/video0 \
! imxvideoconvert_g2d ! $size-1k \
! tee name=t \
t. ! queue ! imxvideoconvert_g2d ! $size-vga \
! vpuenc_h264 ! h264parse ! mp4mux ! filesink location=size-vga.mp4 \
t. ! queue ! imxvideoconvert_g2d ! $size-qvga \
! vpuenc_h264 ! h264parse ! mp4mux ! filesink location=size-qvga.mp4 \
t. ! queue ! waylandsink
--------------------------------------------------
HEVC (h.265) encode multiple streams, save to file, while watching live
NOTE: h265parse is required after vpuenc_hevc before sending to mp4mux.
export size-1k="video/x-raw,width=1920,height=1080,framerate=30/1"
export size-vga="video/x-raw,width=640,height=480,framerate=30/1"
export size-qvga="video/x-raw,width=320,height=240,framerate=30/1"
gst-launch-1.0 -v v4l2src device=/dev/video0 \
! imxvideoconvert_g2d ! $size-1k \
! tee name=t \
t. ! queue ! imxvideoconvert_g2d ! $size-vga \
! vpuenc_hevc ! h265parse ! mp4mux ! filesink location=size-vga.mp4 \
t. ! queue ! imxvideoconvert_g2d ! $size-qvga \
! vpuenc_hevc ! h265parse ! mp4mux ! filesink location=size-qvga.mp4 \
t. ! queue ! waylandsink
--------------------------------------------------
Specify HEVC (h.265) encoder bitrate
NOTE: bitrate is specified in kbps
export size-1k="video/x-raw,width=1920,height=1080,framerate=30/1"
gst-launch-1.0 -v v4l2src device=/dev/video0 \
! imxvideoconvert_g2d ! $size-1k \
! vpuenc_hevc vpuenc_hevc bitrate=2000 ! h265parse \
! mp4mux ! filesink location=size-1k.mp4
--------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment