Skip to content

Instantly share code, notes, and snippets.

@raspi
Last active December 18, 2020 15:11
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 raspi/b903efdbcc7599dd61c85cc735e404d3 to your computer and use it in GitHub Desktop.
Save raspi/b903efdbcc7599dd61c85cc735e404d3 to your computer and use it in GitHub Desktop.
gstreamer RTP Sender and Receiver
#!/bin/bash
set -eu
set -o pipefail
DEST=127.0.0.1
# this adjusts the latency in the receiver
LATENCY=0
VIDEO_CAPS="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264"
VIDEO_DEC="avdec_h264"
#VIDEO_DEC="rtph264depay ! nvh264dec"
#VIDEO_DEC="rtph264depay ! nvh264dec"
#VIDEO_SINK="videoconvert ! autovideosink"
VIDEO_SINK="autovideosink"
gst-launch-1.0 -v rtpbin name=rtpbin drop-on-latency=true latency=$LATENCY \
udpsrc caps=$VIDEO_CAPS port=5000 ! rtpbin.recv_rtp_sink_0 \
rtpbin. ! rtph264depay ! $VIDEO_DEC ! $VIDEO_SINK \
udpsrc port=5001 ! rtpbin.recv_rtcp_sink_0 \
rtpbin.send_rtcp_src_0 ! udpsink port=5005 host=$DEST sync=false async=false
#!/bin/bash
set -eu
set -o pipefail
# change this to send the RTP data and RTCP to another host
DEST=127.0.0.1
# H264 encode from the source
VELEM="ximagesrc display-name=:99"
#VELEM="videotestsrc is-live=1"
VCAPS="video/x-raw,width=1280,height=720,framerate=60/1"
VSOURCE="$VELEM ! queue ! videorate ! videoconvert ! $VCAPS"
VENC="nvh264enc zerolatency=true ! video/x-h264,stream-format=byte-stream ! rtph264pay config-interval=1 pt=96"
VRTPSINK="udpsink port=5000 host=$DEST name=vrtpsink"
VRTCPSINK="udpsink port=5001 host=$DEST sync=false async=false name=vrtcpsink"
VRTCPSRC="udpsrc port=5005 name=vrtpsrc"
gst-launch-1.0 -e -v rtpbin name=rtpbin latency=0 drop-on-latency=true \
$VSOURCE ! $VENC ! rtpbin.send_rtp_sink_0 \
rtpbin.send_rtp_src_0 ! $VRTPSINK \
rtpbin.send_rtcp_src_0 ! $VRTCPSINK \
$VRTCPSRC ! rtpbin.recv_rtcp_sink_0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment