Resource icon

Include/Exclude audio sources using PulseAudio(Linux)

Sometimes you want to stream the audio of one application, but not the other. Here is how to do that on Linux using PulseAudio:

First of all, you are probably going to need pavucontrol as a nice user interface to PulseAudio. If you are able to use pactl for everything, you can probably do that, too.
On Arch Linux and Ubuntu the package is simply called "pavucontrol".

Next, you need to figure out the internal name of your standard output device. Open up pavucontrol and select "Output Devices" at the top. If you play some sound, you will be able to see which of these is active. In my case, its human-readable name is "Built-in Analog Stereo".
Open up a terminal and type in "pactl list short sinks". You will now see the same devices again but this time with their internal name. Copy the name of your standard output device, you will need it later. (The internal name will be similar to the human-readable one. In my case "alsa_output.pci-0000_00_14.2.analog-stereo". Another hint is that it will say "RUNNING" at the end instead of, for example, "IDLE".

Now you will need to add a null sink. This is an output device that will not output to any hardware but will be used by obs. Type in "pactl load-module module-null-sink". Unfortunately you are not able to name this upon creation, but you can use pavucontrol to rename the device if you want.
When executed, it will print a number. This will be important in the next step.

Now that you have a null sink, you are able to have applications that play on your speakers and applications which get their audio streamed by obs, but currently you won't be able to hear those. So you need to add a combine-sink by executing "pactl load-module module-combine-sink slaves=<number>,<name>" in a terminal. Replace <number> with the number of the last step and <name> with the internal name of your standard audio output device.
If you want to give the device a custom name, you can use "pactl load-module module-combine-sink sink_name=<custom name> slaves=<number>,<name>" instead.

And with that you are pretty much good to go. In pavucontrol, switch to the "Playback" tab. On the right of a sound source, you can select to which output device its sound will go. Select your standard audio output device if you want to hear the sound, but don't want to stream it. Select the Null Output if you want to stream it, but don't want to hear it or select the Simultaneous output (combine output) if you want to hear it AND stream it.

The only thing left to do is add a Audio Output Capture in OBS and let it listen to the null device.

If you want to know more about the PulseAudio modules used, see: http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Modules/
  • Like
Reactions: Benjamin Loison
Author
Xandaros
Views
22,590
First release
Last update
Rating
4.75 star(s) 4 ratings

Latest reviews

hi, made an account just to rate this 10 year old guide, still works !!! only thing is that when i did the "pactl load-module module-combine-sink slaves=<number>,<name>" it would always give me "Failure: Input/Output error" so i did "pactl list short sinks" again and with the null-sink showing up as "null-sink" (wow) i put that instead of the number and it just worked so cool!

hihi again edit ive noticed that upon reboot it doesnt stay so after like an hour and a half i have a solution !!!!!!! from (https://askubuntu.com/questions/1379376/how-to-achieve-automated-simultaneous-outputs-with-pipewire)
pretty much, going to /usr/share/pipewire (it syas to copy but it didnt work for me so i just edited the file itself) and replacing the context.exec with
context.exec = [
{ path = "pactl" args = "load-module module-null-sink sink_name=swaggy" }
{ path = "pactl" args = "load-module module-combine-sink slaves=swaggy,<NAME CHANGE THIS TO UR OUTPUT !!!!>" }
{ path = "pactl" args = "set-default-sink combined" }
]
will create a null sink on boot and combine it with whatever output you change it to and i think save audio changes from pavucontrol idk though it ojnly played my spotify to my usb output and not combined so idk !!
hopefully this helped newer peopleif yuo have problems dont contact me i probably dont know how so solve them !!!
Gave clear instructions on how to do EXACTLY what I needed to do to not have an echo of my voice on stream and STILL be able to monitor my mic output!
This works perfectly with the addition that Radon mentioned in the discussion.
Top