1.使用Janus的streaming插件播放 注意此种方式目前仅支持Transport: RTP/AVP/UDP哦 有些摄像头是tcp
/opt/janus1/etc/janus/janus.plugin.streaming.jcfg 配置
rtsp-test: {
type = "rtsp"
id = 99
description = "RTSP Test"
audio = false
video = true
url = "rtsp://xxxx"
#rtsp_user = "username"
#rtsp_pwd = "password"
# secret = "adminpwd"
}
使用网页demo播放即可
2.https://github.com/deepch/RTSPtoWebRTC 此方式支持tcp go实现 编译
export GOPROXY=https://mirrors.aliyun.com/goproxy/
go get github.com/deepch/RTSPtoWebRTC
cd src/github.com/deepch/RTSPtoWebRTC
go run .
访问 http://127.0.0.1:8083 work chrome, safari, firefo
注意以上注册配置的stun 能正确访问
(以下来自百度
第一次运行提示 Session Description must not be empty
排查代码应该是stun服务器连不上 删掉/web/static/js/app.js第二行的stun:stun.l.google.com:19302
http.go里也有一个,删之。
再运行发现一直加载出不来画面,这个问题困扰了好几天,排查代码是RTSP协议发送完PLAY命令了始终收不到数据
调试到/github.com/deepch/vdk/format/rtsp/client.go 的readPacket()中 卡在了poll()函数上
最后终于发现换个rtsp服务器就好了,之前用VLC编的RTSP流无法播放,但用VLC播放没问题。
更新下 已经调通了监控摄像头,要求设置为H264 HIGH Profile 不然报SPS PPS错误
另外SDP解析也有问题 无法识别m=application
浏览器版本也有要求 chrome 72以上 跟webrtc的plan-b和unified-plan有关