2

我正在通过videojs开发rtmps直播。

但我有一个问题。T_T

rtmps 直播不播放。(Rtmp 效果很好。)

即使您使用另一个 Flash 播放器,它也不会播放。(例如) jwplayer


<video ...
data-setup='{ "techOrder":["html5", "flash"]}'>
...
<source src = " ** RTMPS_URL ** " type ="rtmp/flv"/>
</video>
  • RTMPS_URL : rtmps://{SERVER_URL}/?{PARAMETER}
  • SERVER_URL : IP:PORT/args1/args2
  • 参数:键=值

videojs 错误消息。

“闪存:rtmpconnectfailure”

疑似部分如下。

  1. rtmps服务器正在写个人证书。(证书未经公共机构认证)所以我在我的电脑上安装了个人证书,错误是一样的。

  2. 据说 Videojs 博客提供 rtmps。你确定吗?

我究竟做错了什么?

我需要你的帮助。

谢谢 :-)

4

1 回答 1

1

我希望你解决了这个问题,但我仍然在这里为那些和我一样有同样问题的人发布解决方案。

我的工作环境:带有rtmp模块的nginx,ffmpeg从ip camera获取RTSP并以flv格式推送到nginx,在web中显示这个流。

videojs 改变了很多,所以我把我的 html 放在这里:

<html>
<script src="./video.min.js"></script>  //download the videojs from npm or use the online url one
<link rel="stylesheet" type="text/css" href="./video-js.css">
<script src="https://cdn.jsdelivr.net/npm/videojs-flash@2/dist/videojs-flash.min.js></script>

<body>
<video id="liveVideo" class="video-js" controls autoplay preload="auto" width="320" height="240" data-setup="{}">
        <!-- <source src="rtmp://ns8.indexforce.com/home/mystream" type="rtmp/flv">-->
        <!-- the above rtmp link is for testing your videojs works or not -->
        <source src="rtmp://192.168.1.180/cam1/" type="rtmp/flv">
</video>
</body>
</html>

########################

rtmp://192.168.1.180/cam1/ is my nignx server ip address (both my server and client are in the same local network)

ffmpeg -i <Your video/stream> -f flv <Your RTMP url>

########################

我首先得到 FLASH: rtmpconnectfailure, VIDEOJS: ERROR: (CODE:0 MEDIA_ERR_CUSTOM) FLASH: rtmpconnectfailure。

I solved by just adding a '/' at the end in "<video....><source src="rtmp://.../.../ <----this one '/' "></video>" in my html file

因此,请确保在源 URL 的末尾添加“/”。

2020 年 12 月在 Chrome、Opera 和 Edge 中成功运行(必须在浏览器设置中启用 flash)

祝你好运:o)

于 2020-12-04T05:08:22.100 回答