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

相关推荐
tryCbest3 小时前
Vue3—— 第 18 篇:Vue 2 到 Vue 3 迁移指南——升级避坑全记录
前端·vue.js
anyup4 小时前
自带 uni-app x 页面级能力,uView Pro X 8 个开箱即用的工具函数
前端·vue.js·uni-app
开开心心就好4 小时前
两张表格数据对比工具,不用写函数也能查
算法·spring·智能手机·pdf·电脑·intellij-idea·音视频
FungLeo5 小时前
成为全栈·Vue 管理后台篇·可折叠侧栏与移动抽屉:后台导航的响应式实现
前端·javascript·vue.js·侧边栏·响应式布局·无障碍·移动端导航
FansAI_art6 小时前
多角色 AIGC 短片的双模型分工:静态生图与图生视频怎么接
aigc·音视频
思特奇时空智能8 小时前
大规模点要素地图渲染性能优化实践
vue.js·arcgis·性能优化·node.js·html·gis·webgl
FungLeo8 小时前
成为全栈·Vue 管理后台篇·Biome、类型检查、构建和API 代理如何组成质量门禁
前端·javascript·vue.js·typescript·vite·前端工程化·biome
徐小夕9 小时前
开源!我们用知识图谱重构了电子档案,AI 驱动全文智能关联
前端·vue.js·github
FRing031 天前
vue2干货总结11(短信验证、登录功能、统一处理错误(响应拦截器)、将token信息存入vuex、vuex持久化处理)
开发语言·前端·javascript·vue.js·vue2
Java小卷1 天前
面向 Schema 编程,Vue 3 页面级渲染引擎!强大的第三方 UI 适配与扩展(一)
vue.js·低代码