How can I create a virtual output in PulseAudio?

You can add a sink with

pacmd load-module module-null-sink sink_name=MySink
pacmd update-sink-proplist MySink device.description=MySink

You can add a loopback device with the command

pacmd load-module module-loopback sink=MySink

sudo modprobe snd_aloop

Adds a loopback device to ALSA, which appears in the PulseAudio Volume Control. Redirect your stream there, and presto!

Not sure how to add multiple loopback devices.


A little complement to @mxc's answer, as he said you can use the module-null-sink as a virtual output with:

    pacmd load-module module-null-sink sink_name=MySink

This creates a new sink ("virtual output") that you can use for your application. For every sink you create, pulseaudio will also create a monitor source, so in addition to your MySink output device, you will have a MySink.monitor input device that you can use to capture what is sent to your virtual output.

This way it is easy to capture, restream or record the audio an application outputs.

This is a pure Pulseaudio solution and doesn't require Alsa, so it will also work with a different backend than Alsa for Pulseaudio.

Tags:

Pulseaudio