GStreamer RTSP and udpsrc/udpsink dropping packets at medium/higher bitrates

Hi all,

I have been trying to get an RTSP H264 1080p/30 stream working at 8mbits.
The stream works if I keep the bitrate to around 1Mbit, but above this it struggles. There is a similar issue with a udpsink/udpsrc even if run from the same machine.

I am on Xavier AGX with Jetpack 5.02, and GStreamer 1.16.3.

Sending stream for UDP: sudo gst-launch-1.0 -v v4l2src device=/dev/video0 ! ‘image/jpeg,width=1920,height=1080,framerate=30/1,format=MJPG’ ! jpegdec ! queue ! nvvidconv ! nvv4l2h264enc control-rate=1 bitrate=8000000 idrinterval=10 maxperf-enable=1 ! “video/x-h264” ! queue ! h264parse config-interval=1 ! rtph264pay mtu=1024 config-interval=1 ! queue ! udpsink host= port=5600

If I then background this and run a receiving task:
gst-launch-1.0 udpsrc port=5600 ! “application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96” ! rtph264depay ! h264parse ! matroskamux ! filesink location=“Cam.mkv”

I get a file that doesn’t play, and if I look at the size it is 0.5Mbytes/second (rather than the 1Mbyte it should be).

I can make things work with the UDP by adding a buffer-size=2500000 to both sink and src. Or if I increase packet size (rtph264pay mtu=45000) then the file transfers correctly. However neither of these can be used on the RTSP stream.
Looking at the H264 file received, I think we are receiving nearly all P frames, but when we get a burst of packets from an I frame a lot are lost. Once in a while an I-Frame gets through, and then the video displays correctly for a while before getting worse and worse again.

If it makes a difference, my RTSP stream is launched with
"( udpsrc address= port=50000 caps = "application/x-rtp, "
"media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, "
"payload=(int)96" ! rtph264depay ! rtph264pay name=pay0 pt=96 "
"udpsrc address= port=50001 caps = "application/x-rtp, "
“media=(string)audio, clock-rate=(int)44100, encoding-name=(string)”
"MP4A-LATM, payload=(int)97, cpresent=(string)0, "
"config=(string)40002410" ! rtpmp4adepay ! rtpmp4apay name=pay1 pt=97 "
"udpsrc address= port=50002 caps = "application/x-rtp, "
“media=(string)audio, clock-rate=(int)44100, encoding-name=(string)”
"MP4A-LATM, payload=(int)98, cpresent=(string)0, "
“config=(string)40002410" ! rtpmp4adepay ! rtpmp4apay name=pay2 pt=98 )”);

Has anyone got ideas on where I am going wrong?

Thank you in advance.

If setting buffer-size with udp helps, you may try setting kernel socket max buffer size to a bigger value from systctl:

# Get current values
sudo sysctl net.core.rmem_max
sudo sysctl net.core.wmem_max

# increase transmit max buffer size
sudo sysctl -w net.core.wmem_max=1000000

Alternatively, does TCP transport better work ?

gst-play-1.0 rtspt://

Thank you for the reply.
kernel buffer sizes doesn’t seem to help sadly, but i did not know you could use tcp on rtsp. That’s really helpful, thank you.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.