使用webrtc-streamer检察rtsp及时视频

瑞星  金牌会员 | 2024-9-20 15:14:18 | 显示全部楼层 | 阅读模式
打印 上一主题 下一主题

主题 861|帖子 861|积分 2583

1.下载webrtc-streamer

2.解压运行webrtc-streamer.exe


在欣赏器访问127.0.0.1:8000,点击窗口可以看到本机上各窗口及时状态,点击摄像头可以显示摄像头画面。

5.安装phpstudy,并建立网站。(详细过程本身网上搜)

6.打开网站根目录, 新建webrtc文件夹。将下载包html文件夹下webrtcstreamer.js文件和html/libs文件夹下adapter.min.js文件复制到webrtc文件夹下。

7.新建webrtc.html,并修改webrtc-streamer.exe所在IP(第27行),rtsp地址(第28行)
video组件加上muted才会主动播放,否则必要点击才能播放。
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6.     <meta http-equiv="X-UA-Compatible" content="ie=edge">
  7.     <title>Document</title>
  8. </head>
  9. <style>
  10. #id__stream {
  11.   width: 100%;
  12.   height: 100%;
  13. }
  14. </style>
  15. <body>
  16. <div>
  17.     <video muted autoplay controls id="id__stream"></video>
  18. </div>
  19. <script src="./webrtcstreamer.js"></script>
  20. <script src="./adapter.min.js"></script>
  21. <script>
  22.     // 只获取视频
  23.     let constraints = {audio: false, video: true};
  24.     let startBtn = document.getElementById('start')
  25.     let stopBtn = document.getElementById('stop')
  26.     let videoShowControl = document.getElementById('id__stream')
  27.     const s = new WebRtcStreamer('id__stream', 'http://192.168.43.102:8000');
  28.     s.connect('rtsp://admin:admin@192.168.43.110:554/stream0');
  29.     startBtn.onclick = function () {
  30.     }
  31.     stopBtn.onclick = function () {
  32.         videoShowControl.pause();
  33.     }
  34. </script>
  35. </body>
  36. </html>
复制代码
8.在欣赏器输入网址(http://192.168.43.102/webrtc/webrtc.html),即可看到rtsp视频

这里一共有三个地址:
webrtc-streamer.exe(html中配置):http://192.168.43.102:8000
rtsp地址(html中配置): rtsp://admin:admin@192.168.43.110:554/stream0
欣赏网址(phpstudy中配置):http://192.168.43.102/webrtc/webrtc.html

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

瑞星

金牌会员
这个人很懒什么都没写!
快速回复 返回顶部 返回列表