[game-capture: 'Game Capture'] ----------------- d3d12 capture freed ----------------
https://github.com/obsproject/obs-studio/pull/5218/commits/769a29bd1a561ae705091ad3c6fcb481850bc80c said:...Marked as "(BETA)" until we figure out the crackling at 60 minutes.
I can answer "no" to all 2 points: not alt-tabbing nor game running in window.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)?
.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).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).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 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:
- 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)
- Reduce volume of the PC and run OBS (test script includes sound files at 500Hz that is aweful for ears)
- Import Profile from folder named "test_Application_Audio_Capture_BETA_8064"
- Import Scene Collection file named "test_Application_Audio_Capture_BETA_8064.json"
- Switch to Profile named "test Application Audio Capture (BETA) #8064"
- Switch to Scene Collection named "test Application Audio Capture (BETA) #8064"
- 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)
- Click Start Recording button (destination for files is "C:\Temp")
- Open Tools > Scripts and select the "testApplicationAudioCaptureBeta.lua" script
- In the properties of the script click the Start disturb timer button
- 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)
- Wait until crackling appear in the recording (about 2-10 minutes)
- Click Stop Recording button
- Exit OBS
- 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!
Will agree Voicemeeter is a bit of a hassle getting to work, but now I'm using it permanently on and off OBS.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).
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 reoccursWill agree Voicemeeter is a bit of a hassle getting to work, but now I'm using it permanently on and off OBS.
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.Same problem has been reported for an OBS certified hdmi capture device
Asus TUF GAMING CAPTURE BOX-CU4K30 Audio Issue
I am using OBS Studio 29.1.1 and OBS certified hdmi capture card Asus TUF GAMING CAPTURE BOX-CU4K30 I am having a weird problem with sound when capturing HDMI content. When audio monitoring is turned on the sound is like a robot talking . Turning the audio monitoring to off and then back on...obsproject.com
Okay I'm no tech wiz with software, but voicemeeter on top of [audio input capture] seems to have fixed any static.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