Last active
May 6, 2022 15:13
-
-
Save koonix/c1d82e55e4f67fd212c97b87b3b08ad6 to your computer and use it in GitHub Desktop.
an OBS script to load/unload a pulseaudio module-remap-sink on OBS's start/exit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function script_description() | |
return [[ | |
<h2>obs-pulse-remap</h2> | |
<p>Load a module-remap-sink on pulseaudio when OBS starts, and unload it when OBS exits.</p> | |
<p>Useful for when you want OBS to capture the audio of only one program.</p> | |
<p>Author: Ehsan Ghorbannezhad <[email protected]></p> | |
]] | |
end | |
local modules = {} | |
function script_load() | |
p = io.popen("pactl load-module module-remap-sink sink_name=OBSSink sink_properties=device.description=OBSSink", "r") | |
for m in p:lines() do | |
if tonumber(m) then | |
table.insert(modules, m) | |
end | |
end | |
end | |
function script_unload() | |
for _, m in ipairs(modules) do | |
os.execute("pactl unload-module " .. m) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment