PipeWire

From ArchWiki
Jump to navigation Jump to search

PipeWire is a new multimedia framework by GNOME. The main developer is Wim Taymans.

PipeWire supports containers like Flatpak and does not rely on user groups audio and video, but rather 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.

Pipewire uses Systemd/User for management of the server and automatic socket activation. See the respective Systemd/User for more details on the startup behavior and logging of the service.

Optionally, install pipewire-docs to review the documentation. Other packages, such as pipewire-alsa, pipewire-pulse, and pipewire-jack are normally not needed unless one wants to use PipeWire as a PulseAudio/JACK replacement. Also available are lib32-pipewireAUR, lib32-pipewire-pulse-gitAUR[broken link: package not found], and lib32-pipewire-jackAUR for multilib support.

Usage

WebRTC screen sharing

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

This requires xdg-desktop-portal and one of its backends to be installed. The available backends are:

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 following URL

chrome://flags/#enable-webrtc-pipewire-capturer

For xdg-desktop-portal-wlr to work you need to set XDG_CURRENT_DESKTOP[1]:

export XDG_CURRENT_DESKTOP=sway

Note, since Chromium is currently using PipeWire 0.2 whereas Arch ships PipeWire 0.3, you also need to install libpipewire02 for screen sharing to work.

Tip: To share an individual monitor with xdg-desktop-portal-wlr if you have more than one, you can add the --output=Monitor flag to it by editing the ExecStart= option in the unit's service file. The complete line could look like ExecStart=@libexecdir@/xdg-desktop-portal-wlr --output=eDP-1

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: Since this pull request was merged, the following note about specific app/window sharing may be not correct anymore for xdg-desktop-portal-gtk. (Discuss in Talk:PipeWire#)

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

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 thanks to the PipeWire GStreamer plugin. Applications like e.g. cheese are therefore already able to share video input using it.

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 this blog entry for more information.

ALSA/Legacy applications

Install pipewire-alsa to route all application using the ALSA API through PipeWire.

PulseAudio clients

Install pipewire-pulse. Normally, no further action is needed, as the user service pipewire-pulse.socket should be enabled automatically by the package. If PipeWire does not work correctly on system startup, validate that the user services pipewire-pulse.service and pipewire.service are up and running. See Systemd/User.

Reboot or re-login to see the effect.

To check if the replacement is working, run the following command and see the output:

$ pactl info
...
Server Name: PulseAudio (on PipeWire 0.3.16)
...

JACK clients

Install pipewire-jack and use pw-jack to launch JACK clients with the compatible libraries instead of the original libjack*:

pw-jack application

Alternatively, install pipewire-jack-dropinAUR to let JACK clients load the compatible libraries automatically.

Use ldd to verify that the JACK application links to the correct library:

$ ldd /usr/bin/qjackctl | grep -i libjack
libjack.so.0 => /usr/lib/pipewire-0.3/jack/libjack.so.0 (0x00007f7e5080a000)

Bluetooth devices

PipeWire handles Bluetooth audio devices if the pipewire-pulse package is installed. More specifically, the media session daemon checks for /etc/pipewire/media-session.d/with-pulseaudio, and enables its bluez5 module automatically if the file exists.

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.

Troubleshooting

Microphone is not detected by PipeWire

PipeWire's alsa-monitor module uses alsa-card-profile to detect devices by default. If this isn't working for you, try to turn off api.alsa.use-acp, or optionally turn on api.alsa.use-ucm in /etc/pipewire/media-session.d/alsa-monitor.conf, under rules -> the first rule -> actions -> update-props:

...
update-props = {
    api.alsa.use-acp = false
...

Then, restart pipewire and check available devices:

$ pw-record --list-targets
Available targets ("*" denotes default): 62
	58: description="Built-in Audio" prio=1872
	60: description="Built-in Audio" prio=2000
*	62: description="Built-in Audio (Loopback PCM)" prio=1984

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 pactl set-default-sink to set the sink and pactl list sinks to list the available ones. 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 worked fine, but after a reboot, the volume was intolerably low.

Open alsamixer, use F6 to select the proper soundcard, and make sure the ALSA volumes are at 100%. alsactl 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

Increasing memlock from 64kB to 128kB seems enough to fix this. If you are running pipewire-pulse under systemd/User, add:

username	soft	memlock	64
username	hard	memlock	128

to /etc/security/limits.d/username.conf, and:

LimitMEMLOCK=131072

to pipewire-pulse.service.

Alternatively, install realtime-privileges and add your own user to the realtime group.

See also