Question / Help Webcam and RTMP drift out of sync

MajorGlory

New Member
He Guys,

Just wondering how you guys would deal with the following issue:

I use a somewhat strange two pc streaming set up because of my 21:9 monitor. It's native resolution (and therefore my gaming resolution) is 3440x1440. I do not know of any capture cards that will handle that correctly (or will a 4k capture card deal with that?). In order to still use a two pc stream I have the following set up:

Gaming PC has two network cards. One is used for all regular internet/gaming traffic. The other is used to stream with OBS at 20000 kb/s in the full res (3440x1440) to my laptop. This laptop has two networkcards as well. One, strictly for the stream (this one picks up the mentioned stream) a second for internet (and stream) traffic. Using NginX the OBS on my laptop pics up the stream from the first PC (as a mediasource in OBS) and adds the built in laptop webam and an overlay....The audio is coming from my gaming system. All audio from the laptop (=streaming system) is disabled.

At the start of the stream I delay my webcam with roughly 3,5 seconds (1 second because OBS on the gaming pc buffers for one second) and 2,5 extra because that is the delay between two pc's. At the start of the stream, al is well....But after some time (say an hour) I start to notice that de webcam actually needs more and more delay to stay in sync with the audio from the game pc...Restarting both systems helps of course...but the viewers won't like that....

My options are (as far is I understand as streaming n00b):

-> Don't send microphone audio from gaming pc to streaming pc and use dedicated mic from streaming PC.
I don't think this would work because that would mean my voice and my mouth would be in sync on the stream, but would not correspond with the game image after a while.

-> Connect webcam to gaming pc and send everything as a single, synchronous stream to the second pc.
I don't want this because I do intend to use a webcam with background removal in the near future. This would use CPU power on the gaming pc that I want to keep for the game. The streaming PC has enough CPU power to spare, so that should take the webcam at all times....

Very curious about your suggestions OBS community!

Regards,

MG
 

MajorGlory

New Member
Hey John,

No....and yes. I have finally decided to buy an external webcam (logitech c922) and connect that directly to the gaming pc. Next I have set my webcam in OBS to use my headset mic as dedicated audio input source (this ensures sync between webcam and voice audio). I have of course disabled the mic input in OBS. This seems to work. However, the audio from the stream as a whole still drifts out of sync ever so slowly. If I do a scene change in the streaming obs this sync gets reset. So i simply switch scenes once every hour or so. Still, I will most likely upgrade to an i7-7700k next week in order to stream from one pc directly....on the current gaming pc everything is always synced, it's the streaming pc that causes the de-sync. Please keep me informed on you progress with this issue as I am still looking for that perfect fix. I will post my progress (if any) here.
 

john5788

New Member
I think I fixed my problem last night. I made some code changes to the vlc-video plugin which can be found in this pull request here: https://github.com/jp9000/obs-studio/pull/786#issuecomment-277220796

My setup:
I am pushing an RTMP stream from a single instance of OBS to an nginx server, and in a second instance of OBS, reading it back and adding my webcam overlays and etc... This is to achieve a clean game recording with all audio that I can save locally and a separate stream for Twitch with overlays and facecam.

My findings:
In the second instance of OBS, I am using the VLC video plugin to read the RTMP stream and this is where I was seeing the delay drift. The initial delay between real time and RTMP stream was roughly 2000ms so that was what I set the webcam delay to. But every now and then, the RTMP stream would become corrupt, change into a gray screen in the OBS preview window and add about 200ms to the delay. After a while, this repeated and added up to became large. I decided to open VLC and read the stream manually alongside OBS and see if this occurred as well. After discovering it did as well, I found an option in VLC to change the network-caching delay. Playing around with this value allowed the VLC stream to not drift away from real time by itself and then it was just a matter of finding out what the vlc-video plugin was doing.

The plugin today uses a hard coded 100ms delay. I simply added a new user-defined property allowing custom definition of what network-caching can be set to. I set mine to 3500 and was able to play for a couple hours. The webcam video with a 5000ms delay and game video were in sync for the entire time.
 

DanteMustDie

New Member
I know this may seem like a shot in the dark, but I am having the exact same problem as you, John. I have no idea how to fix it despite you posting the solution. Is there any chance you could simplify this information? This is the only step left to actually complete my stream set up, I'd love to change the delay on my RTMP stream to finally get everything synced up and working.
 

john5788

New Member
I know this may seem like a shot in the dark, but I am having the exact same problem as you, John. I have no idea how to fix it despite you posting the solution. Is there any chance you could simplify this information? This is the only step left to actually complete my stream set up, I'd love to change the delay on my RTMP stream to finally get everything synced up and working.

Try updating to obs-studio 19.0.3, it looks like my code was merged in for that release. You should be able to find the NetworkCaching option when you go under the RTMP source properties window. Set that value according to your own experimentation. For me, my sweet spot was 3500ms. Anything higher than 3500ms would also work, but introduces unnecessary delays to the Twitch stream.

Edit: I can't read commit changes. 19.0.3 doesn't contain my code yet, wait for the next release or build the latest source code on your own:

https://github.com/jp9000/obs-studio/wiki/Install-Instructions
 
Last edited:
Top