gstreamervlcrtp

RTP streaming from GStreamer to VLC failed


appsrc ! videoconvert ! videoscale ! video/x-raw,format=BGR,width=2448,height=2048,framerate=21/1 ! videoconvert ! openh264enc ! h264parse ! rtph264pay ! udpsink host=127.0.0.1 port=10001

The above pipeline is the pipeline that sends video from my RTP server to the UDP sink.

Powershell > ./gst-launch-1.0.exe udpsrc address=127.0.0.1 port=10001 caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264, payload=(int)96" ! rtph264depay ! h264parse ! openh264dec ! queue ! autovideosink

The gstreamer execution command above is streams video from my application's server. When I run this, the following is output in Windows powershell:

Use Windows high-resolution clock, precision: 1 ms
Setting pipeline to PAUSED ...
Pipeline is live and does not need PREROLL ...
Got context from element 'autovideosink0': gst.d3d11.device.handle=context, device=(GstD3D11Device)"(GstD3D11Device)\ d3d11device2", adapter=(uint)0, adapter-luid=(gint64)86769, device-id=(uint)5567, vendor-id=(uint)4098, hardware=(boolean)true, description=(string)"AMD\ Radeon(TM)\ 780M";
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock

And after about 30 seconds, a window called "Direct3D11 renderer" runs and video is output here.

I created an .sdp file to play the above streaming on VLC, but although it connects in VLC, no video is output and it pauses again.

sdp file

v=0
o=- 0 0 IN IP4 127.0.0.1
s=GStreamer H264 stream
c=IN IP4 127.0.0.1
m=video 10001 RTP/AVP 96
a=rtpmap:96 H264/90000

What's the problem?


Solution

  • UDP mtu is limited in VLC 3.0 to 1316, you can set the packet size on OBS side by setting the address to "udp://1.2.3.4:4242?pkt_size=1316"

    Though, I rather advise you, to use "rtp_mpegts" as a container on OBS side, and on VLC side to use rtp://@1.2.3.4:4242 rather than using raw UDP. Be sure to use an even port number.

    reference: https://forum.videolan.org/viewtopic.php?t=143484#p470409

    My VLC version is 3.0.20. According to the answer above, the packet size and port number were changed on the server side, and the video was now viewable in VLC.

    Modified pipeline from RTP server:

    appsrc ! videoconvert ! videoscale ! video/x-raw,format=BGR,width=2448,height=2048,framerate=21/1 ! videoconvert ! openh264enc bitrate=2000 ! h264parse ! rtph264pay mtu=1316 config-interval=1 ! udpsink host=127.0.0.1 port=10002 sync=false async=false