-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Description
Operating System Info
Windows 10
Other OS
No response
OBS Studio Version
27.0.0-rc2
OBS Studio Version (Other)
No response
OBS Studio Log URL
OBS Studio Crash Log URL
No response
Expected Behavior
Audio recording without dropouts.
Current Behavior
When recording or streaming, audio data contains multiple random short audio dropouts.
Distribution of the dropouts seems to be random but happen at a certain rate depending on which computer it is being run on. On my computer it’s approx. every 5 minutes, I have seen it on another computer where it happens roughly twice per hour.
For a 40 min. test recording on my computer, dropouts have occurred at these time stamps:
00:03:19
00:09:40
00:15:38
00:19:51
00:23:41
00:29:55
00:36:07
The length of the dropouts are not necessarily all the same length.
Steps to Reproduce
- Launch OBS.
- Start test tone (I use https://www.szynalski.com/tone-generator/).
- Record desktop audio using OBS (all default settings) and wait.
- After stopping the recording, audio dropouts can be found in the resulting file.
As indicated above, the frequency of this issue seems to depend on hardware and may either not occur at all or very rarely on some systems, I'm not sure what it depends on.
The issue can also be reproduced without using a test tone of course, but a continuous tone makes it easier to check the resulting file for dropouts.
Anything else we should know?
Conditions
I have been testing on Windows 10 20H2 with OBS 26.1.2-276 and 27.0.rc2, 64 bit, without any video source configured (issue also happens with video configured though).
The issue seems to be independent of OBS settings (like audio sample rate or output format). I have not yet found any setting in the OS (like energy settings) that fix or reduce the issue.
The frequency of the issue seems to depend on the hardware. There are systems where I was not able to reproduce the issue, though I did not make excessively long recordings (> 4 h) to eliminate the possibility of the issue occurring on these systems.
The issue is not limited to recording from desktop audio but also applies when recording from external USB audio interfaces.
The issue is not limited to recording but also applies to streaming.
When an audio dropout occurs, the message “can't discard, data still pending” is seen in the debug output (if compiled with DEBUG_AUDIO).
The attached log file includes a debug message (Capture size: 480) I added, it outputs the captureSize variable in ProcessCaptureData() to check for any changes in amount of data being returned there.
Debug attempt
I’m not familiar with the OBS code base and the audio processing happening, but to me it seems like the problem is the fact that in audio_callback(), it always takes a fixed amount of data from the audio buffer (audio_size = AUDIO_OUTPUT_FRAMES * sizeof(float)) even if the buffer is not sufficiently filled due to potential delays in the capture thread.
What I have tried to solve this issue is basically waiting for the buffer to be filled, like this in audio_callback.
if (!source->audio_pending && source->audio_ts > 0) {
int iterations = 0;
while (source->audio_input_buf[0].size < 4096) {
blog(LOG_DEBUG,
"waiting 2 ms for audio buffer to fill (%s)",
obs_source_get_name(source));
os_sleep_ms(2);
iterations++;
}
if (iterations > 0) {
blog(LOG_DEBUG,
"waited %i iterations for the audio buffer to fill",
iterations);
}
}
This significantly reduces the number of dropouts (on my system to like 1 in half an hour), but it’s not a good solution because additional to not entirely fixing the issue it doesn’t recover from the situation and adds continuous wait cycles after the first dropout that far exceed the number of dropouts that would have actually occurred. Also it seems kind of wrong to me doing that in the first place.
I would appreciate some guidance or a fix for this issue.
