46

I'm having some trouble figuring out how to create a simple rtp stream with gstreamer and display it on vlc.

I've installed GStreamer 0.10.30 and VLC 1.1.3. My only requirement is to use MPEG4 or H.264 codecs.

Right now, I can stream the GStreamer videotestsrc through this simple pipeline:

gst-launch videotestsrc ! ffenc_mpeg4 ! rtpmp4vpay ! udpsink host=127.0.0.1 port=5000

which outputs the "caps" needed by the client to receive the stream:

/GstPipeline:pipeline0/GstUDPSink:udpsink0.GstPad:sink: caps = application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)MP4V-ES, profile-level-id=(string)1, config=(string)000001b001000001b58913000001000000012000c48d8800f50a041e1463000001b24c61766335322e3132332e30, payload=(int)96, ssrc=(uint)365697461, clock-base=(uint)390754204, seqnum-base=(uint)10399

I'm also able to display the stream using the following pipeline:

gst-launch udpsrc uri=udp://127.0.0.1:5000 caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)MP4V-ES, profile-level-id=(string)1, config=(string)000001b001000001b58913000001000000012000c48d88007d0a041e1463000001b24c61766335322e3132332e30, payload=(int)96, ssrc=(uint)298758266, clock-base=(uint)3097828288, seqnum-base=(uint)63478" ! rtpmp4vdepay ! ffdec_mpeg4 ! autovideosink

but when I try to receive the stream with vlc:

vlc -vvv rtp://127.0.0.1:5000

I get nothing...

4
  • Question: Where is the path to this file, filename and is it a configuration file that you just edited in gstreamer? Commented Mar 3, 2014 at 4:11
  • What does the payload=(int)96 mean?
    – tkarls
    Commented Oct 14, 2016 at 7:53
  • How can I know your streaming command is using this settings/caps "/GstPipeline:pipeline0/GstUDPSink:udpsink0.GstPad:sink: (...)". Where do you get this information from?
    – Robert
    Commented Apr 6, 2017 at 6:36
  • 4
    For those coming in the future: you might get an error saying there's no such element as ffenc_mpeg4. Just replace ffenc_mpeg4 and ffdec_mpeg4 with avenc_mpeg4 and avdec_mpeg4 respectively.
    – SSBakh
    Commented Nov 6, 2020 at 12:29

3 Answers 3

49

I've solved the issue, it just needs an sdp file like this:

v=0
m=video 5000 RTP/AVP 96
c=IN IP4 127.0.0.1
a=rtpmap:96 MP4V-ES/90000

and the option "send-config=true" for the rtpmp4vpay element:

gst-launch videotestsrc ! ffenc_mpeg4 ! rtpmp4vpay send-config=true ! udpsink host=127.0.0.1 port=5000

and then, it can be played with

vlc <filename>.sdp
7
  • I've found how to write sdp file for any codec. See en.wikipedia.org/wiki/RTP_audio_video_profile then go to coresponding RFC link that have sample of SDP syntax Commented Aug 18, 2015 at 7:03
  • This is the kind of behaviour that deserves multiple upvotes. The question was super relevant to me but without the self answer it would be kind of useless. Commented Oct 29, 2015 at 9:26
  • 4
    Using gstreamer 1.0 the line should be gst-launch videotestsrc ! ffenc_mpeg4 ! rtpmp4vpay config-interval=3 ! udpsink host=127.0.0.1 port=5000 Where config-interval=3 is the interval in seconds sending the config data. send-config is now deprecated. Commented Oct 30, 2015 at 10:13
  • How to generate SDP file for MJPEG stream? rfc2435 seems too large. Also rtpjpegpay don't have option like send-config.
    – beemaster
    Commented May 4, 2016 at 20:14
  • Since using 127.0.0.1 isn't clear, I just thought I would mention: in a multiple machine environment, this would be causing your client (VLC or whatever) to open an inbound port (so possibly firewall rules needed) and the stream would be sending to it. This solution isn't providing you with a way to easily have multiple VLC clients connect to a single endpoint. (that confused me a bit). Commented Jun 20, 2016 at 5:37
27

How to for H264 and new gstreamer (windows)

gst-launch-1.0 videotestsrc ! openh264enc ! rtph264pay config-interval=10 pt=96 ! udpsink host=127.0.0.1 port=5000

sdp file:

v=0
m=video 5000 RTP/AVP 96
c=IN IP4 127.0.0.1
a=rtpmap:96 H264/90000

for other codec see https://en.wikipedia.org/wiki/RTP_audio_video_profile and corresponding SDP example in RFC link

3
  • 4
    You mistyped the port number, otherwise it is working - tested but with x264enc (on Linux).. good tip on the RFC
    – nayana
    Commented Oct 2, 2015 at 12:03
  • 3
    And the OSX equivalent: gst-launch-1.0 videotestsrc ! vtenc_h264 ! rtph264pay config-interval=10 pt=96 ! udpsink host=127.0.0.1 port=5000 (instead of openh264enc) Commented Jun 5, 2018 at 6:15
  • In my case adding h264parse after openh264enc works on Windows; gst-launch-1.0 videotestsrc ! openh264enc ! h264parse ! rtph264pay config-interval=10 pt=96 ! udpsink host=127.0.0.1 port=5000
    – wsys
    Commented Aug 9, 2023 at 5:06
3

For some of you just check the answers, but not comments below the answers

For GStreamer 1.18.xxx. ffenc_mpeg4 was renamed to avenc_mpeg4(This confuses me alot) So try command:

gst-launch-1.0 videotestsrc ! avenc_mpeg4 ! rtpmp4vpay config-interval=1 ! udpsink host=127.0.0.1 port=5000

About VLC same as Dave's answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.