Last active
December 17, 2022 10:31
-
-
Save koonix/0f843ca152cc2ded9232bf4de9dcc9b3 to your computer and use it in GitHub Desktop.
load/unload a pulseaudio module-remap-sink on OBS 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 v1</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: ghesy <ehsan at disroot dot org></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