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/
Author
Xandaros
First release
Last update
Rating
4.00 star(s) 1 ratings

Latest reviews

This works perfectly with the addition that Radon mentioned in the discussion.
Top