4

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 :)

  • Did you use the same codec for RTSP and RTMP? i.e. does OBS output H.264 to RTMP? By the way, there are profiles in H.264 for low latency and high performance. – TimTIM Wong Aug 21 '20 at 20:00

1 Answers1

2

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.

Fei
  • 1,906
  • 20
  • 36