PipeWire

PipeWire is a new low-level multimedia framework. It aims to offer capture and playback for both audio and video with minimal latency and support for PulseAudio, JACK, ALSA and GStreamer-based applications.

The daemon based on the framework can be configured to be both an audio server (with PulseAudio and JACK features) and a video capture server.

PipeWire also supports containers like Flatpak and does not rely on the audio and video user groups. Instead, it uses a Polkit-like security model, asking Flatpak or Wayland for permission to record screen or audio.

Installation

Install the pipewire package from the official repositories. There is also lib32-pipewire for multilib support.

Pipewire uses systemd/User for management of the server and automatic socket activation.

Optionally, install pipewire-docs to review the documentation.

Pipewire can work as drop-in replacement for others audio servers. See #Audio for details.

Session manager

Like JACK, PipeWire implements no connection logic internally. The burden of watching for new streams and connect them to the appropriate output device or application is left to an external component known as a session manager.

There are currently two session managers available:

  • WirePlumber A more powerful manager and the current recommendation. It is based on a modular design, with Lua plugins that implement the actual management functionality.
https://pipewire.pages.freedesktop.org/wireplumber/ || wireplumber
  • PipeWire Media Session A very simple session manager that caters to some basic desktop use cases. It was mostly implemented for testing and as an example for building new session managers.
https://gitlab.freedesktop.org/pipewire/media-session || pipewire-media-session

Switch between session managers by simply installing the appropriate package, which will conflict with and replace the other option.

GUI

Configuration

The PipeWire package provides an initial set of configuration files in . You should not edit these files directly, as package updates will overwrite your changes. To configure PipeWire, you can copy files from to the alternate system-wide location , or to the user location ~/.config/pipewire. An equally named file in a directory with a higher precedence makes the analogous files ignored.

Profiles

Pipewire brings a custom "Pro Audio" profile in addition to the PulseAudio profiles, selectable through pavucontrol. The effect of which is described here: https://gitlab.freedesktop.org/pipewire/pipewire/-/wikis/FAQ#what-is-the-pro-audio-profile

Usage

Audio

PipeWire can be used as an audio server, similar to PulseAudio and JACK. It aims to replace both PulseAudio and JACK, by providing a PulseAudio-compatible server implementation and ABI-compatible libraries for JACK clients. See the blog post PipeWire Late Summer Update 2020 for more information.

ALSA clients

Install (and remove if it was installed) to route all application using the ALSA API through PipeWire.

PulseAudio clients

Install . It will replace and . Reboot, re-login or start the user unit to see the effect.

Normally, no further action is needed, as the user service should be enabled automatically by the package. To check if the replacement is working, run the following command and see the output:

For further configuration (e.g. regarding modules) take a look at the official upstream Wiki about Migration from PulseAudio and Configuration of Pipewire-Pulse.

JACK clients

Install for JACK support. There is also for multilib support.

pw-jack(1) may be used to start JACK clients, but it is technically not required, as it only serves as a wrapper around the , and environment variables.

It is possible to request a custom buffer size by setting a quotient of buffersize/samplerate (which equals the block latency in seconds):

PIPEWIRE_LATENCY="128/48000" application

Bluetooth devices

PipeWire handles Bluetooth audio devices if the package is installed. The package includes the /etc/pipewire/media-session.d/with-pulseaudio file, whose existence prompts the media session daemon to enable the module.

Automatic profile selection

Both and WirePlumber can automatically switch between HSP/HFP and A2DP profiles whenever an input stream is detected.

has it disabled by default. You can set  property to  to enable it:

WirePlumber has profile auto-switching enabled by default. You can disable it with:

PipeWire patch sets for command line

We have Helvum for graphical visualization and creation of connections, but it cannot save and load patch sets. qpwgraph does this nicely in full GUI. For non-GUI needs, the following are bash scripts to save wiresets, load wiresets, and dewire all connections. For saving and loading, use a command-line parameter for the filename.

pw-savewires
#!/bin/bash

if [[ "$#" -ne 1 ]]; then
	echo
	echo 'usage: pw-savewires filename'
	echo
	exit 0
fi

rm $1 &> /dev/null
while IFS= read -r line; do
	link_on=`echo $line | cut -f 4 -d '"'`
	link_op=`echo $line | cut -f 6 -d '"'`
	link_in=`echo $line | cut -f 8 -d '"'`
	link_ip=`echo $line | cut -f 10 -d '"'`
	echo "Saving: " "'"$link_on:$link_op"','"$link_in:$link_ip"'"
	echo "'"$link_on:$link_op"','"$link_in:$link_ip"'" >> $1
done < <(pw-cli dump short link)

Sharing audio devices with computers on the network

While PipeWire itself is not network transparent, its pulse implementation supports network streaming. An easy way to share audio between computers on the network is to use the Avahi daemon for discovery. To enable this functionality, install the package. Make sure that the is running on all computers that will be sharing audio.

To share the local audio devices load the appropriate modules on the host (make sure to use the local IP address):

$ pactl load-module module-native-protocol-tcp listen=192.168.1.10
$ pactl load-module module-zeroconf-publish

Then load the discovery module on the clients:

$ pactl load-module module-zeroconf-discover

It is also possible to load the modules automatically by creating a dedicated configuration file:

Streaming audio to an AirPlay receiver

It is possible to stream audio to a device that is posing as an AirPlay Receiver. To enable this functionality, load the RAOP Discover module:

$ pactl load-module module-raop-discover

It is also possible to load this module automatically by creating a dedicated configuration file:

Run PipeWire on top of native JACK

PipeWire can also run as a JACK client on top of the native JACK daemon if desired. See JACK and PipeWire for more information.

Use ALSA dmix devices as PipeWire sinks

It is possible to have a PipeWire server (or multiple, for each user) output to ALSA via ALSA dmix devices. This allows you to use ALSA as the primary audio output system while being able to use non-ALSA devices such as Bluetooth headphones.

ALSA dmix setup

Suppose you have two cards, and HDMI:

and your PCMs look like:

and suppose your ALSA configuration looks something like this:

In this particular example, the dmix devices would be and .

PipeWire dmix setup

First of all, stop from monitoring and adding hardware ALSA devices by commenting out alsa_monitor.enable():

Now, configure to use dmix devices. The default configuration file (/usr/share/pipewire/pipewire.conf) contains a commented out example which you can use as a basis.

Add your own element to the array:

As a user (non-root), check out the output of , and set the default input(source) and output(sink) devices to your liking with . is the number before sink/source names.

Now, you can fully test your configuration.

WebRTC screen sharing

Most applications used to rely on X11 for capturing the desktop (or individual applications), for example when using WebRTC in web browsers (e.g. on Google Meet). On Wayland, the sharing mechanism is handled differently for security reasons. PipeWire enables sharing content under Wayland with fine-grained access controls.

This requires and one of its backends to be installed. The available backends are:

After installing a backend, you need to restart the user unit. This also starts the service if it has not started already.

Firefox (84+) supports this method by default, while on Chromium (73+) one needs to enable WebRTC PipeWire support by setting the corresponding (experimental) flag at the URL or via CLI argument .

obs-studio (27+) supports this method by using the new PipeWire capture source.

Note that the only supported feature is sharing the entire desktop and not a specific app/window .

xdg-desktop-portal-wlr

For to work, the and environment variables have to be set in the systemd user session. has to be set to the name of your compositor, e.g. . is set automatically by the compositor. The recommended way to bring these environment variables over to the systemd user session is to run after launching the compositor, e.g. with the compositors configuration file. See and for more details.

Video

Although the software is not yet production-ready, it is safe to play around with. Most applications that rely on GStreamer to handle e.g. video streams should work out-of-the-box using the PipeWire GStreamer plugin, see GStreamer#PipeWire. Applications like e.g. are therefore already able to share video input using it.

Using , it should also be possible to use the pw-v4l2 script to preload a library () that intercepts v4l2 calls and routes video through pipewire.

Audio post-processing

EasyEffects

EasyEffects (former PulseEffects) is a GTK utility which provides a large array of audio effects and filters to individual application output streams and microphone input streams. Notable effects include an input/output equalizer, output loudness equalization and bass enhancement, input de-esser and noise reduction plug-in. See the GitHub page for a full list of effects.

In order to use EasyEffects, install . See Community Presets for a collection of preset configurations. See AutoEq for collection of AI generated EQ presets for headphones.

NoiseTorch

NoiseTorch is an alternative way for noise suppression, packaged with . There also exists .

After starting it the module can be loaded for the selected microphone. It is possible to adjust the voice activation threshold, which should be set to the highest level, not filtering out any actual voice.

You can start audio processing with systemd automatically, see . Note that the noisetorch binary path is different if installed from AUR.

Noise suppression for voice

Install , copy the provided PipeWire configuration to a suitable drop-in directory:

Then simply follow the instructions given on GitHub.

JamesDSP

JamesDSP for Linux (available as ) provides open-source sound effects for PipeWire and PulseAudio. It uses its own effects engine and without depending on LADSPA, Calf, etc. JamesDSP was initially published as an audio effects processor for Android devices.

LADSPA, LV2 and VST plugins

If you want to choose between the full list of available LADSPA, LV2 and VST plugins, you can apply them using a custom Pulseaudio null sink and Carla Jack host. Install , and carla. At the begin, create a new PulseAudio null sink named .

pactl load-module module-null-sink object.linger=1 media.class=Audio/Sink sink_name=default_null_sink channel_map=FL,FR

Start Carla through Pipewire, . In Rack tab add whichever plugin you want. Make sure they are stereo type. You can change their order, the one on top of the list will be the first to receive the audio stream, just like in EasyEffects. Afterwards move to Patchbay tab and connect the L/R monitors to Carla inputs, then Carla outputs to the playbacks of your desired device (speakers, earphones, HDMI, etc). Save the configuration to a local folder, i.e. .

You can test the effects while a multimedia application is reproducing audio, i.e. watching a video on a website through Firefox. There are two methods to do it. The first one, inside Carla Patchbay tab, disconnecting all Firefox connections and linking its L/R outputs to playbacks. The second through pavucontrol, locating Firefox audio stream and redirecting it to (this should remember the connection to automatically redirect the application to the same sink on the next instance).

To apply these settings at startup, create two systemd user service units:

Then override jack-carla-rack service specifying the full path of your Carla configuration at Environment directive:

At last, enable the and user units.

Note that if you set the as the default device in system settings, all applications will be redirected to it and the volume keys will change its level, not the one on the speakers. If you want to control volume speakers, leave them as the default in system settings and redirect your desired application to inside pavucontrol (Pipewire compatibility layer will remember the connection on the next instance of the same application).

Troubleshooting

Microphone is not detected by PipeWire

PipeWire's alsa-monitor module uses to detect devices by default. If this is not working for you, try to turn off , or optionally turn on .

If using :

Otherwise, if using :

Then, restart PipeWire and check available devices:

An alternative solution suggested in this PipeWire issue is to add the microphone manually. First of all, make sure the microphone is detected by ALSA.

$ arecord -l
**** List of CAPTURE Hardware Devices ****
card ''card_number'': ''card_name'', device ''device_number'': ''device_name''
  ...

Choose your microphone from the list, and to further test the microphone, run the following commands.

If the microphone is working with , but not detected by PipeWire, try to add a config file to manually add this device.

/etc/pipewire/pipewire.conf.d/microphone.conf (or ~/.config/pipewire/pipewire.conf.d/microphone.conf)
context.objects = [
    { factory = adapter
        args = {
            factory.name           = api.alsa.pcm.source
            node.name              = "microphone"
            node.description       = "Undetected Microphone"
            media.class            = "Audio/Source"
            api.alsa.path          = "hw:''card_number'',''device_number''"
        }
    }
]

And then restart PipeWire to reload the config.

Sound does not automatically switch when connecting a new device

To automatically switch to newly connected devices, uncomment the bolded line:

Restart PipeWire by restarting the and user unit for the changes to take effect.

Sound does not automatically switch to Bluetooth headphones

Run and configure your desktop environment to automatically run that command on login. You might need to execute . The may be found using output of . See wireplumber issue #89 for more details.

No sound after connecting to Bluetooth device

As of 2020-12-07, if there is no sound after connecting a Bluetooth device, you might need to switch the default sink and/or move a sink input to the correct sink. Use to list the available sinks and pactl set-default-sink to switch the default sink to the Bluetooth device. This can be automated via udev using a script similar to this one.

See this Reddit thread for a discussion of the issue. According to author of the script, the headset profile (HSP) might still have problems.

Low volume

After replacing PulseAudio with Pipewire, sound may work fine, but after a reboot, the volume becomes intolerably low.

Open , use to select the proper soundcard, and make sure the ALSA volumes are at 100%. should maintain this setting after reboot.

Increasing RLIMIT_MEMLOCK

Dec 13 11:11:11 HOST pipewire-pulse[99999]: Failed to mlock memory 0x7f4f659d8000 32832: This is not a problem but for best performance, consider increasing RLIMIT_MEMLOCK

Install realtime-privileges and add your own user to the group.

Alternatively, increasing memlock from 64kB to 128kB seems enough to fix this. If you are running under systemd/User, add:

username	soft	memlock	64
username	hard	memlock	128

to

Changing the default sample rate

By default PipeWire sets a fixed global sample rate of 48kHz. If you need to change it (e.g. you own a DAC supporting a higher value), you can set a new default:

Changing the allowed sample rate(s)

PipeWire can also change dynamically the output sample rates supported by your DAC. The sample rate follows the sample rate of the audio stream being played.

for example, . Consult your hardware manual for supported values of your DAC.

According to the developer here,PipeWire allows up to 16 different sample rate and switch when possible. That means, with configuration above, no resampling is done when supported.

To check out which output sample rate and sample format are the data sent to DAC (probably you need to change digits):

$ cat /proc/asound/card0/pcm0p/sub0/hw_params

To check out which input sample rate is used, change pcm0p to ( is short for "capture", is for "playback").

Sound quality (resampling quality)

If you used PulseAudio with or , then you might consider uncommenting and changing to or the maximum 15 in block in both and /etc/pipewire/pipewire-pulse.conf (copy them from if they do not exist). Do not forget to restart the and user units (never forget if you want your configuration changes to be applied).

There is a very little quality difference between and 15, but the CPU load difference is 2-3x. And the latency difference between , , 15 is yet to be investigated by anybody. on 44100→48000 Hz on Ryzen 2600 causes or processes to cause 4.0% one CPU core load.

You can compare resamplers here: https://src.infinitewave.ca/ (do not pay attention to anything above 18 KHz and over 120 dB). speex is listed as "Xiph.org Speex".

PipeWire uses its own resampling algorithm called Spa. Like with SoX's , Speex's , PipeWire includes its standalone version: . Usage:

$ spa-resample -q 15 -f s24 -r 48000 input16bit44100orAnythingElse.wav output24bit48000hz.wav

It is probably somehow possible to use other resamplers by creating your own sink. Or just use a plugin in your music player (e.g., Qmmp has SoX plugin).

External sound card not activated after reconnect

Check ~/.config/pipewire/media-session.d/default-profile if there is any entry with default profile "off" and remove it. If that does not help, remove all files from and restart the user unit.

No Sound or pactl info shows Failure: Connection refused

It means applications are unable to connect to the PipeWire-Pulse service, confirm that /etc/pipewire/pipewire-pulse.conf exists and is not empty and restart the user unit.

If that does not fix it, run and pastebin while seeking help on IRC (#pipewire on OFTC) or the mailing-lists.

Low audio quality on Bluetooth

In case Bluetooth playback stutters, check the unit status of the user unit for errors similar as below:

Feb 17 18:23:01 HOST pipewire[249297]: (bluez_input.18:54:CF:04:00:56.a2dp-sink-60) client too slow! rate:512/48000 pos:370688 status:triggered

If they appear, check the currently selected codec using and try changing it by setting bluez5.codecs to one of . You can also try mSBC support (fixes mic on Sony 1000XM3, i.e. Headphones WH-1000XM3 and Earbuds WF-1000XM3), and the SBC-XQ codec.

With :

With :

Restart PipeWire by restarting the user unit for the changes to take effect.

Noticeable audio delay or audible pop/crack when starting playback

This is caused by node suspension when inactive.

With :

Disable this by editing depending on where the delay occurs and changing property session.suspend-timeout-seconds to 0 to disable or experiment with other values and see what works.

Alternatively you can comment out the line in .

Restart both and to apply these changes, or alternatively reboot.

With , create a new file to overwrite the default configuration:

Instead of disabling suspension entirely, you can also change the timeout value to the desired number of seconds of delay before source suspension.

Audio cutting out when multiple streams start playing

This problem can typically be diagnosed by reading the journal of the user unit and finding lines similar to:

pipewire-pulse[21740]: pulse-server 0x56009b9d5de0: [Nightly] UNDERFLOW channel:0 offset:370676 underrun:940

According to the official PipeWire troubleshooting guide, to solve this problem for :

/etc/pipewire/media-session.d/alsa-monitor.conf (or ~/.config/pipewire/media-session.d/alsa-monitor.conf
api.alsa.headroom = 1024

With :

If you experience audio stuttering because of kernel page locking or late scheduling see Gaming#Tweaking kernel parameters for response time consistency.

Audio is distorted

  • For microphones, try navigating to the card that is having issues after running and use the arrow keys to reduce any "Mic Boost" or "Internal Mic Boost" options.
  • Follow #Changing the default sample rate, reducing the sample rate to to (44.1 kHz).

Audio problems after standby

If the sound is missing or otherwise garbled after waking the machine up from sleep, it might help to reinitialize ALSA:

# alsactl init

High latency with USB DACs (e.g. Schiit DACs)

Changing sample rates or formats might help reduce latency with some DACs such as Schiit Hel 2. Using matching rules in pipewire-media-session we can set properties for devices.

Copy the default configuration file into either or . Then append a new rule-block similar to the following one:

node can be obtained using pw-top.

Your DAC might support a different format or sample rate. You can check what your DAC supports by querying ALSA:

First get the card number of your DAC:

So in this example it would be card 3. Get all supported sample rates and formats:

In this case are the supported formats and are the supported sample rates across all formats.

No sound from USB DAC until 30% volume

Some USB DACs will have no sound output until a certain level of volume is reached . Typically this is around 25% - 30% which then leads to an uncomfortably loud initial volume and the inability to maintain a low volume. The solution is to ignore hardware mixer volume control by setting to .

To achieve this with , you can add onto the configuration by adding a configuration fragment using table.insert:

Then, restart pipewire. Set your master volume in and then save the settings with . You should now be able to use your volume mixer as normal.

Realtime audio does not work

If shows up in the status of the user unit, then the priority of the pipewire daemon was not changed to realtime. See for this issue.

Simultaneous output to multiple sinks on the same sound card

Create a copy of /usr/share/alsa-card-profile/mixer/profile-sets/default.conf so that changes persist across updates. Here we define a profile joining the two default mappings for Analog and HDMI.

Now we configure PipeWire's media-session to use the new card-profile for matching devices. Identifying information can be found using .

No notification sounds from Discord

This might cause by having the min.quantum too low, try setting it to more than 700. You can make an override for Discord specifically by appending the following rule to the pulse.rules section of pipewire-pulse.conf.

FMOD games crashing under PipeWire

Some games that use an old version of the FMOD audio engine, like Pillars of Eternity, invoke and crash if the PulseAudio binary is not present. A workaround is to symlink to /bin/true.

# ln -s /bin/true /bin/pulseaudio

Note that if you wish to reinstall PulseAudio, you need to remove the symlink.

OBS (etc.) display nothing, even if they ask for a window/screen

If you are sure that you have installed as well as either or , check the running state of the daemons.

In OBS, if everything is working, you should see this in :

...
info: [pipewire] desktop selected, setting up screencast
info: [pipewire] created stream 0x5632d7456850
info: [pipewire] playing stream…

For multi-monitor setups the package will allow to capture of all the screens.

gollark: It's a Server Self Destructor.
gollark: <@235768051683950593> No, due to websockets
gollark: No.
gollark: PotatOS has code for dumping a static filesystem image to tapes and then loading it, but not a fast tape filesystem, sadly.
gollark: The interface would be pretty similar.

See also

This article is issued from Archlinux. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.