Frequent audio buffering: how to prevent, or reset audio buffer?

gfbeach

New Member
During almost every streaming session, at least one of my audio sources go out sync with the video. I check my log (https://obsproject.com/logs/TDOJpKFEnXGg4iv3) and I see messages like "adding [x] milliseconds of audio buffering, total audio buffering is now [x] milliseconds." I'm using Application Audio Capture (BETA) to capture Discord and game audio, but sometimes it even happens with my microphone, ("_K66 Microphone" in the logs), which I use as a scene-level Audio Input Capture. (The microphone lag is consistently only 40-60ms which I can live with.) While this seems to happen more often with Application Audio Capture (BETA), it still even happens sometimes when I don't use discrete capture sources and route applications through Desktop Audio. I reboot my machine fresh before each stream, enable Game Mode in Windows and my antivirus (ESET), load OBS as administrator, and generally try to have any games or programs relevant to the stream already open prior to starting my stream or recording. In earlier tests I would sometimes get a Max Audio Buffering error, which I've read can be indicative of high CPU activity, but at no point during stream or test recordings has my CPU been anywhere near 100% utilization. I've got the games' frame rates and other settings configured to keep my GPU usage at-or-below 80%, even while recording/streaming.

In a perfect world I could pinpoint and prevent these kinds of buffering hiccups entirely, but barring that, is there a way to "reset" an audio source while it may cut out for a split-second it'll sync back up and remove the buffering delay?

(PS: I know the overlays are tossing up all sorts of error codes in the logs; that's a separate issue that I'll work on.)
 

AaronD

Active Member
Is this in the Monitor (headphones, local speakers)? It does that, because the person who wrote it treated it like a generic network stream instead of the local real-time thing that it is. So any hiccup simply expands the buffer, indefinitely. If your sound card uses its own clock instead of the PC's clock, then the same nominal sample rate is still slightly different, and that's enough to do it.

The best solution IMO, is to not use OBS's Monitor at all. Use an external mixer, virtual or physical, to do all of the audio work, drive the headphones, and feed a completely finished soundtrack to OBS to pass through unchanged. But if you have to use OBS's Monitor, you can:
  1. Send it to a different device, that uses the PC's clock. This will never (rarely anyway) hiccup, and so the buffer stays small. Physical devices are effectively random as to which clock they use, but a virtual one is practically guaranteed to work.
    • If you have some videos to play in OBS, you could use the Monitor to send that audio to the external mixer, following these rules, mix it with everything else there, and return the finished soundtrack to OBS. In this case, that's all the Monitor does; the headphones still come from the external mixer.
  2. Disrupt the flow of audio to the Monitor. When the audio restarts, it gets a new (small) buffer. Only the Monitor needs this; the stream and recording are okay. You could:
    1. Change the Monitoring setting (Advanced Audio Properties) to Monitor Off and change it back.
    2. Change the Monitoring device (Settings -> Audio) and change it back.
    3. Blink the mute button for each problem source, briefly enough that no one on stream will notice.
    4. Have two copies of every source that you monitor. None of the stream copies go to the Monitor, and none of the monitor copies go to the stream. Then blink the Monitor copies.
 

gfbeach

New Member
Thank you for your feedback! Unfortunately, my concern isn't related to the Monitor function. If I record or stream, often times one of my audio sources (not always but often an Application Audio Capture (BETA) source) will start buffering and lag behind the video by anywhere from 1/4 to a full second on the rendered/streamed video. It can happen with any audio source (including "global" sources like Desktop Audio or Mic In), it doesn't happen each and every time, and the amount of milliseconds of buffering isn't always the same.
 

Edwo

New Member
Hello i have the same problem
I can have 1 audio source end up being multiple second before the video.
I had the same issue on my older computer which is really frustrating. Not even changing my entire hardware fixed the issue LMAO


i think this is important to mention. YES, when a source starts having a problem, that source is multiple seconds AHEAD of everything else.
When i noticed this, i was messing around in obs with the source, disabled and enable ONLY that source and the issue was sometimes resolved. I will try to replicate this if its hard to believe, but im very confident this has happened.


im using Application Audio Capture too, Radeon RX 580, AMD Ryzen 5 3600,
i have tried changing my sound format to 48000, obs in admin and cant remember the rest
next ill try to reduce the audio bitrate from 192 to 128
on my old hardware i wasnt using Application Audio Capture and still had the problem even after ticking "use device timestamps"
but Application Audio Capture doesn thave use device timestamps as far as i could see

google isnt spitting anything out about this, i have been searching for a long time, i cant find much

a pretty simple good first solution would be, to have a addon, that properly resets all audio sources every ~30 minutes, cant find something like this either tho
 

GeorgeT

New Member
I would recommend getting a mixer. A hardware mixer than using software for sound. If you are planning to stream/record and in the future use 2 Computers. 1 for gaming and 1 for capture then mixer is your choice. If you are using a "bad" microphone a mixer would help you filter it. I can type the pros/cons all day. The cons of a mixer is basically the extra space on your desk. Other than that its a great tool that you can use without tabbing out or clicking or basically anything. Its physical and its there! But a mixer can be expensive. So the cheap solution would be to either use the elgato sound capture(even if you dont have elgato capture card) OR use 1 source of audio, all in one, try reinstalling your audio drivers too, check if the frequency of your audio from your sound device is the same as OBS. 44k or 48k. And do a clean install of your Graphics driver and Tick off the HD audio driver nvidia offers(If you are using NVIDIA). I recommend Private Streams and adding audio sources 1 by 1 until you get the issue. Then my friend you can know exactly what causes it! I hope this helps!
Edit: Audio goes out of sync mostly on encoder overloads. Lower your bitrate! Sometimes it takes 1 millisecond to happen during a loading screen through the game and you won't notice!
 

Edwo

New Member
wish there was a simple software solution to sync your audio in obs.
they coded it so the buffer keeps adding up on only part of the stream output, obviously almost all of us want to have our audio and video sources synced so im thinking someone might have already coded something to prevent this, but i cant find it

and im sorry, i really dont want to buy a mixer, not just for the moneys sake, but also I dont want to invest my time into something that only syncs my audio to video, it will also take up more space in my room, the mixer can have issues on its own and i have to learn how the mixer works, thats quite the investment if i only need my audio to not go out of sync

i have tried change my sound format already to the same as windows, no change.
as i said i will reduce audio bitrate and see what happens this time
 

Edwo

New Member

Edwo

New Member
sry for triple post, i just found the forum post by accident, wasnt visible on github, but its much better to visit the forum post
i cant edit my post anymore? <.<
 

gfbeach

New Member
I'll give those a try @Edwo ! I'm glad you had better luck than I did finding a more direct solution.

@GeorgeT I know going with a hardware solution for audio mixing and having separate machines for gameplay and rendering is the proper way to do things, but that's a bit rich for my blood when I'm just getting started. ^^; Lowering the audio bitrate has helped a bit so we'll see if it's more stable over time.

Does anyone know if hiding/reloading an audio source (i.e. making it disappear then reappear into the audio mixer panel) would be one way to force a resync? It's less than ideal to do that mid-stream, but it'd be a decent solution for my purposes for now.
 

Edwo

New Member
i tried the software, seems to not help, will try different settings today

it seems to resync, when you tick and untick one of the tracks in advanced audio properties
im using the first track for the actual stream and disable second track to not have copyrighted music on stream, maybe thats a problem?
do you use that feature?
 

Edwo

New Member
(IMPORTANT QUICK EDIT: i ran a short recording and the chrome right away is ~0.2 seconds behind the video, i believe the async filter might actually be working now, and it changed from a desync building up over time, to a set delay of ~0.2 second, i cant fully tell atm, but i got some hopes up)

day before yesterday: I streamed again, but no luck
and for some reason i wasnt able to reset the desync this time.
i tried to mute unmute, toggled the tracks, nothing helped this time.
if I switch to chrome on a different audio source there was no delay anymore, but switching back to the original source, it was still there.
Even my desktop audio had no delay, which had chrome included.

Yesterdays changes:
44.1k everywhere
6k bitrate + 7k buffer (from simply 7k bitrate)
audio reduced bitrate 190 -> 128
check box in async filter addon "use obs time"

It didnt work, but woud i do i have is a showcase of the problem on stream
I realize now that I should have muted everything except the audio sync video from chrome to make it easier. I can do that next time, but here is a very long stream with a constant showcase in the bottom right of the video and audio desync, and how it changes over time.

(If game is loud or im talking just skip to a different point, where you can hear the sound, ill fix that next time)

so the desync changes all the time over the course of the stream
i heard the sound of the ball bounce:
-right after the peak of the jump
-right before the bounce

1. the sound is ALWAYS before the bounce
2. it ranges from ~0.35 seconds (300 milliseconds) before the bounce to something like 0.1 seconds before (100 milliseconds)

I have ran multiple cpu and a gpu stresstests while recording the sync and there was no change.
addtionally i have monitored the cpu "processor time" through out the whole stream I linked above

Capture.PNG


stream start is 2:31pm
end is 10:38
LOG: https://obsproject.com/logs/lKQJtFUXa2H42HRD
log might be hard to read because of the "obs-async-audio-filter" keeps removing and adding frames, but it hasnt helped


ill just offset the chrome audio for 0.2seconds for now and see how it works out, because im out of ideas
i can run the stream like this again if anyone needs me to test something out, ill mute everything that time except the sound of chrome for the balls bouncing sound.
and ill remove the filters

i feel like im losing my marbles at this point, im looking over the whole stream, and maybe the sound is consistently bouncing 0.2 seconds after the sound, maybe i just need to offset it and its fixed.
Im actually questioning my own sanity now LUL but i know for a fact that at some points i was able to reset the delay somehow and there was no delay so idk what is going on
lets see what happens today

(IMPORTANT QUICK EDIT: i ran a short recording and the chrome right away is ~0.2 seconds behind the video, i believe the async filter might actually be working now, and it changed from a desync building up over time, to a set delay of ~0.2 second, i cant fully tell atm, but i got some hopes up)
 

gfbeach

New Member
Thanks for looking into this more. I did a stream this past weekend and it pretty much went without a hitch; my background music source lagged at the very end of the stream, but I'm frankly OK with that since it's a tertiary element. I'm still using Audio Application Capture (BETA) for game audio. I'm getting in the habit of loading up all games/other demanding applications before going live, and that seems to help. There might still be a bit of delay here and there but it's less than it was and it hasn't maxed over the last few streams.

At the risk of stating the obvious, if your sound is consistently ahead of the video, and it's always by a similar amount (give or take a few dozen milliseconds), then maybe adding a Sync offset in Advanced Audio Properties will help?

It boggles my mind that audio buffering (especially when max'd) is the result of the CPU being overworked and yet neither you nor I log the CPU being under especially heavy load. Maybe it's a matter of the individual CPU core being used by OBS, versus the CPU as a whole. No idea what to do about that, though.
 

GeorgeT

New Member
I had this problem once that's why I will insist. First run OBS as administrator. Then Try to eliminate any possibilities that your encoder will be overloaded. Again sometimes your encoder might be overloaded while loading into a map? That can happen in a millisecond and you won't even notice. Even Obs won't notice. This happened to me in Tarkov when I loaded into a raid. I simply lowered the bitrate for less workload and I started running obs as administrator. Good luck to you both.
 

Edwo

New Member
even if your cpu is max load, it shouldnt create desynchronization, that is really not practicle, cpu will have max load sometimes
 

Edwo

New Member
I had this problem once that's why I will insist. First run OBS as administrator. Then Try to eliminate any possibilities that your encoder will be overloaded. Again sometimes your encoder might be overloaded while loading into a map? That can happen in a millisecond and you won't even notice. Even Obs won't notice. This happened to me in Tarkov when I loaded into a raid. I simply lowered the bitrate for less workload and I started running obs as administrator. Good luck to you both.
how many cpu stresstest should I do in a row while streaming to disprove this point? i have ran 2 in a row just now, and before i did 3 in a row with no immediate change in the sync

also update, the desync is increasing afterall, idk maybe i got lucky on that 1 stream or something
 

gfbeach

New Member
For the past couple of streams I haven't had any significant buffering on anything other than a background audio track, which I can live with. Games (via Application Audio Capture [BETA]) as well as the microphone have been working just fine. It seems like loading OBS itself (in Administrator mode) as the last part of my tech stack, after all other support programs and games are up, is helping a lot.
 

gfbeach

New Member
Another multi-hour stream, no buffering. I'm consistently getting good results and the missing link seems to be what I mentioned in my last post: loading EVERYTHING ELSE (games, overlays, Discord, etc) first, with OBS in admin mode being the very last thing.
 

AaronD

Active Member
Yes, order does often matter. Basic resources first, then the things that use them, then the things that use that, etc.

Teardown in the opposite order, so that it doesn't save a note for next time that "X" no longer works. Or auto-switch to something else that it finds, and then the next startup is still on that something else...

If you have a decent amount going on, you might even script it, instead of trusting yourself to do it manually every time. Don't start anything directly; just hit the script and watch it work.
 

Edwo

New Member
i have noticed that fully closing google chrome, then opening all my tabs again actually removes the delay, but then it restarts.
Im kinda tired of dealing with this issue, but i want to say that having to start all the programs in a specific order shouldnt be the solution to this.
this seems like a software issue and i always had issues now with audio in obs when it comes to desync. unlucky i guess

btw: the logs say "adding 2021 milliseconds of audio buffering"
but the delay has never been more then 0.3 seconds at most, are those logs even accurate?
is max audio buffering even a red flag? it sure looks scary, but I havent seen solutions besides restart obs. it sounds more like thats not the real issue and a lot of people have it without actually having any trouble with that
 
Top