我希望你解决了这个问题,但我仍然在这里为那些和我一样有同样问题的人发布解决方案。
我的工作环境:带有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)