如何使用Gstreamer通过RTMP流式传输?

时间:2017-01-09 15:05:07

标签: streaming gstreamer rtmp wowza

我正在尝试使用Gstreamer将视频和音频流式传输到RTMP服务器(Wowza),但存在许多问题。

几乎没有关于如何正确使用rtmpsink的文档,这是一个通过RTMP将媒体发送到指定服务器的插件。不仅如此,制作rtmpsink兼容的正确Gstreamer管道只是目前的一次试错练习。

我目前的Gstreamer管道是:

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

在我的Linux机器上运行上述内容会出现此错误:

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)

由于缺乏Wowza方面的文档,另一个问题实际上是指向正确的IP地址指向rtmpsink并且缺少Gstreamer方面的文档,除了发现的一些示例之外,正确的RTMP身份验证是难以理解的在某些论坛上由于其他变量而无法确认是否有效。

使用rtmpsink通过RTMP进行流式传输的正确Gstreamer管道是什么?如何在有和没有身份验证的情况下正确实现rtmpsink

1 个答案:

答案 0 :(得分:2)

实际上你正在使用的管道工作正常。

然而,禁用Wowza的RTMP安全性是必须的,也指向正确的方向。

遵循下一页的指南:https://www.wowza.com/forums/content.php?36-How-to-set-up-live-streaming-using-an-RTMP-based-encoder

  • 重新检查应用程序播放类型中是否启用了RTMP:

Applications

  • 禁用所有安全选项以确保GStreamer兼容性。

Security

  • 播放安全性标签中,检查是否已选择无客户端限制(默认情况下已选中)。

Playback

  • 来源标签中,在左侧列中,可以检查服务器设置:

Output

完成所有这些步骤后,我们可以启动上一个管道:

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

它可以工作,可以点击 Test Players 按钮查看结果。结果如下:

TestPlayers

虽然它可能超出范围,但可以向管道添加音频并改进它添加一些缺少的属性:

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.

关于密码加密内容,使用GStreamer实现它并不是直截了当的。

相关问题