1. 先下载相应版本的webrtc-streamer
https://github.com/mpromonet/webrtc-streamer/releases
2. 编辑html/index.html文件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div style="width: 100%;height: 100%;">
<video id="video" muted controls />
</div>
<script src="html/libs/adapter.min.js"></script>
<script src="html/webrtcstreamer.js"></script>
<script>
let options = "rtptransport=tcp";
var webRtcServer = null;
window.onload = function () {
webRtcServer = new WebRtcStreamer("video", "http://127.0.0.1:9001");//这里填你自己部署的WebRtcStreamer服务地址
//rtsp://user:password@ip:port/h264/ch1/main/av_stream--海康
//rtsp://user:password@ip:port/cam/realmonitor?channel=1&subtype=0--大华
//webRtcServer.connect("rtsp://admin:password@ip:554/ch1/main/av_stream", null, options); //这里填可以正常预览的rtsp地址,可以先使用vlc或其他软件测试一下地址的有效性
webRtcServer.connect("rtsp://127.0.0.1:8554/video", null, options);
}
window.onbeforeunload = function () { webRtcServer.disconnect(); }
</script>
</body>
</html>
3.修改config.js文件
修改海康的rtsp地址