在做项目时,有时需要在页面中预览摄像机视频,之前是在页面中调用VLC插件,这就需要客户电脑上安装VLC插件,但是现在的一些国产化电脑上面不支持VLC插件的安装(ARM、MIPS架构平台),这就需要寻找一种无插件的播放方式,下面介绍的这个开源工具,就可以解决这个问题,特别适合局域网使用,无需流媒体服务器,很方便。源代码是go写的,很方便实现跨平台。
RTSP流到WebBrowser基于Pion的webtc不使用ffmpeg或gstreamer)。
Note: RTSPtoWeb 是一个改进的服务,它提供了相同的功能,一个改进的API,并且支持更多的协议。建议使用RTSPtoWeb而不是此服务。
如果你需要 RTSPtoWSMP4f 请使用 https://github.com/deepch/RTSPtoWSMP4f
源码下载
$ git clone https://github.com/deepch/RTSPtoWebRTC
进入源码目录
$ cd RTSPtoWebRTC/
测试运行
$ GO111MODULE=on go run *.go
打开浏览器,查看视频
open web browser http://127.0.0.1:8083 work chrome, safari, firefox
format:
{
"server": {
"http_port": ":8083"
},
"streams": {
"demo1": {
"on_demand" : false
"url": "rtsp://170.93.143.139/rtplive/470011e600ef003a004ee33696235daa"
},
"demo2": {
"on_demand" : true
"url": "rtsp://admin:admin123@10.128.18.224/mpeg4"
},
"demo3": {
"on_demand" : false
"url": "rtsp://170.93.143.139/rtplive/470011e600ef003a004ee33696235daa"
}
}
}
使用选项"on_demand": false,否则当多个客户端连接时,你会得到不稳定的流和性能问题。
视频编解码器支持: H264
音频编解码器支持: pcm alaw and pcm mulaw
Deepch - https://github.com/deepch streaming developer
Dmitry - https://github.com/vdalex25 web developer
Now test work on (chrome, safari, firefox) no MAC OS
Examples of working with video on golang