Audio crackling at ranom interval with "Application Audio Capture"

Neryss

New Member
Here's a quick update:
I've streamed approx 10 hours of switch gameplay, so using an Avermedia Mini, and I didn't have any sound issue at all during all these streams...
I guess the OBS plugin has some issues or my MB audio card has some issues then?
 

vanyaindigo

New Member
Perhaps the incorrect work of the plugin is due to some kind of OBS update, since you say that it worked without problems before.
 

aelius_l

New Member
Updating this with a quick note, but I nagged the #audio-support channel on the OBS Discord and was able to set up a tracelogging program with someone there. I managed to capture the bug happening on stream again today and was recording the events to a tracelog and sent that over along with the VOD, so hopefully we'll hear something about this issue sooner rather than later.
 

RocketarmsMedia

New Member
I've used both win-capture-audio plugin and the built-in OBS one, both having the same issues. It's just the game audio for me in this case (I of course can't hear it, only stream/vod).

clips.twitch.tv/ScrumptiousTubularPenguinSquadGoals-ttCT-2eoCIglNFlN
 

Neryss

New Member
I'm here with a quick update now and I might ask some things because I'm not knowledgeable enough about audio capture etc.

So I've been streaming my Switch gameplay for 2 weeks now and no sound issues so far (several 5-6h sessions) :
I'm using a capture device source on OBS, the audio is captured by that instead of the application audio source, but why does it differ?

I though the issue came from something else than OBS (since I've been having issues with discord screenshare), like my motherboard because of the fact my problem started appearing when I changed it alongside my CPU. But even if I capture the audio via a capture device source, the audio is still treated by my computer right? Only difference being the image and audio passes by USB, so is the audio treated differently than when it comes from my PC?

I also thought it was an encoder issue, but the image from my capture card is still treated by my encoder for OBS so I guess it shouldn't be the reason?

If so, I can assume the issue is not hardware related, it could be a driver problem, but it wouldn't explain why I don't have issues with my Switch gameplay.
If it was indeed hardware related I would have more issues daily and I would have audio inconsistencies with records from AMD adrenalin, or just in my headset while gaming.

Now the last problematic reasoning:
If it's not something I can hear in my headset meaning I've never heard the issue directly, instead it was only from recording/streams, where could it come from? It's the same problem with discord screensharing so it's not only related to OBS or the audio app capture.

I'm kind of lost now since I first thought it was something ONLY related to OBS but it doesn't seem so? But it also seems like it's related to it (since streaming audio from my capture card should also trigger this issue).

But anyway here's the report, I'll try to get some answers in the meanwhile and I will update the post if I have some news.
 

Suslik V

Active Member
There is chance that this can be connected to the:
[game-capture: 'Game Capture'] ----------------- d3d12 capture freed ----------------
and similar events during the capture.

1) Are you Alt-Tabbing from the captured game to the desktop (for example, to type something in the chat)?
2) Is this audio crackling happens to games/media_payers running in window (not fullscreen)?

----------------
A bit of additional info.

Technically (if I understand it right), all audio data grabbed (or let say copied) in this line of code:
So, this grabbed data may differ from what you hear because it's a copy of the original audio data, and it may be mistakenly taken from a different place/size/time etc (just my own assumption). Normally this shouldn't happen. And most of the time the feature works OK.

From the user's point of view - you can do almost nothing on your side to resolve the issue. If some other workarounds (as virtual devices or capture cards) works for you fine - use them.

When the process-capture feature was implemented, developers were aware of the crackling issue.
The comment to the corresponding commit says:
https://github.com/obsproject/obs-studio/pull/5218/commits/769a29bd1a561ae705091ad3c6fcb481850bc80c said:
...Marked as "(BETA)" until we figure out the crackling at 60 minutes.
 

vanyaindigo

New Member
1) Are you Alt-Tabbing from the captured game to the desktop (for example, to type something in the chat)?
2) Is this audio crackling happens to games/media_payers running in window (not fullscreen)?
I can answer "no" to all 2 points: not alt-tabbing nor game running in window.
 

Suslik V

Active Member
I did small investigation that can help to shad a light on the origin of the issue (fingers crossed).
I made small lua script that in my test invironment can reproduce the issue in about 1 minute.

Steps to reproduce the issue:
  1. Download the "Issue #8064 (test files).7z" archive, ~126KB, MD5:9609E30AB901A25256DEEB269F623878 and unpack its contents to the "C:\Temp" folder (make the one if it doesn't exist). If all done OK you will find: "C:\Temp\Issue #8064 (test files)\testApplicationAudioCaptureBeta.lua" and other files)
  2. Reduce volume of the PC and run OBS (test script includes sound files at 500Hz that is aweful for ears)
  3. Import Profile from folder named "test_Application_Audio_Capture_BETA_8064"
  4. Import Scene Collection file named "test_Application_Audio_Capture_BETA_8064.json"
  5. Switch to Profile named "test Application Audio Capture (BETA) #8064"
  6. Switch to Scene Collection named "test Application Audio Capture (BETA) #8064"
  7. PC will start to play the sound of 500Hz (if you will use different folder from p1 - there will be message that the script is missing - open the Tools > Scripts, remove "testApplicationAudioCaptureBeta.lua" from the list and add the script manually)
  8. Click Start Recording button (destination for files is "C:\Temp")
  9. Open Tools > Scripts and select the "testApplicationAudioCaptureBeta.lua" script
  10. In the properties of the script click the Start disturb timer button
  11. In 5 sec the Preview of OBS will be disabled and enabled again in 200 ms, again and again. Then in 5 sec process will repeat (infinity loop)
  12. Wait until crackling appear in the recording (about 2-10 minutes)
  13. Click Stop Recording button
  14. Exit OBS
  15. Add recorded .mp4 file to your favorite audio editor (or playback the file) to check if 1kHz recorded signal has any anomalies (first stereo track is Application Audio capture (BETA), second is reference Desktop Audio)

Example:
obs Application Audio Capture (BETA) bug_#8064.png

Please, try to reproduce the issue on your end by using this script and say here if you succeeded or not.
I used virtual environment and this may not reflect the real PC behavior. So, your help is appreciated.

Notes
In my setup, if the Default Format (Windows sound setting for the device running in shared mode) differs from the OBS Audio (for example, 48kHz vs 44.1kHz) then the issue may happen earlier.

In virtual environment I got crash during the testing. Despite the OS is obsolete, I will add the log here, just in case (the .mp4 itself was 29MB, so I didn't attached it here, with the crackling in the end, and some samples were over the 1.0f amplitude which is odd).

Don't forget to switch to different Scene Collection and Profile before using OBS as normal (script auto plays 500Hz sound on OBS startup without confirmation).

Lua:
local obs = obslua
local bit = require("bit")
local ffi = require("ffi")
local winmm = ffi.load("Winmm")
local SND_ASYNC = 0x00000001
local SND_NODEFAULT = 0x00000002
local SND_LOOP = 0x00000008
local SND_FILENAME = 0x00020000
local fdwSound_flags = SND_ASYNC + SND_NODEFAULT + SND_FILENAME
local fdwSound_flags_looped = SND_ASYNC + SND_NODEFAULT + SND_LOOP + SND_FILENAME

-- Looping parameters
local timer_period_ms = 5000
local disturb_active_ms = 200

-- Locks for timers
local timer_active = false
local disturb_active = false

-- Put a sounds of your choice next to "su34.lua" and don't forget to match its names either in code below or rename your existing files.
SOUND1_FILEPATH = script_path() .. "500Hz-06a_48000sr_32bit_float_10sec.wav"
SOUND2_FILEPATH = script_path() .. "streaming_started.wav"
SOUND3_FILEPATH = script_path() .. "1kHz-06a_48000sr_32bit_float_10sec.wav"

ffi.cdef[[
    bool PlaySound(const char *pszSound, void *hmod, uint32_t fdwSound);
]]

function playsound(filepath)
    winmm.PlaySound(filepath, nil, fdwSound_flags)
end

function playsound_looped(filepath)
    winmm.PlaySound(filepath, nil, fdwSound_flags_looped)
end

function on_event(event)
  if event == obs.OBS_FRONTEND_EVENT_STREAMING_STARTED then
    playsound(SOUND2_FILEPATH)
  end
  if event == obs.OBS_FRONTEND_EVENT_RECORDING_STARTED then
    playsound_looped(SOUND3_FILEPATH)
  end
  if event == obs.OBS_FRONTEND_EVENT_RECORDING_STOPPED then
    playsound_looped(SOUND1_FILEPATH)
  end
end

-- This function triggers OBS hotkey event.
-- I was unable to make the "obs.obs_frontend_set_preview_enabled(true)"
-- to trigger at list twice in a row (true/false) from inside the script,
-- thus using hotkeys here...
function send_hotkey(hotkey_id_name, key_modifiers)
    shift_mod = key_modifiers.shift or false
    control_mod = key_modifiers.control or false
    alt_mod = key_modifiers.alt or false
    command_mod = key_modifiers.command or false
    modifiers = 0

    if shift_mod then
        modifiers = bit.bor(modifiers, obs.INTERACT_SHIFT_KEY )
    end
 
    if control_mod then
        modifiers = bit.bor(modifiers, obs.INTERACT_CONTROL_KEY )
    end
 
    if alt_mod then
        modifiers = bit.bor(modifiers, obs.INTERACT_ALT_KEY )
    end
 
    if command_mod then
        modifiers = bit.bor(modifiers, obs.INTERACT_COMMAND_KEY )
    end

    combo = obs.obs_key_combination()
    combo.modifiers = modifiers
    combo.key = obs.obs_key_from_name(hotkey_id_name)

    obs.obs_hotkey_inject_event(combo, false)
    obs.obs_hotkey_inject_event(combo, true)
    obs.obs_hotkey_inject_event(combo, false)
end

-- Internal loop (toggles preview)
function timer_disturb_callback()
    if obs.obs_frontend_preview_enabled() then
        --print("OBS true")
        send_hotkey("OBS_KEY_A", {}) ---- {shift=true, alt=true, control=true}
    else
        --print("OBS false")
        send_hotkey("OBS_KEY_A", {})
    end
end

-- External loop (delay + timeout)
function timer_callback()
    if disturb_active then
        disturb_active = false
        print("...OBS disturb ended!")
        obs.timer_remove(timer_disturb_callback)
    else
        disturb_active = true
        print("disturb OBS...")
        obs.timer_add(timer_disturb_callback, disturb_active_ms)
    
    end
end

-- Start external loop
function disturb_obs_button_clicked(props, p)
    if not timer_active then
        obs.timer_add(timer_callback, timer_period_ms)
        timer_active = true
    end
    return false
end

-- A function named script_properties defines the properties that the user
-- can change for the entire script module itself
function script_properties()
    local props = obs.obs_properties_create()
    obs.obs_properties_add_button(props, "disturb_obs_button", "Start disturb timer", disturb_obs_button_clicked)
    return props
end

function script_description()
    return "to test Application Audio Capture (BETA) crackling issue (#8064).\nRequires hotkey 'A' for the Enable Preview and Disable Preview."
end

function script_load(settings)
  playsound_looped(SOUND1_FILEPATH)
  obs.obs_frontend_add_event_callback(on_event)
end

-- Modified: Suslik V
-- Based on Lua script:
-- https://gist.github.com/snakecase/e816384a071cec31efbb4b9e429c108d

-- Credits: upgradeQ (https://gist.github.com/upgradeQ/b2412242d76790d7618d6b0996c4562f), gima (https://gitlab.com/gima/obsnotification)
-- Thank you guys!

ALSO, look for newer version of the similar test files here: https://github.com/obsproject/obs-studio/issues/8064#issuecomment-1597505629
If you succeed ("crackling" appears in 2-120 minute interval), follow these steps (it may help to developers to resolve the issue): https://github.com/obsproject/obs-studio/issues/8064#issuecomment-1519111627
 

Attachments

  • Issue #8064 (test files).7z
    126.9 KB · Views: 21
  • 2023-05-26 11-36-58.txt
    87.3 KB · Views: 21
  • Crash 2023-05-26 11-47-43.txt
    34 KB · Views: 29
Last edited:

Neryss

New Member
I did small investigation that can help to shad a light on the origin of the issue (fingers crossed).
I made small lua script that in my test invironment can reproduce the issue in about 1 minute.

Steps to reproduce the issue:
  1. Download the "Issue #8064 (test files).7z" archive, ~126KB, MD5:9609E30AB901A25256DEEB269F623878 and unpack its contents to the "C:\Temp" folder (make the one if it doesn't exist). If all done OK you will find: "C:\Temp\Issue #8064 (test files)\testApplicationAudioCaptureBeta.lua" and other files)
  2. Reduce volume of the PC and run OBS (test script includes sound files at 500Hz that is aweful for ears)
  3. Import Profile from folder named "test_Application_Audio_Capture_BETA_8064"
  4. Import Scene Collection file named "test_Application_Audio_Capture_BETA_8064.json"
  5. Switch to Profile named "test Application Audio Capture (BETA) #8064"
  6. Switch to Scene Collection named "test Application Audio Capture (BETA) #8064"
  7. PC will start to play the sound of 500Hz (if you will use different folder from p1 - there will be message that the script is missing - open the Tools > Scripts, remove "testApplicationAudioCaptureBeta.lua" from the list and add the script manually)
  8. Click Start Recording button (destination for files is "C:\Temp")
  9. Open Tools > Scripts and select the "testApplicationAudioCaptureBeta.lua" script
  10. In the properties of the script click the Start disturb timer button
  11. In 5 sec the Preview of OBS will be disabled and enabled again in 200 ms, again and again. Then in 5 sec process will repeat (infinity loop)
  12. Wait until crackling appear in the recording (about 2-10 minutes)
  13. Click Stop Recording button
  14. Exit OBS
  15. Add recorded .mp4 file to your favorite audio editor (or playback the file) to check if 1kHz recorded signal has any anomalies (first stereo track is Application Audio capture (BETA), second is reference Desktop Audio)

Example:
View attachment 94476

Please, try to reproduce the issue on your end by using this script and say here if you succeeded or not.
I used virtual environment and this may not reflect the real PC behavior. So, your help is appreciated.

Notes
In my setup, if the Default Format (Windows sound setting for the device running in shared mode) differs from the OBS Audio (for example, 48kHz vs 44.1kHz) then the issue may happen earlier.

In virtual environment I got crash during the testing. Despite the OS is obsolete, I will add the log here, just in case (the .mp4 itself was 29MB, so I didn't attached it here, with the crackling in the end, and some samples were over the 1.0f amplitude which is odd).

Don't forget to switch to different Scene Collection and Profile before using OBS as normal (script auto plays 500Hz sound on OBS startup without confirmation).

Lua:
local obs = obslua
local bit = require("bit")
local ffi = require("ffi")
local winmm = ffi.load("Winmm")
local SND_ASYNC = 0x00000001
local SND_NODEFAULT = 0x00000002
local SND_LOOP = 0x00000008
local SND_FILENAME = 0x00020000
local fdwSound_flags = SND_ASYNC + SND_NODEFAULT + SND_FILENAME
local fdwSound_flags_looped = SND_ASYNC + SND_NODEFAULT + SND_LOOP + SND_FILENAME

-- Looping parameters
local timer_period_ms = 5000
local disturb_active_ms = 200

-- Locks for timers
local timer_active = false
local disturb_active = false

-- Put a sounds of your choice next to "su34.lua" and don't forget to match its names either in code below or rename your existing files.
SOUND1_FILEPATH = script_path() .. "500Hz-06a_48000sr_32bit_float_10sec.wav"
SOUND2_FILEPATH = script_path() .. "streaming_started.wav"
SOUND3_FILEPATH = script_path() .. "1kHz-06a_48000sr_32bit_float_10sec.wav"

ffi.cdef[[
    bool PlaySound(const char *pszSound, void *hmod, uint32_t fdwSound);
]]

function playsound(filepath)
    winmm.PlaySound(filepath, nil, fdwSound_flags)
end

function playsound_looped(filepath)
    winmm.PlaySound(filepath, nil, fdwSound_flags_looped)
end

function on_event(event)
  if event == obs.OBS_FRONTEND_EVENT_STREAMING_STARTED then
    playsound(SOUND2_FILEPATH)
  end
  if event == obs.OBS_FRONTEND_EVENT_RECORDING_STARTED then
    playsound_looped(SOUND3_FILEPATH)
  end
  if event == obs.OBS_FRONTEND_EVENT_RECORDING_STOPPED then
    playsound_looped(SOUND1_FILEPATH)
  end
end

-- This function triggers OBS hotkey event.
-- I was unable to make the "obs.obs_frontend_set_preview_enabled(true)"
-- to trigger at list twice in a row (true/false) from inside the script,
-- thus using hotkeys here...
function send_hotkey(hotkey_id_name, key_modifiers)
    shift_mod = key_modifiers.shift or false
    control_mod = key_modifiers.control or false
    alt_mod = key_modifiers.alt or false
    command_mod = key_modifiers.command or false
    modifiers = 0

    if shift_mod then
        modifiers = bit.bor(modifiers, obs.INTERACT_SHIFT_KEY )
    end
 
    if control_mod then
        modifiers = bit.bor(modifiers, obs.INTERACT_CONTROL_KEY )
    end
 
    if alt_mod then
        modifiers = bit.bor(modifiers, obs.INTERACT_ALT_KEY )
    end
 
    if command_mod then
        modifiers = bit.bor(modifiers, obs.INTERACT_COMMAND_KEY )
    end

    combo = obs.obs_key_combination()
    combo.modifiers = modifiers
    combo.key = obs.obs_key_from_name(hotkey_id_name)

    obs.obs_hotkey_inject_event(combo, false)
    obs.obs_hotkey_inject_event(combo, true)
    obs.obs_hotkey_inject_event(combo, false)
end

-- Internal loop (toggles preview)
function timer_disturb_callback()
    if obs.obs_frontend_preview_enabled() then
        --print("OBS true")
        send_hotkey("OBS_KEY_A", {}) ---- {shift=true, alt=true, control=true}
    else
        --print("OBS false")
        send_hotkey("OBS_KEY_A", {})
    end
end

-- External loop (delay + timeout)
function timer_callback()
    if disturb_active then
        disturb_active = false
        print("...OBS disturb ended!")
        obs.timer_remove(timer_disturb_callback)
    else
        disturb_active = true
        print("disturb OBS...")
        obs.timer_add(timer_disturb_callback, disturb_active_ms)
     
    end
end

-- Start external loop
function disturb_obs_button_clicked(props, p)
    if not timer_active then
        obs.timer_add(timer_callback, timer_period_ms)
        timer_active = true
    end
    return false
end

-- A function named script_properties defines the properties that the user
-- can change for the entire script module itself
function script_properties()
    local props = obs.obs_properties_create()
    obs.obs_properties_add_button(props, "disturb_obs_button", "Start disturb timer", disturb_obs_button_clicked)
    return props
end

function script_description()
    return "to test Application Audio Capture (BETA) crackling issue (#8064).\nRequires hotkey 'A' for the Enable Preview and Disable Preview."
end

function script_load(settings)
  playsound_looped(SOUND1_FILEPATH)
  obs.obs_frontend_add_event_callback(on_event)
end

-- Modified: Suslik V
-- Based on Lua script:
-- https://gist.github.com/snakecase/e816384a071cec31efbb4b9e429c108d

-- Credits: upgradeQ (https://gist.github.com/upgradeQ/b2412242d76790d7618d6b0996c4562f), gima (https://gitlab.com/gima/obsnotification)
-- Thank you guys!
Hey!
I've been away for a bit of time but I'm here now, I can give some more informations:

It doesn't seem to be related to alt+tab, I was playing Control for hours and the sound crackling appears after random interval (usually after one or two hours). It happens to fullscreen, borderless and windowed app as far as I tested.

Earlier today I had issues with the Discord audio capture after like 30min of using the capture and 3 hours of streaming.

I guess the only workaround is to use something such as voicemetter or a global sound capture on OBS. I will try that in the future but it's so much stuff to setup just for OBS (since using voicemetter seems to change the way sound is handled in general). I'm not really into sound tech so it's kinda hard for me to figure out how to setup VM, if it's the only option let's go then.

I mean, I can just wait for the sound issue to disappear after like 10 seconds or change the audio capture back and forth but anyway it's just not "clean".

Thank you so much for the intel! I will try to use your script and report back when I get the results (I'm not streaming the day after tomorrow so I'll do that by then).
 

spooker

New Member
Same problem has been reported for an OBS certified hdmi capture device
 

RocketarmsMedia

New Member
Hey!
I've been away for a bit of time but I'm here now, I can give some more informations:

It doesn't seem to be related to alt+tab, I was playing Control for hours and the sound crackling appears after random interval (usually after one or two hours). It happens to fullscreen, borderless and windowed app as far as I tested.

Earlier today I had issues with the Discord audio capture after like 30min of using the capture and 3 hours of streaming.

I guess the only workaround is to use something such as voicemetter or a global sound capture on OBS. I will try that in the future but it's so much stuff to setup just for OBS (since using voicemetter seems to change the way sound is handled in general). I'm not really into sound tech so it's kinda hard for me to figure out how to setup VM, if it's the only option let's go then.

I mean, I can just wait for the sound issue to disappear after like 10 seconds or change the audio capture back and forth but anyway it's just not "clean".

Thank you so much for the intel! I will try to use your script and report back when I get the results (I'm not streaming the day after tomorrow so I'll do that by then).
Will agree Voicemeeter is a bit of a hassle getting to work, but now I'm using it permanently on and off OBS.
 

RocketarmsMedia

New Member
Will agree Voicemeeter is a bit of a hassle getting to work, but now I'm using it permanently on and off OBS.
Okay just checked my VOD and its still scuffed 10% of the time... It's definitely all the [application/audio output capture] and the BETA. Will try the [audio input capture] for next stream and see if it reoccurs
 

AaronD

Active Member
Same problem has been reported for an OBS certified hdmi capture device
What you describe over there doesn't sound like this problem. Audio problems are not audio problems are not audio problems. Minute details matter a lot. Blending unrelated problems together in the same thread makes it hard to solve any of them.
 

RocketarmsMedia

New Member
Okay just checked my VOD and its still scuffed 10% of the time... It's definitely all the [application/audio output capture] and the BETA. Will try the [audio input capture] for next stream and see if it reoccurs
Okay I'm no tech wiz with software, but voicemeeter on top of [audio input capture] seems to have fixed any static.
 

Suslik V

Active Member
I noticed that the "crackling" always captured by the peak meter of OBS (obviously, 1kHz test wave signal changes its amplitude before being encoded).
 

dan.cormack

New Member
I have run into this exact issue. I record my sessions in a flight sim called DCS. I am using the application audio capture as I don't want desktop sounds to show up and for some reason, I cannot get the application to flow all audio out to the virtual audio devices which I also use to record additional programs which generate sounds. This generally happens after about an hour of recording. I unfortunately don't have an exact time just yet. Going forward, I am exiting and restarting my OBS session prior to starting up a recording session. The problem arises and lasts for up to 8 minutes or so. It has a gradual onset and then gets quite bad and then suddenly fades away. You can experience it here.. Onset https://youtu.be/KQZCTx44THQ?t=1190. Quite bad. https://youtu.be/KQZCTx44THQ?t=1285. Gone https://youtu.be/KQZCTx44THQ?t=1387
 

Mundayy

New Member
Just want to add I've been having this same issue for several months now. I believe it started happening after upgrading to an AMD cpu. After about an hour-ish into stream the audio goes crackly with no indication to me or anything. Strangely it's only my game audio. Mic and spotify seem to be unaffected as far as I can tell, but I'm only aware of it happening when someone in chat points it out. Usually an alt-tab or two will fix it, but I keep checking back here for fixes and keeping my fingers crossed each time OBS updates that it'll fix it.
 
Top