瑞星 发表于 2024-9-20 15:14:18

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

1.下载webrtc-streamer
https://i-blog.csdnimg.cn/direct/02f3649cae344d47a400af50208744d1.png
2.解压运行webrtc-streamer.exe
https://i-blog.csdnimg.cn/direct/e0f18e5352114d5d9c523402d974921c.png
https://i-blog.csdnimg.cn/direct/12a578f4ce534a32bd0e51dd00f81ffd.png
在欣赏器访问127.0.0.1:8000,点击窗口可以看到本机上各窗口及时状态,点击摄像头可以显示摄像头画面。https://i-blog.csdnimg.cn/direct/a8b3a9c708b2481eab7d8c7c8ee4a521.png
5.安装phpstudy,并建立网站。(详细过程本身网上搜)
https://i-blog.csdnimg.cn/direct/4bd66ea1f974483782409c0a08a1a297.png
6.打开网站根目录, 新建webrtc文件夹。将下载包html文件夹下webrtcstreamer.js文件和html/libs文件夹下adapter.min.js文件复制到webrtc文件夹下。
https://i-blog.csdnimg.cn/direct/8fda856033234eed8313c9921c2fba35.png
7.新建webrtc.html,并修改webrtc-streamer.exe所在IP(第27行),rtsp地址(第28行)
video组件加上muted才会主动播放,否则必要点击才能播放。
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<style>
#id__stream {
width: 100%;
height: 100%;
}
</style>
<body>
<div>
    <video muted autoplay controls id="id__stream"></video>
</div>
<script src="./webrtcstreamer.js"></script>
<script src="./adapter.min.js"></script>
<script>
    // 只获取视频
    let constraints = {audio: false, video: true};
    let startBtn = document.getElementById('start')
    let stopBtn = document.getElementById('stop')
    let videoShowControl = document.getElementById('id__stream')
    const s = new WebRtcStreamer('id__stream', 'http://192.168.43.102:8000');
    s.connect('rtsp://admin:admin@192.168.43.110:554/stream0');

    startBtn.onclick = function () {
    }
    stopBtn.onclick = function () {
      videoShowControl.pause();
    }
</script>
</body>
</html> 8.在欣赏器输入网址(http://192.168.43.102/webrtc/webrtc.html),即可看到rtsp视频
https://i-blog.csdnimg.cn/direct/4134f1b7c48e4721822754e30e517154.png
这里一共有三个地址:
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企服之家,中国第一个企服评测及商务社交产业平台。
页: [1]
查看完整版本: 使用webrtc-streamer检察rtsp及时视频