djwhatley
New Member
I've written a Lua script to simulate an old-school terminal display and output text one character at a time, while also playing a sound effect for each character. To play the sound, it grabs a media source loaded up with the effect (~50ms in duration, 9KB as .wav) and restarts the source:
The characters are printed out with a small delay between each one. I started at 50ms, and while it played fine through the audio monitor, the sound in the encoded output was very laggy. I bumped it up to 75ms, but the difference is small, and the problem remains. On checking the logs, I can see the issue:
So it's pretty clearly overloading the audio buffer, though I haven't been able to figure out why. The .wav is at the same sample rate I'm using in OBS (48kHz), and again the audio itself is only about 50ms long. It feels to me like it has to be related to rapidly restarting the audio source, but I've tried a lot of different things at this point, and can't seem to sort it out.
I'm considering just rewriting the entire thing in a web page and capturing the audio from that.. but before I do that, does anyone know of a way to solve this within OBS?
Lua:
function play_sfx1()
local media_source_sfx1 = obs.obs_get_source_by_name(sfx1_source_name)
if media_source_sfx1 then
obs.obs_source_media_restart(media_source_sfx1)
obs.obs_source_release(media_source_sfx1)
end
end
The characters are printed out with a small delay between each one. I started at 50ms, and while it played fine through the audio monitor, the sound in the encoded output was very laggy. I bumped it up to 75ms, but the difference is small, and the problem remains. On checking the logs, I can see the issue:
Code:
15:27:02.977: Max audio buffering reached!
15:27:02.977: adding 960 milliseconds of audio buffering, total audio buffering is now 960 milliseconds (source: Startup SFX 1)
15:27:02.977:
15:27:02.998: Source Startup SFX 1 audio is lagging (over by 13160.93 ms) at max audio buffering. Restarting source audio.
So it's pretty clearly overloading the audio buffer, though I haven't been able to figure out why. The .wav is at the same sample rate I'm using in OBS (48kHz), and again the audio itself is only about 50ms long. It feels to me like it has to be related to rapidly restarting the audio source, but I've tried a lot of different things at this point, and can't seem to sort it out.
I'm considering just rewriting the entire thing in a web page and capturing the audio from that.. but before I do that, does anyone know of a way to solve this within OBS?