VUE+webrtc-streamer 实现实时视频播放(监控设备-rtsp)

效果

下图则启动成功,此时在浏览器访问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端口可

html 复制代码
 <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和端口,默认8000
    this.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

相关推荐
渔舟唱晚@3 小时前
大模型数据流处理实战:Vue+NDJSON的Markdown安全渲染架构
vue.js·大模型·数据流
邪恶的贝利亚5 小时前
实现p2p的webrtc-srs版本
网络协议·webrtc·p2p
鱼樱前端6 小时前
Vue3+d3-cloud+d3-scale+d3-scale-chromatic实现词云组件
前端·javascript·vue.js
q_19132846956 小时前
基于Springboot+Vue的办公管理系统
java·vue.js·spring boot·后端·intellij idea
满分观测网友z6 小时前
vue的<router-link>的to里面的query和params的区别
前端·javascript·vue.js
BillKu6 小时前
Vue3 + TypeSrcipt 防抖、防止重复点击实例
前端·javascript·vue.js
鱼樱前端6 小时前
Vue3结合three和babylonjs实现3D数字展厅效果
前端·vue.js
Themberfue6 小时前
Vue ⑥-路由
前端·javascript·vue.js
深圳市青牛科技实业有限公司 小芋圆6 小时前
GC1809:高性能音频接收与转换芯片
科技·单片机·嵌入式硬件·音视频·智能家居·新能源
xx155802862xx6 小时前
Python如何给视频添加音频和字幕
java·python·音视频