Streaming RTMP to JANUS-Gateway only showing bitrate but no video

Viewed 1539

I'm currently using the streaming plugin as follows Fancy artchitecture here

OBS--------RTMP--------->NGINX-Server------FFMPEG(input RTMP output RTP)--------->JANUS---------webrtc-------->Client

When using the ffmpeg command (bellow), on the Janus streaming interface, we only see the bitrate that corresponds to that of the ffmpeg output in the console but we don't see any video.

ffmpeg -i rtmp://localhost/live/test -an -c:v copy -flags global_header -bsf dump_extra -f rtp rtp://localhost:8004 

(using "-c:v copy" so that no encoding is used and hence reducing the latency)

The video shows fine if I use "-c:v libx264", the only issue is that it is CPU intensive and adds latency.

Previously I had tried using RTSP as input for FFMPEG and in this case the video show fine with almost no latency even though I use "-c:v copy".

So I don't realy get why for RTSP the copy works fine, but for RTMP I have to use the libx264 codec. If anyone has an idea about this I am all ears :)

1 Answers

I had similar issue and my problem was that the stream / video that I used has large GOP size. For WebRTC, latency is sub-second, so the input source should have short interval I frames. Better to remove B frames since they referring backward and forward as well.

Here are commands that you could use for small GOP size (4) and remove B frames.

Using RTMP streaming src:

ffmpeg rtmp://<your_src> -c:v libx264 -g 4 -bf 0 -f rtp -an rtp://<your_dst>

Using a mp4 file:

ffmpeg -re -i test.mp4 -c:v libx264 -g 4 -bf 0 -f rtp -an rtp://<your_dst>

-c:v copy does not reduce latency. It merely tells ffmpeg not to transcode.

Related