Difference between revisions of "PipeWire"

From Alpine Linux
Jump to: navigation, search
m (Remove note about ardour not working)
m (Usage: pw-* commands have been moved to the pipewire-tools package)
 
(19 intermediate revisions by 7 users not shown)
Line 7: Line 7:
 
=== Audio Group ===
 
=== Audio Group ===
  
Add your normal user to the <code>audio</code> group. The user must log in for this to take effect.
+
When elogind is not available, the user has to be added to the <code>audio</code> group. The user must log in for this to take effect.
  
 
<pre>
 
<pre>
Line 22: Line 22:
 
# rc-update add dbus default
 
# rc-update add dbus default
 
</pre>
 
</pre>
 
{{Note|You may need to install dbus from the edge repository, but I'm not entirely sure.}}
 
  
 
Then use <code>dbus-launch</code> whenever you start an X or Wayland session. For example:
 
Then use <code>dbus-launch</code> whenever you start an X or Wayland session. For example:
 
<pre>
 
<pre>
 
$ dbus-launch --exit-with-session sway
 
$ dbus-launch --exit-with-session sway
 +
</pre>
 +
 +
=== XDG_RUNTIME_DIR ===
 +
 +
If you are not using a Desktop Manager, ensure that your <code>XDG_RUNTIME_DIR</code> is set to a user-writable location. By default for pulseaudio this is {{Path|/run/user/1000/}} or {{Path|/tmp}}. If this is not set, pipewire will create a directory in your home folder instead, called <code>~/pulse</code>, and on attempting to run Pavucontrol or pactl, you will get the following error:
 +
 +
<pre>
 +
$ pactl list
 +
Connection failure: Connection refused
 +
pa_context_connect() failed: Connection refused
 
</pre>
 
</pre>
  
 
== Installation and configuration ==
 
== Installation and configuration ==
  
Install <code>pipewire</code>. It might be a good idea to use the edge version because it's more up-to-date and PipeWire is still under development.
+
<pre>
 +
# apk add pipewire
 +
</pre>
 +
 
 +
Create custom configuration file in {{Path|/etc/pipewire/pipewire.conf}}:
 +
 
 +
<pre>
 +
# mkdir /etc/pipewire
 +
# cp /usr/share/pipewire/pipewire.conf /etc/pipewire/
 +
</pre>
 +
 
 +
Uncomment the following line in {{Path|/etc/pipewire/pipewire.conf}}:
 +
 
 +
<pre>
 +
{ path = "/usr/bin/pipewire-media-session"  args = "" }
 +
</pre>
 +
 
 +
Enable the <code>snd_seq</code> kernel module for ALSA support.
  
 
<pre>
 
<pre>
# apk add pipewire pipewire-doc
+
# modprobe snd_seq
 +
# echo snd_seq >> /etc/modules
 
</pre>
 
</pre>
  
=== Pulseaudio ===
+
=== ALSA ===
  
PipeWire can run a [https://www.freedesktop.org/wiki/Software/PulseAudio/ Pulseaudio] daemon which should allow all existing Pulseaudio applications to be used with the PipeWire backend.
+
If you use neither Jack nor PulseAudio and you don't intend to.
  
 
<pre>
 
<pre>
# apk add pipewire-pulse
+
# touch /etc/pipewire/media-session.d/with-alsa
 
</pre>
 
</pre>
  
To enable the Pulseaudio daemon edit <code>/etc/pipewire/pipewire.conf</code> and uncomment the following line:
+
=== PulseAudio ===
 +
 
 +
PipeWire can run a [https://www.freedesktop.org/wiki/Software/PulseAudio/ PulseAudio] daemon which should allow all existing PulseAudio applications to be used with the PipeWire backend.
  
 
<pre>
 
<pre>
exec /usr/bin/pipewire-pulse
+
# apk add pipewire-pulse
 
</pre>
 
</pre>
  
=== Jack ===
+
It should be automatically enabled.
  
If you will be using PipeWire for [https://jackaudio.org/ Jack] applications install the required package and make system wide links to the PipeWire replacement Jack libraries (I have not had success using <code>pw-jack</code>). You will not need to start a Jack server.
+
=== JACK ===
 +
 
 +
If you will be using PipeWire for [https://jackaudio.org/ JACK] applications install the required package and make system wide links to the PipeWire replacement JACK libraries (I have not had success using <code>pw-jack</code>). You will not need to start a JACK server.
  
 
<pre>
 
<pre>
Line 71: Line 101:
 
=== Screen sharing on Wayland ===
 
=== Screen sharing on Wayland ===
  
Not got this working yet. Take a look at [https://github.com/flatpak/xdg-desktop-portal xdg-desktop-portal].
+
You will need the right [https://github.com/flatpak/xdg-desktop-portal xdg-desktop-portal] backend for your desktop environment. Screen sharing is known to work on:
 +
* GNOME with <code>xdg-desktop-portal-gtk</code>
 +
* KDE Plasma with <code>xdg-desktop-portal-kde</code> and Firefox
 +
* Sway with <code>xdg-desktop-portal-wlr</code> and Firefox
  
 
== Usage ==
 
== Usage ==
Line 84: Line 117:
  
 
<pre>
 
<pre>
 +
# apk add pipewire-tools
 
$ pw-cat -p --list-targets
 
$ pw-cat -p --list-targets
 
</pre>
 
</pre>
Line 93: Line 127:
 
</pre>
 
</pre>
  
If you have a microphone test recording audio is working.
+
If you have a microphone test audio recording is working.
  
 
<pre>
 
<pre>
Line 102: Line 136:
 
</pre>
 
</pre>
  
Test Pulseaudio clients using a media player (most use Pulseaudio) and if you use Jack test that too:
+
Test PulseAudio clients using a media player (most use PulseAudio) and if you use JACK test that too:
  
 
<pre>
 
<pre>
Line 111: Line 145:
 
You should hear a sustained beep.
 
You should hear a sustained beep.
  
If you are happy everything is working, make pipewire start automatically when your X or Wayland session starts. For example, you could add the <code>pipewire</code> command to <code>~/.xinitrc</code> or your window manager's config file.
+
If you are happy everything is working, make PipeWire start automatically when your X or Wayland session starts. For example, you could add the <code>pipewire</code> command to <code>~/.xinitrc</code> or your window manager's config file.
  
 
== See Also ==
 
== See Also ==
Line 119: Line 153:
 
* [https://wiki.archlinux.org/index.php/PipeWire PipeWire on the ArchWiki]
 
* [https://wiki.archlinux.org/index.php/PipeWire PipeWire on the ArchWiki]
 
* [https://wiki.gentoo.org/wiki/Pipewire PipeWire on the Gentoo Wiki]
 
* [https://wiki.gentoo.org/wiki/Pipewire PipeWire on the Gentoo Wiki]
 +
 +
[[Category:Multimedia]]

Latest revision as of 15:24, 30 August 2021

Underconstruction clock icon gray.svg
This material is work-in-progress ...

The instructions below have not been thoroughly tested and may break things.
(Last edited by Govynnus on 30 Aug 2021.)

PipeWire is a multimedia processing engine that aims to improve audio and video handling on Linux.

Prerequisites

Audio Group

When elogind is not available, the user has to be added to the audio group. The user must log in for this to take effect.

# addgroup audio <user>

D-Bus

PipeWire requires a running D-Bus session. If you use a full desktop environment this will probably be started automatically, but with minimal window managers it must be done manually.

# apk add dbus dbus-openrc dbus-x11
# rc-service dbus start
# rc-update add dbus default

Then use dbus-launch whenever you start an X or Wayland session. For example:

$ dbus-launch --exit-with-session sway

XDG_RUNTIME_DIR

If you are not using a Desktop Manager, ensure that your XDG_RUNTIME_DIR is set to a user-writable location. By default for pulseaudio this is /run/user/1000/ or /tmp. If this is not set, pipewire will create a directory in your home folder instead, called ~/pulse, and on attempting to run Pavucontrol or pactl, you will get the following error:

$ pactl list
Connection failure: Connection refused
pa_context_connect() failed: Connection refused

Installation and configuration

# apk add pipewire

Create custom configuration file in /etc/pipewire/pipewire.conf:

# mkdir /etc/pipewire
# cp /usr/share/pipewire/pipewire.conf /etc/pipewire/

Uncomment the following line in /etc/pipewire/pipewire.conf:

{ path = "/usr/bin/pipewire-media-session"  args = "" }

Enable the snd_seq kernel module for ALSA support.

# modprobe snd_seq
# echo snd_seq >> /etc/modules

ALSA

If you use neither Jack nor PulseAudio and you don't intend to.

# touch /etc/pipewire/media-session.d/with-alsa

PulseAudio

PipeWire can run a PulseAudio daemon which should allow all existing PulseAudio applications to be used with the PipeWire backend.

# apk add pipewire-pulse

It should be automatically enabled.

JACK

If you will be using PipeWire for JACK applications install the required package and make system wide links to the PipeWire replacement JACK libraries (I have not had success using pw-jack). You will not need to start a JACK server.

# apk add pipewire-jack
# ln -sf /usr/lib/pipewire-0.3/jack/libjackserver.so.0 /usr/lib/libjackserver.so.0
# ln -sf /usr/lib/pipewire-0.3/jack/libjacknet.so.0 /usr/lib/libjacknet.so.0
# ln -sf /usr/lib/pipewire-0.3/jack/libjack.so.0 /usr/lib/libjack.so.0
Note: These symlinks might be overwritten during updates.

Video

Video should work out-of-the-box with v4l2 devices (e.g. a lot of webcams) and GStreamer applications.

Screen sharing on Wayland

You will need the right xdg-desktop-portal backend for your desktop environment. Screen sharing is known to work on:

  • GNOME with xdg-desktop-portal-gtk
  • KDE Plasma with xdg-desktop-portal-kde and Firefox
  • Sway with xdg-desktop-portal-wlr and Firefox

Usage

Start the PipeWire media server. You'll probably get quite a few errors but just ignore them for now.

$ pipewire

In a different terminal window check the default output device. I don't yet know how this default can be changed for all applications, so you'd better hope it's right!

# apk add pipewire-tools
$ pw-cat -p --list-targets

Test sound is working using an audio file in a format supported by libsndfile (e.g. flac, opus, ogg, wav).

$ pw-cat -p test.flac

If you have a microphone test audio recording is working.

$ pw-cat -r --list-targets
$ pw-cat -r recording.flac
(Speak for a while then stop it with Ctrl+c)
$ pw-cat -p recording.flac

Test PulseAudio clients using a media player (most use PulseAudio) and if you use JACK test that too:

# apk add jack-example-clients
$ jack_simple_client

You should hear a sustained beep.

If you are happy everything is working, make PipeWire start automatically when your X or Wayland session starts. For example, you could add the pipewire command to ~/.xinitrc or your window manager's config file.

See Also