使用jwplayer连接到RTMP流时没有显示视频

时间:2014-12-14 12:50:22

标签: video streaming jwplayer rtmp

我一直关注this tutorial使用Raspberry Pi从我的Logitech C920网络摄像头流式传输视频。在解释我目前的问题之前,我想注意网络摄像头和Pi工作正常,即我可以使用例如VLC和cvlc成功传输视频:

cvlc v4l2:///dev/video0:chroma=h264:width=1920:height=1080 --sout '#standard{access=http,mux=ts,dst=192.168.0.8:8080,name=stream,mime=video/ts}' -vvv

但是我想从网页上观看流媒体,所以我下载了jwplayer,将其放在我的网络服务器上的一个文件夹中并创建了这个HTML页面来观看它:

<html>
<head>
<script src="jwplayer.js"></script>
</head>
<body>
<div id="myElement-teststream">Loading the player...</div>

<script type="text/javascript">
    jwplayer("myElement-teststream").setup({
        playlist: [{
            sources@: [{
                file: "rtmp:192.168.0.8:1935/live/teststream"
            }]
        }],
        height: 1080,
        primary: "flash",
        width: 1920
    });
</script>
</body>
</html>

192.168.0.8是Pi的IP地址。然而,当我去localhost时,没有玩家出现,我只能看到div“加载播放器......”

我已经启动了流媒体服务器,这是显示它正在侦听端口1935的输出:

+-----------------------------------------------------------------------------+
|                                                                     Services|
+---+---------------+-----+-------------------------+-------------------------+
| c |      ip       | port|   protocol stack name   |     application name    |
+---+---------------+-----+-------------------------+-------------------------+
|tcp|        0.0.0.0| 1112|           inboundJsonCli|                    admin|
+---+---------------+-----+-------------------------+-------------------------+
|tcp|        0.0.0.0| 1935|              inboundRtmp|              appselector|
+---+---------------+-----+-------------------------+-------------------------+
|tcp|        0.0.0.0| 8081|             inboundRtmps|              appselector|
+---+---------------+-----+-------------------------+-------------------------+
|tcp|        0.0.0.0| 8080|             inboundRtmpt|              appselector|
+---+---------------+-----+-------------------------+-------------------------+
|tcp|        0.0.0.0| 6666|           inboundLiveFlv|              flvplayback|
+---+---------------+-----+-------------------------+-------------------------+
|tcp|        0.0.0.0| 9999|             inboundTcpTs|              flvplayback|
+---+---------------+-----+-------------------------+-------------------------+
|udp|        0.0.0.0|10000|             inboundUdpTs|              flvplayback|
+---+---------------+-----+-------------------------+-------------------------+
|tcp|        0.0.0.0|  554|              inboundRtsp|              flvplayback|
+---+---------------+-----+-------------------------+-------------------------+
|tcp|        0.0.0.0| 6665|           inboundLiveFlv|             proxypublish|
+---+---------------+-----+-------------------------+-------------------------+
|tcp|        0.0.0.0| 8989|         httpEchoProtocol|            samplefactory|
+---+---------------+-----+-------------------------+-------------------------+
|tcp|        0.0.0.0| 8988|             echoProtocol|            samplefactory|
+---+---------------+-----+-------------------------+-------------------------+
|tcp|        0.0.0.0| 1111|    inboundHttpXmlVariant|                  vptests|
+---+---------------+-----+-------------------------+-------------------------+
/crtmpserver/src/crtmpserver.cpp:277 GO! GO! GO! (2384)

然后我用这个命令捕获:

./capture -F -o -c0|avconv -re -i - -vcodec copy -f  rtsp -metadata title=teststream rtsp://192.168.0.8:554/live

现在,我可以使用rtmp://192.168.0.8:1935/live/teststream使用VLC访问流,但不能从HTML页面访问。

一切似乎工作正常,网络摄像头亮起蓝色,但播放器似乎没有出现。我错过了什么?

1 个答案:

答案 0 :(得分:2)

不需要包含一个项目的播放列表,并且您的RTMP网址格式错误。也不需要“primary”属性,因为RTMP是Flash协议 - 无论如何都无法以HTML5模式显示。所以,试试这个:

<script type="text/javascript">
    jwplayer("myElement-teststream").setup({
        file: "rtmp://192.168.0.8:1935/live/teststream",
        height: 1080,
        width: 1920
    });
</script>

我不是“流媒体人”,所以我不确定文件的格式。请参阅此页面有关设置:http://support.jwplayer.com/customer/portal/articles/1430358-using-rtmp-streaming