效果
下圖則啟動成功,此時在瀏覽器訪問127.0.0.1:8000可以看到本機監控畫面
1、下載webrtc-streamer
地址:https://github.com/mpromonet/webrtc-streamer/releases
2、解壓下載包
3、雙擊webrtc-streamer.exe啟動服務
4、將下載包html文件夾下webrtcstreamer.js
文件和html/libs文件夾下adapter.min.js
文件復制到VUE項目public目錄下。在index.html
文件里引入這兩個js文件
5.頁面 中使用
注意:第三步在本機啟動服務所以 new WebRtcStreamer(id,serverUrl)中URL傳入127.0.0.1端口可
<template><div><div class="coTitle">視頻</div><video id='video' controls autoplay autobuffer muted preload='auto'style='width:90%; height: 290px; margin-left:5%;object-fit: fill;'></video></div>
</template><script>
export default {name: 'index1',data() {return {webRtcServer: null}},mounted() {//video:需要綁定的video控件ID//127.0.0.1:8000:啟動webrtc-streamer的設備IP和端口,默認8000this.webRtcServer = new WebRtcStreamer('video', 'http//127.0.0.1:8000')//需要查看的rtsp地址this.webRtcServer.connect('rtsp://user:password@ip:port/cam/realmonitor?channel=1&subtype=0')//rtsp://user:password@ip:port/h264/ch1/main/av_stream--海康},beforeDestroy() {this.webRtcServer.disconnect()this.webRtcServer = null},
}
</script><style scoped></style>
6、運行項目可查看監控視頻播放效果
文章參考鏈接:https://blog.csdn.net/liona_koukou/article/details/126605137