环境准备
1.带有Docker的服务器一台
2.海康或大华摄像头
3.服务器与摄像头在同一局域网下
摄像头配置
视频编码需要H.264的格式,webrtc不支持H.265
webrtc-streamer安装
创建配置文件config.json
hikcam(海康)、ajhuacam(大华),rstp地址如下所示
{
"urls": {
"hikcam": {
"video": "rtsp://${user}:${password}@${ip}:554/h264/ch1/main/av_stream"
},
"ajhuacam": {
"video": "rtsp://${user}:${password}@${ip}:554/cam/realmonitor?channel=1&subtype=0"
}
}
}
用户名(user),密码(password)、摄像头局域网IP地址(ip)需要替换成自己的
docker run -p 8000:8000 -d --net=host -v $PWD/config.json:/app/config.json mpromonet/webrtc-streamer
前端环境准备
克隆项目webrtc-streamer-html或者webrtc-streamer-vuejs
<html>标签:webRtcServer,海康,streamer,大华,webrtc,摄像头 From: https://www.cnblogs.com/zhanghengbolg/p/16639083.html
<head>
<script src="libs/adapter.min.js" ></script>
<script src="webrtcstreamer.js" ></script>
<script>
var webRtcServer = null;
window.onload = function() {
webRtcServer = new WebRtcStreamer("video",location.protocol+"//"+window.location.hostname+":8000");
webRtcServer.connect("rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov");
}
window.onbeforeunload = function() { webRtcServer.disconnect(); }
</script>
</head>
<body>
<video id="video" />
</body>
</html>