admin管理员组

文章数量:829156

HTML5实时显示摄像头视频

1、页面HTML代码:

<canvas id="video-canvas" style="width: 100%; height: 387px;"></canvas>
<script type="text/javascript" src="<%=basePath%>resources/js/jsmpeg-master/jsmpeg.min.js"></script>
<script type="text/javascript">var canvas = document.getElementById('video-canvas');								var url = 'ws://' + document.location.hostname + ':' + port + '/';	port = port + 2;var player = new JSMpeg.Player(url, {	canvas : canvas});
</script>
 


2、需要Node做服务端,下载jsmpeg-master



npm install cnpm -g --registry=

cnpm install ws -g

添加 NODE_PATH 和path 环境变量,路径是modules模块儿的所在路径,注意用户模块和全局安装模块儿的路径不同,根据需要选择,不设置服务器报错找不到模块module 

node D:\lang\nodejs\node_modules\jsmpeg-master\websocket-relay.js 123456 8981 8982

 
ffmpeg -i rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov -f mpegts -codec:v mpeg1video -bf 0 -codec:a mp2    -r 120    -q 2  http://localhost:8981/123456/640/480/

ffmpeg -i rtsp://218.204.223.237:554/live/1/66251FC11353191F/e7ooqwcfbqjoo80j.sdp -f mpegts -codec:v mpeg1video -bf 0 -codec:a mp2    -r 120    -q 2   http://localhost:8981/123456/640/480/

海康:
rtsp://[username]:[password]@[ip]:[port]/[codec]/[channel]/[subtype]/av_stream

rtsp://admin:12345@192.0.0.64:554/h264/ch1/main/av_stream

大华:
rtsp://username:password@ip:port/cam/realmonitor?channel=1&subtype=0


本文标签: HTML5实时显示摄像头视频