网络摄像机 +VLC+Nod e.js+HTML5
网络摄像机大部分都需要安装插件才能看, 对于我们这些搞 B/S 的来说比较麻烦, 最近项 目中要用到摄像机实时监控, 所以查询了些资料。 公司采用的大华的东西, 将设备全部接入 一个局域网中,设置好 ip
摄像机 1 (192.168.8.110)
摄像机 2 (192.168.8.180)
硬盘录像机 NVR (192.168.8.108)
百度了一下大华(包含 NVR/摄像机)RTSP地址:
rtsp://user:pwd@ip:port/cam/ realmonitor?channel=1&subtype=0
channel通道,NVR分通道。
subtype 码流, 0 代表主码流(高清 1080P), 1 代表辅码流 (704*576(D1)).
直接访问摄像机:
/cam/realmonitor?channel=1&subtype=0
/cam/realmonitor?channel=1&subtype=0
/cam/realmonitor?channel=1&subtype=0
/cam/realmonitor?channel=2&subtype=0
摄像机 1:rtsp://admin:admin@192.168.8.110:554
摄像机 2:rtsp://admin:admin@192.168.8.110:554
访问 NVR:
摄像机 1:rtsp://admin:admin@192.168.8.108:554
摄像机 2:rtsp://admin:admin@192.168.8.108:554
Html5 <video>并不支持rtsp,所以使用vlc进行转码 將rtsphttp这样<video>就可以直接 播放。
使用 vlc 命令,在 cmd 命令下使用(注意下面是一行命令)
vlc -I dummy -vvv
"rtsp://admin:admin@192.168.8.110:554 /cam/realmonitor?channel=1&subtype=1"
--sout="#transcode{vcodec=theo,vb=800,acodec=vorb,ab=128,channels=2,samplerate=44100}:ht tp{mux=ogg,dst=:8080/cam}" --sout-all --sout-keep
多行 0%-100%,基本上就是成功了
vk 4dummy -w\r "rBp://adrriin:ddmin@192d6S8J1C;554/cam/realnio..t - 匕■
[S2 Oaf Im?[: J care Input debug
Buffering 62Z
A
[020a£J)i9c ] care input debug
Buffering 62a
[020af1 core inmit dehug
Riiffering
[BQ    b9&    xnpn.it: debu^
Buff citing GS>£
[G20afb9c] core Imuut debug
Bufftirlny 68<
LldMBaf bVE J care input debug
UuliBring b8X
[020afJ)i9c] care input debug
Buffering 73>c
html5标签区分大小写
[|Q2 BajFb9c ] cai*e input debug
Buffering 73k
[B2 BclTb9i^ ] cure -Luput debug
Duff e ring- 73k
LKGiHaf JtuVc J care Input debug
Buffering 8瞅
[020a£hi9c] care input debug
Buffering 8
f G2BaFb9c ] hcihe input debug
BufFevlng iRz
[BQ BaJb?Q ] sar-c xnp4.1t: debu^
DufTc ring 8S>£
[£l2 0af In?c ] care Input debug
Buffering 8B^
[Q28afb9c1 core input debug
Buffering 8Bz
02旦刊Fh9匸]core input debug
Bufferina 怕乂
[Q2OaJFb?c ] come input debug
DuffDvlng 93m
[62Bctfb9c ] core liiiputr debug
Buffering 93k
Lld2Ua£J]ii9[: J care input debug
Stream Ibuffering done ClUltl ms ±n lUld ms>
[020a£b?c 1 care inwt debug
Decodet* uait done tn 6 ms
[621 &ai*e ihilm wa.inning
late fcudf£er for mux input
[B2 BcSaBc ] icaifc mux war-nJLng
late hu-Ffer fci- nnux input <173667^
LM2Hy571c ] stFeaji_ou.t_transcodB stream out warningr: Reseting video ye
W
HTML5
height="450" autoplay="autoplay"
<video src="127.0.0.1:8800/cam"    width="600"
con trols="c on trols" loop="loop">
Your browser does not support the video tag.
</video>
chrome打开页面就可以看到了
<-■ C 127.0.0J/agro/cam/
Node.js+HTML5
采用Node.js启动vic,这里是多个摄像头
app.js
var child_process = require('child_process');
function ope nCam(rtsp,path){
var server=child_process.spaw n("C:\\Program Files
(x86)\\VideoLAN\\VLC\\",["-l","dummy","-vvv",rtsp,"--sout=#tra nscode{vcodec=theo,vb=8 00,acodec=vorb,ab=128,cha nn els=2,samplerate=44100}:http{mux=ogg,dst="+path+"}","--sout-all ",”--sout-keep"]);
//dummy 可以修改为 --no-dummy-quiet,隐藏vlc命令窗口
server.o n('exit', function (code, sig nal) {
con sole .lo g('service exit');
});
}
openCam('rtsp://admin:admin@192.168.8.108:554 /cam/realmonitor?channel=1 &subtype=1',':8 800/cam');// 摄像机 110
openCam('rtsp://admin:admin@192.168.8.108:554 /cam/realmonitor?channel=2&subtype=1',':8 801/cam');// 摄像机 180
目前只能一个摄像机一个端口,端口复用暂时不知道怎么弄。
HTML
<video src="192.168.8.87:8800/cam"    width="600" height="450" autoplay="autoplay"
con trols="c on trols" loop="loop">
Your browser does not support the video tag.
</video>
<video src="192.168.8.87:8801 /cam" width="600" height="450" autoplay="autoplay" con trols="c on trols" loop="loop">
Your browser does not support the video tag.
</video>
运行 node app,打开 html即可
倉       
• cr
9 27 A£L l/dgro/cafri/
经过测试PC chrome、安卓UC都能打开。