简体   繁体   中英

Changing lag and jitter of rtmp stream using OBS and nginx

I have a MEVO camera that I'm using to stream video to OBS via my debian nginx rtmp server. I also have a USB webcam connected directly to my PC running OBS, and I'm streaming video from my smartphone to OBS via the same nginx rtmp server and an app called Larix Broadcaster. CPU usage of the OBS PC: 15%; nginx rtmp server: 2%.

MEVO               > nginx-rtmp > OBS
USB webcam                      > OBS
Smartphone (Larix) > nginx-rtmp > OBS

This works but the streams are not in sync with each other. There is a latency of about 2-5 seconds between the MEVO and OBS (and there is also a different latency between Larix and OBS.) The webcam is instant. I don't mind the 2 second latency - I can set a manual async delay in OBS on the webcam to sync it up with the MEVO. The problem is that the latency is not consistent. Every time I start streaming the MEVO it changes!

Then, when I finally manage to sync the streams (lucky shot), also while streaming they go in and out of sync (jitter). Only in the 100-200ms range, but enough to be visible.

Looking at the MEVO, I believe it only supports RTMP. So moving to another protocol won't work for me.

What could be the cause of the jitter and the changing latency? Could it be the network? The MEVO and OBS are both on a fast 1Gbps wired network.

I tried setting the Network Buffering in OBS to 1MB, 2MB or whatever, but it doesn't help. I also tried changing the buflen in nginx.conf, but to no avail.

nginx.conf:

worker_processes  1;

events {
    worker_connections  1024;
}

rtmp {
    server {
        listen 1935;
        chunk_size 4096;
        buflen 1000ms;
        application live {
            live on;
            record off;
            max_connections 20;
        }
    }
}
  • I'm streaming the MEVO to rtmp://10.0.0.1/live/mevo (mevo is the stream key )
  • I'm streaming Larix to rtmp://10.0.0.1/live/larix (larix is the stream key )

Please help me fix the jitter and changing latency in OBS. Thanks.


Update as I'm trying to fix the changing startup lag:

  • I tried setting chunk_size to 2048, but this doens't help.
  • When I add: wait_key on; I never get the stream to show in OBS.

Any ideas?

I'm from Softvelum team which is behind Larix Broadcaster.

I'd recommend to change "Keyframe frequency" to 1 second and set "Max buffer items" to 70. You can read Q13 from this page https://softvelum.com/larix/faq/ to lean more about this setting. As for "catching" the sync-up - this happens if you start streaming close to key frame start. If you have 300 items in buffer - this is about 3 seconds, so you can get in the middle and get 1.5-2 seconds behind the real-time.

Try to play with buffer and keyframe to see how it works.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM