Skip to content

Instantly share code, notes, and snippets.

@robcowie
Last active June 16, 2023 19:27
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 robcowie/1f3602e8d4940941489fd09d8a0c782d to your computer and use it in GitHub Desktop.
Save robcowie/1f3602e8d4940941489fd09d8a0c782d to your computer and use it in GitHub Desktop.
Gstreamer Pipeline Examples

Gstreamer Examples

Videotest Source

gst-launch-1.0 -e videotestsrc pattern=ball num-buffers=300 \
! video/x-raw,width=640,height=480,framerate=30/1 \
! nvvideoconvert \
! nvv4l2h265enc \
! mp4mux \
! filesink location=/wastestream-home/test.mp4

USB Camera Source

gst-launch-1.0 v4l2src device=/dev/camera num-buffers=300 \
! 'video/x-raw,width=1920,height=1080,framerate=30/1' \
! nvvideoconvert \
! 'video/x-raw(memory:NVMM)' \
! nvv4l2h265enc \
! h265parse \
! qtmux \
! filesink location=/wastestream-home/output_30.mp4

USB Camera Source with HW-accelerated Source

This runs but produces broken video

gst-launch-1.0 nvv4l2camerasrc device=/dev/camera num-buffers=600 \
! 'video/x-raw(memory:NVMM),format=(string)UYVY,width=960,height=540,framerate=60/1' \
! nvvideoconvert \
! nvv4l2h265enc \
! h265parse \
! qtmux \
! filesink location=/wastestream-home/output_60_04.mp4

RTP Over UDP Transmission

Sender

gst-launch-1.0 -e \
videotestsrc ! video/x-raw,width=1280,height=720,framerate=30/1 \
! x264enc tune=zerolatency bitrate=5000 \
! video/x-h264,profile=high \
! h264parse \
! rtph264pay \
! udpsink host=224.1.1.1 port=5000 auto-multicast=true

Receiver

gst-launch-1.0 -e \
udpsrc multicast-group=224.1.1.1 port=5000 \
caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264" \
! rtph264depay \
! h264parse \
! mp4mux \
! filesink location=/data/output5.mp4

Shared Memory Transmission

Sender

gst-launch-1.0 \
    videotestsrc is-live=true \
    ! videoconvert \
    ! videoscale \
    ! video/x-raw, width=1920, height=1080, framerate=30/1 \
    ! x265enc \
    ! shmsink socket-path=/tmp/gs shm-size=2000000 wait-for-connection=0

Receiver

gst-launch-1.0 \
    shmsrc socket-path=/tmp/gs is-live=true do-timestamp=true \
    ! h265parse \
    ! matroskamux ! filesink location=shm_testfile1.mkv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment