How to stream via RTMP using Gstreamer?

26.9k views Asked by At

I am attempting to stream video and audio using Gstreamer to an RTMP Server (Wowza) but there are a number of issues.

There is almost no documentation about how to properly utilise rtmpsink, a plugin that sends media via RTMP to a specified server. Not only that but crafting the correct Gstreamer pipeline that is rtmpsink compatible is simply a trial and error exercise currently.

My current Gstreamer pipeline is:

sudo gst-launch-1.0 -e videotestsrc ! queue ! videoconvert ! x264enc ! flvmux streamable=true ! queue ! rtmpsink location='rtmp://<ip_address>/live live=true'

Running the above on my Linux machine spits out this error:

Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Redistribute latency...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
ERROR: from element /GstPipeline:pipeline0/GstRTMPSink:rtmpsink0: Could not     open resource for writing.
Additional debug info:
gstrtmpsink.c(246): gst_rtmp_sink_render (): /GstPipeline:pipeline0/GstRTMPSink:rtmpsink0:
Could not connect to RTMP stream "rtmp://31.24.217.8/live live=true" for writing
EOS on shutdown enabled -- waiting for EOS after Error
Waiting for EOS...
ERROR: from element /GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0: Internal data flow error.
Additional debug info:
gstbasesrc.c(2948): gst_base_src_loop (): /GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0:
streaming task paused, reason error (-5)
ERROR: from element /GstPipeline:pipeline0/GstQueue:queue0: Internal data flow error.
Additional debug info:
gstqueue.c(992): gst_queue_handle_sink_event (): /GstPipeline:pipeline0/GstQueue:queue0:
streaming task paused, reason error (-5)

Due to lack of documentation on the Wowza side another issue is actually pin-pointing the correct ip address to point rtmpsink at and lack of documentation on the Gstreamer side, proper RTMP authentication is elusive aside from some examples found on some forums of which cannot be confirmed as working due to other variables.

What is the correct Gstreamer pipeline for streaming via RTMP using rtmpsink and how do I properly implement rtmpsink for this with and without authentication?

1

There are 1 answers

3
jgorostegui On

Actually the pipeline you're using is working fine.

However, disabling the Wowza's RTMP security it is a must, also pointing to the correct direction of too.

Following the guidelines on the next page: https://www.wowza.com/forums/content.php?36-How-to-set-up-live-streaming-using-an-RTMP-based-encoder

  • Re-check that RTMP is enabled in application Playback Types:

Applications

  • Disable all security options to assure the GStreamer compatibility.

Security

  • In the Playback Security tab, check that No client restrictions is selected (selected by default).

Playback

  • In the Sources tab, in the left columns, it is possible to check the server settings:

Output

Once we have done all this steps, we can launch the previous pipeline:

gst-launch-1.0 -e videotestsrc ! queue ! videoconvert ! x264enc ! flvmux streamable=true ! queue ! rtmpsink location='rtmp://192.168.1.40:1935/livertmp/myStream'

It works and it is possible to check the result clicking on Test Players button. The result is next:

TestPlayers

Although probably it is out of scope, it is possible to add audio to the pipeline and improve it adding some properties that were missing:

gst-launch-1.0 videotestsrc is-live=true ! videoconvert ! x264enc bitrate=1000 tune=zerolatency ! video/x-h264 ! h264parse ! video/x-h264 ! queue ! flvmux name=mux ! rtmpsink location='rtmp://192.168.1.40:1935/livertmp/myStream' audiotestsrc is-live=true ! audioconvert ! audioresample ! audio/x-raw,rate=48000 ! voaacenc bitrate=96000 ! audio/mpeg ! aacparse ! audio/mpeg, mpegversion=4 ! mux.

Regarding to the password encrypted content, is not straightforward to achieve it with GStreamer.