Janus 网关无法从 RTSP 流中获取视频流,而 gstreamer 和 VLC 可以轻松地进行流式传输

Janus gateway fails to fetch video stream from RTSP stream while gstreamer and VLC streams it easily

如标题所示,使用 gStreamer 或 VLC,我可以使用以下命令毫无问题地显示视频

gst-launch-1.0 rtspsrc protocols=tcp location="rtsp://{USER}:{PASSWD}@{URL}:63554/axis-media/media.amp?videocodec=h264" short-header=TRUE ! rtph264depay ! decodebin ! fpsdisplaysink

我可以将其设置为 VLC 中的网络流,如下所示,结果类似

rtsp://{USER}:{PASSWD}@{URL}:63554/axis-media/media.amp?stream=0&videocodec=h264

但是 janus (latest/stable: v0.11.3) 配置如下无法在网页上显示流

        type = "rtsp"
        id = 99
        description = "RTSP Test"
        audio = false
        video = true
        url = "rtsp://{USER}:{PASSWD}@{URL}:63554/axis-media/media.amp?stream=0&videocodec=h264"
        videortpmap = "H264/90000"
        videofmtp = "profile-level-id=42e01f;packetization-mode=1"
        videoopt=96 
        secret = "adminpwd"

错误(repeatig)如下图

2021-09-18T10:20:56Z janus-gateway.janus-gateway[30166]: [rtsp-test] Reconnected to the RTSP server, streaming again
2021-09-18T10:20:56Z janus-gateway.janus-gateway[30166]: [rtsp-test] 30s passed, sending OPTIONS

还有

2021-09-18T10:21:02Z janus-gateway.janus-gateway[30166]: * Connection #0 to host {IP} left intact
2021-09-18T10:21:02Z janus-gateway.janus-gateway[30166]: SETUP answer:RTSP/1.0 200 OK
2021-09-18T10:21:02Z janus-gateway.janus-gateway[30166]: CSeq: 2
2021-09-18T10:21:02Z janus-gateway.janus-gateway[30166]: Transport: RTP/AVP;unicast;client_port=10092-10093;server_port=50000-50001;ssrc=E60B5F25;mode="PLAY"
2021-09-18T10:21:02Z janus-gateway.janus-gateway[30166]: Server: GStreamer RTSP server
2021-09-18T10:21:02Z janus-gateway.janus-gateway[30166]: Session: c7gVPWsPKB48EAYw; timeout=60
2021-09-18T10:21:02Z janus-gateway.janus-gateway[30166]: Date: Sat, 18 Sep 2021 10:11:57 GMT
2021-09-18T10:21:02Z janus-gateway.janus-gateway[30166]: 
2021-09-18T10:21:02Z janus-gateway.janus-gateway[30166]:   -- RTP port (video): 50000
2021-09-18T10:21:02Z janus-gateway.janus-gateway[30166]:   -- RTCP port (video): 50001
2021-09-18T10:21:02Z janus-gateway.janus-gateway[30166]:   -- SSRC (video): 3859504933
2021-09-18T10:21:02Z janus-gateway.janus-gateway[30166]:   -- RTSP session timeout (video): 30000 ms
2021-09-18T10:21:02Z janus-gateway.janus-gateway[30166]: [WARN] No host address for the RTSP video stream, no latching will be performed
2021-09-18T10:21:02Z janus-gateway.janus-gateway[30166]: RTSP video latching: 0.0.0.0:50000
2021-09-18T10:21:02Z janus-gateway.janus-gateway[30166]:   -- RTCP: 0.0.0.0:50001
2021-09-18T10:21:02Z janus-gateway.janus-gateway[30166]: Sending PLAY request...
2021-09-18T10:21:02Z janus-gateway.janus-gateway[30166]: * Found bundle for host {IP}: 0x7f143c01cee0 [can pipeline]
2021-09-18T10:21:02Z janus-gateway.janus-gateway[30166]: * Re-using existing connection! (#0) with host {IP}
2021-09-18T10:21:02Z janus-gateway.janus-gateway[30166]: * Connected to {IP} ({IP}) port 63554 (#0)
2021-09-18T10:21:02Z janus-gateway.janus-gateway[30166]: > PLAY rtsp://{USER}:{PASSWD}@{URL}:63554/axis-media/media.amp?stream=0&videocodec=h264 RTSP/1.0
2021-09-18T10:21:02Z janus-gateway.janus-gateway[30166]: CSeq: 3
2021-09-18T10:21:02Z janus-gateway.janus-gateway[30166]: Session: c7gVPWsPKB48EAYw
2021-09-18T10:21:02Z janus-gateway.janus-gateway[30166]: Range: npt=0.000-
2021-09-18T10:21:02Z janus-gateway.janus-gateway[30166]: 
2021-09-18T10:21:02Z janus-gateway.janus-gateway[30166]: < RTSP/1.0 200 OK
2021-09-18T10:21:02Z janus-gateway.janus-gateway[30166]: < CSeq: 3

现在我必须使用 gstreamer 来捕获 rtsp 流并将其作为 rtp 发送到 janus

gst-launch-1.0 rtspsrc protocols=tcp location="rtsp://{USER}:{PASSWD}@{URL}:63554/axis-media/media.amp?videocodec=h264" short-header=TRUE ! rtph264depay ! decodebin ! videoscale ! videoconvert ! x264enc tune=zerolatency bitrate=1500 speed-preset=superfast ! rtph264pay ! udpsink host=127.0.0.1 port=8004

但这可能会保持 24/7 流,这可能会有问题...

Janus Gateway/Server 只是不支持 interleaved mode。目前在 Janus Streaming 插件(基于 Curl)中实现了 RTSP 支持,几乎不可能在其中添加此类支持。