How to Configure mpv to Use PipeWire on Linux?

Configuring the mpv media player to output audio directly through the PipeWire audio server improves playback efficiency, reduces latency, and ensures seamless audio routing on modern Linux distributions. While many modern Linux distributions handle this automatically via compatibility layers, explicitly defining the audio output driver in your mpv configuration file guarantees optimal native performance. This article provides a straightforward, step-by-step guide to verifying your PipeWire setup, modifying the mpv.conf file, and troubleshooting common audio issues.

Step 1: Verify PipeWire and PulseAudio-Pulse Installation

Before forcing mpv to use a specific audio backend, you need to ensure that PipeWire and its necessary audio emulation layers are running on your system. Most modern distributions (like Fedora, Ubuntu 22.04+, and Arch Linux) ship with PipeWire as the default, but it is best to verify.

Open your terminal and run the following command:

pactl info

Look at the Server Name line in the output. If it says something like PulseAudio (on PipeWire 1.x.x), your system is successfully using PipeWire with the PulseAudio compatibility layer.

Alternatively, you can check the status of the PipeWire systemd services:

systemctl --user status pipewire pipewire-pulse

Step 2: Configure mpv for PipeWire Output

mpv relies on a configuration file named mpv.conf to store user preferences. Depending on your desktop environment and how you installed mpv, you may need to create this file manually.

Locate or Create the Configuration File

The standard location for the mpv configuration file is within your user’s home directory. Open your terminal and create the directory and file using the following command:

mkdir -p ~/.config/mpv/
nano ~/.config/mpv/mpv.conf

Add the Audio Output Settings

To explicitly force mpv to use PipeWire, you have two main options depending on your preference for native PipeWire handling or using the stable PulseAudio compatibility layer.

Option A: Native PipeWire Output (Recommended for modern setups) Add the following line to your mpv.conf file:

ao=pipewire

Option B: PulseAudio Emulation Output If your specific build of mpv was not compiled with native PipeWire support, you can safely route it through the PulseAudio layer, which PipeWire intercepts perfectly:

ao=pulse

After adding your preferred line, save and exit the text editor (in Nano, press Ctrl+O, Enter, then Ctrl+X).

Step 3: Test and Verify the Configuration

To ensure that mpv is respecting your new configuration and routing audio correctly, launch a media file from the terminal by running:

mpv --v your-video-or-audio-file.mpk

Watch the terminal initialization text closely. Look for lines starting with [ao] or [ao/pipewire]. A successful configuration will display a line similar to:

[ao] Trying audio driver 'pipewire'
[ao/pipewire] Playback device 'default' opened successfully.

If you hear clear audio and see no fallback errors, your configuration is active and optimized.