MPD

From Gentoo Wiki
Jump to:navigation Jump to:search
Resources
#mpd (webchat )(registration required)
Ohloh LogoOpen Hub

MPD (Music Player Daemon) is a flexible, server-side application for playing music. Through plugins and libraries it can play a variety of sound files while being controlled by a network protocol.

Installation

USE flags

USE flags for media-sound/mpd The Music Player Daemon (mpd)

+alsa Add support for media-libs/alsa-lib (Advanced Linux Sound Architecture)
+curl Enable web stream listening support via net-misc/curl
+dbus Enable dbus support for anything that needs it (gpsd, gnomemeeting, etc)
+eventfd Use the eventfd function in MPD's event loop
+ffmpeg Enable ffmpeg/libav-based audio/video codec support
+icu Enable ICU (Internationalization Components for Unicode) support, using dev-libs/icu
+id3tag Enable support for ID3 tags via media-libs/libid3tag
+inotify Use the Linux kernel inotify subsystem to notice changes to mpd music library
+io-uring Enable the use of io_uring for efficient asynchronous IO and system requests
+mpg123 Enable support for mp3 decoding over media-sound/mpg123
ao Use libao audio output library for sound playback
audiofile Add support for libaudiofile where applicable
bzip2 Enable bzip2 compression support
cdio Enable ISO9660 parsing via dev-libs/libcdio-paranoia
chromaprint Enable ChromaPrint / AcoustID support
doc Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally
expat Enable the use of dev-libs/expat for XML parsing
faad Use media-libs/faad2 for AAC decoding
flac Add support for FLAC: Free Lossless Audio Codec
fluidsynth Enable MIDI support with media-sound/fluidsynth (discouraged)
gme Enable video game music formats support via media-libs/game-music-emu
httpd Enable built-in stream server
jack Add support for the JACK Audio Connection Kit
lame Support for MP3 streaming via Icecast2
libmpdclient Enable support for remote mpd databases
libsamplerate Build with support for converting sample rates using libsamplerate
libsoxr Enable resampling with media-libs/soxr
mad Add support for mad (high-quality mp3 decoder library and cli frontend)
mikmod Add libmikmod support to allow playing of SoundTracker-style music files
mms Support for Microsoft Media Server (MMS) streams
modplug Add libmodplug support for playing SoundTracker-style music files
musepack Enable support for the musepack audio codec
nfs Enable support for the Network File System
openal Add support for the Open Audio Library
openmpt OpenMPT decoder plugin
opus Enable Opus audio codec support
oss Add support for OSS (Open Sound System)
pipewire Enable support for PipeWire audio backend
pulseaudio Add sound server support via media-libs/libpulse (may be PulseAudio or PipeWire)
qobuz Build plugin to access qobuz
recorder Enables output plugin for recording radio streams
samba Add support for SAMBA (Windows File and Printer sharing)
selinux !!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur
shout Enable ShoutCast/IceCast plugin using media-libs/libshout
sid Enable SID (Commodore 64 audio) file support
signalfd Use the signalfd function in MPD's event loop
snapcast Snapcast audio plugin
sndfile Add support for libsndfile
sndio Enable support for the media-sound/sndio backend
sqlite Add support for sqlite - embedded sql database
systemd Enable support for systemd socket activation
test Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)
tremor Enable support for media-libs/tremor, a fixed-point version of the Ogg Vorbis decoder
twolame Enable MP2 encoding via media-sound/twolame
upnp Enable UPnP port mapping support
vorbis Add support for the OggVorbis audio codec
wav Support WAV encoding
wavpack Add support for wavpack audio compression tools
webdav Enable using music from a WebDAV share
wildmidi Enable MIDI support via media-sound/wildmidi
zeroconf Support for DNS Service Discovery (DNS-SD)
zip Enable support for ZIP archives
zlib Enable database compression with virtual/zlib
Data provided by the Gentoo Package Database · Last update: 2026年07月20日 03:59 More information about USE flags
Note
A number of these flags are set by the desktop profile.

Emerge

root #emerge --ask media-sound/mpd

Configuration

After installation, MPD should work "out of the box", via Gentoo's default configuration.

A list of supported features/plugins can be obtained by running:

user $mpd --version

MPD can be configured system-wide or per-user, depending on the intended usage.

System-wide configuration

Basic configuration

An example of a simple configuration:

FILE /etc/mpd.conf
music_directory "/var/lib/mpd/music"
playlist_directory "/var/lib/mpd/playlists"
db_file "/var/lib/mpd/database"
log_file "/var/lib/mpd/log"
state_file "/var/lib/mpd/state"
user "mpd"
bind_to_address "localhost"
bind_to_address "/var/lib/mpd/socket"
input {
 plugin "curl"
}
audio_output {
 type "alsa"
 name "default"
 mixer_type "software"
}

With this configuration, MPD should be able to run as a system daemon under the mpd user, which is the default setting.

Per-user configuration

Basic configuration

Copy /etc/mpd.conf to ${XDG_CONFIG_HOME}/mpd/mpd.conf, then modify the latter as appropriate.

Sample configuration using PulseAudio output:

FILE ${XDG_CONFIG_HOME}/mpd/mpd.conf
# Recommended location for database
db_file "~/.mpd/database"
# Input
input {
 plugin "curl"
}
# PulseAudio output
audio_output {
 type "pulse"
 name "Pulse Audio"
}

Now it should be possible to start MPD simply by running:

user $mpd

PipeWire (optional)

If MPD was built with the pipewire USE flag), add a dedicated audio_output section to ${XDG_CONFIG_HOME}/mpd/mpd.conf:

FILE /etc/mpd.conf
audio_output {
 type "pipewire"
 name "Pipewire Output"
}
Note
PipeWire will not let an MPD system daemon access a user-level pipewire socket, so this option should only be used if running MPD as a user-level daemon.

General configuration

PulseAudio (optional)

If MPD was built with the pulseaudio USE flag, a dedicated audio_output section can be added to the configuration file:

CODE
audio_output {
 type "pulse"
 name "Pulse Output"
 mixer_control "Master"
}
Note
If running PipeWire with libpulse, this option will allow a system-level MPD daemon to access the user-level PipeWire server if one of the TCP options is enabled in the PipeWire configuration, as described on the "PipeWire" page.

HTTP streaming server (optional)

If MPD was built with the httpd USE flag, a dedicated audio_output section can be added to the configuration file:

CODE
audio_output { 
 type "httpd"
 name "HTTP Stream" 
 encoder "vorbis" # optional, vorbis(OGG) or lame(MP3)
 port "8000"
 bitrate "192" # do not define if quality is defined 
 format "44100:16:1"
}
bind_to_address "0.0.0.0"

Binding to 0.0.0.0 enables streaming on all discovered local IP interfaces; binding to a specific IP address such as 192.168.1.2 will enable streaming via only that IP.

Note
Some players require specifying the file format in the URL to be able to connect to the stream, e.g. http://192.168.1.2:8000/mpd.ogg .

Bluetooth headset (optional)

To set up a Bluetooth headset, first follow the Bluetooth headset page.

Pure ALSA setup

For Bluetooth support on a pure ALSA setup, add an ALSA configuration file (e.g. /etc/asound.conf or ${HOME}/.asoundrc for a system-wide or per-user configuration, respectively) to allow MPD to control the volume of the headset, changing the values of the interface and device settings as appropriate:

CODE
# Specify the parameters of the Bluetooth connection
defaults.bluealsa {
 interface "hci0" # Host Bluetooth adapter
 device "XX:XX:XX:XX:XX:XX" # Bluetooth headset MAC address
 profile "a2dp"
}

To be able to switch between the Bluetooth headset and the default sound card, add the following to the audio_output section in the MPD configuration file:

CODE
audio_output {
 type "alsa"
 name "My ALSA Device"
}
audio_output {
 type "alsa"
 name "ALSA Bluetooth Headset"
 device "bluealsa"
 mixer_type "software"
}
Tip
MPD might crash when switching output while playing - if so, pause before switching.

If trying to play AAC or other files results in an error such as:

user $mpd --no-daemon --stderr
...
alsa_output: Failed to open "My ALSA Device" [alsa]: Error opening ALSA device "bluealsa" (snd_pcm_hw_params): Invalid argument
...

then add the following line to the relevant section of the relevant MPD configuration file:

CODE
format "44100:16:2"

FIFO (optional)

Use the following to set up a fifo(7) for ncmpcpp's visualiser plugin, modifying the values of the name and path variables as appropriate:

CODE
audio_output {
 type "fifo"
 name "mpdFIFO"
 path "/tmp/mpd.fifo"
 enabled "yes"
 format "44100:16:2"
}

Services

Note
If the system's cron program supports @reboot, it's possible to create a cron job to start MPD at boot, rather than using an init script.

System-wide service

OpenRC

To start MPD:

root #rc-service mpd start

To start MPD at boot, add it the default runlevel:

root #rc-update add mpd default

systemd

To start MPD immediately:

root #systemctl start mpd

To start MPD at boot:

root #systemctl enable mpd

Per-user service

systemd

It is possible to leverage systemd user services to control MPD per-user.

To activate MPD, start the systemd socket:

user $systemctl --user enable --now mpd.socket

Clients

  Note to editors - Adding to or modifying this list
When adding to lists, please follow these conventions:
  • For the name field, use upstream's formatting/styling, including capitalization. If the software has a page on this wiki, make the name a link to that page using the Link template; otherwise, make the name a link to the project's home page.
  • For the description field, use the package description or, if unavailable, upstream's summary description of the software.
  • Do not add subjective information (e.g. "Best client for...") to the package or upstream description; add objective information (e.g. "for Emacs") only where necessary.

Packaged for Gentoo

Name Package Toolkit Description
ampc app-emacs/ampc::gnu-elpa Other Asynchronous Music Player Controller [for Emacs]
Ario media-sound/ario GTK GTK client for MPD inspired by Rhythmbox but much lighter and faster
Cantata media-sound/cantata Qt Featureful and configurable Qt client for the music player daemon (MPD)
Gimmix media-sound/gimmix GTK Graphical music player daemon (MPD) client using GTK+2
Glurp media-sound/glurp GTK GTK2 based graphical client for the Music Player Daemon
MPC media-sound/mpc CLI/TUI Commandline client for Music Player Daemon (media-sound/mpd)
ncmpc media-sound/ncmpc CLI/TUI Ncurses client for the Music Player Daemon (MPD)]
ncmpcpp media-sound/ncmpcpp CLI/TUI An ncurses mpd client, ncmpc clone with some new features, written in C++]
PMS media-sound/pms CLI/TUI Practical Music Search: open source ncurses client for mpd, written in C++
Quimup media-sound/quimup Qt Qt client for the music player daemon (MPD)
Rusty Music Player Client media-sound/rmpc::guru CLI/TUI Beautiful and configurable TUI client for MPD
Sonata media-sound/sonata GTK Elegant GTK+ music client for the Music Player Daemon (MPD)
vimpc media-sound/vimpc CLI/TUI ncurses based mpd client with vi-like key bindings
wmmp x11-plugins/wmmp Other Window Maker dock app client for mpd (Music Player Daemon)
xfmpc media-sound/xfmpc GTK Music Player Daemon (MPD) client for the Xfce desktop environment
ympd media-sound/ympd::bgo-overlay Web Standalone MPD Web GUI written in C, utilizing Websockets and Bootstrap/JS

Not yet packaged for Gentoo

Name Toolkit Description
clerk CLI/TUI mpd client, based on rofi/fzf
vimus CLI/TUI MPD client with vim-like key bindings

The MPD site also provides a sorted list of MPD clients.

Scrobblers

Scrobblers are clients that submit to Audioscrobbler — compatible services (eg. libre.fm or last.fm)

Troubleshooting

For general troubleshooting refer to the MPD user manual troubleshooting section

No Audio from PulseAudio

Running MPD as a system service under the mpd user causes permissions issues. Change the user in mpd.conf to the appropriate user:

FILE /etc/mpd.conf
user "larry"

See also

  • Snapcast — a multiroom client-server audio player, where all clients are time synchronized with the server to play perfectly synced audio. Can be configured as a 'frontend' to MPD.
  • Upmpdcli — a free and open source UPnP media renderer front-end for Music Player Daemon (MPD).

External resources