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

相关推荐
深情废杨杨16 分钟前
前端vue-父传子
前端·javascript·vue.js
工业互联网专业1 小时前
毕业设计选题:基于springboot+vue+uniapp的驾校报名小程序
vue.js·spring boot·小程序·uni-app·毕业设计·源码·课程设计
唯创知音1 小时前
电子烟智能化创新体验:WTK6900P语音交互芯片方案,融合频谱计算、精准语音识别与流畅音频播报
人工智能·单片机·物联网·音视频·智能家居·语音识别
J不A秃V头A1 小时前
Vue3:编写一个插件(进阶)
前端·vue.js
司篂篂2 小时前
axios二次封装
前端·javascript·vue.js
姚*鸿的博客2 小时前
pinia在vue3中的使用
前端·javascript·vue.js
天下无贼!4 小时前
2024年最新版Vue3学习笔记
前端·vue.js·笔记·学习·vue
cuijiecheng20184 小时前
音视频入门基础:AAC专题(6)——FFmpeg源码中解码ADTS格式的AAC的Header的实现
ffmpeg·音视频·aac
爱喝水的小鼠5 小时前
Vue3(一) Vite创建Vue3工程,选项式API与组合式API;setup的使用;Vue中的响应式ref,reactive
前端·javascript·vue.js
小晗同学5 小时前
Vue 实现高级穿梭框 Transfer 封装
javascript·vue.js·elementui