From ArchWiki
Revision as of 14:37, 7 August 2010 by CptNeutral (talk | contribs) (moved Streaming With Icecast and MPD to Streaming With Icecast: A more generic page covering not just mpd)
Jump to: navigation, search

MPD is a program for playing music via a daemon process instead of using a client. It also incorporates a music database for quick access, playlists, and a variety of frontend options.

Step 1: Set Up MPD and Install a Client

Use the MPD Install Guide to install and configure MPD and a client.

Step 2: Setting up Icecast

  • Install Icecast via Pacman
 # pacman -S icecast
  • Edit the configuration file.

Open up /etc/icecast.xml in your text editor. The main section you want to pay attention to is <authentication>. Inside the <authentication> block are all the passwords that icecast use. I STRONGLY RECOMMEND you change them.
Icecast defaults to listening on port 8000, and you may also change that if you wish.

You will also want to uncomment the changeowner lines to switch to a user and group without root privileges. Remember to enable the chroot section:


The default log path, /var/log/icecast, is not created automatically, so you will need to either create that folder and chown to the user in the changeowner lines, change the log path, or disable logging. Be aware that by turning changeowner on, all paths are relative to the home directory of that user. You will have to edit all paths manually. A good choice might be to create a new user "icecast" and set its home directory to /usr/share/icecast. Create there a directory "log" and don't forget to give the ownership to icecast.

Afterwards change the paths section to the following:


Note that if you're running icecast under a local user (i.e. one that doesn't use /etc/icecast.xml) then you'll need to copy the icecast web xml files from /usr/share otherwise you'll get errors about xslt and the web interface won't work.

$ cp -R /usr/share/icecast/web ~/icecast/
  • Start icecast

You can start icecast by executing:

 # icecast -b -c /etc/icecast.xml
  • Test it.

Make sure Icecast is running by opening up http://localhost:8000/ in your web browser. You should be greeted by an Icecast2 Status page. This indicates everything is running properly.

Step 3: Configure MPD to be an Icecast Source

Edit /etc/mpd.conf and enable the Icecast audio_output by adding the following:

audio_output {
    type        "shout"
    encoding    "ogg"
    name        "my cool stream"
    host        "localhost"
    port        "8000"
    mount       "/mpd.ogg"

# This is the source password in icecast.xml
    password    "hackme"

# Set either quality or bitrate
#   quality     "5.0"
    bitrate     "64"

    format      "44100:16:1"

# Optional Paramters
    user        "source"
#   description "here's my long description"
#   genre       "jazz"
} # end of audio_output

# Need this so that mpd still works if icecast is not running
audio_output {
    type "alsa"
    name "fake out"
    driver "null"

Step 4: Running MPD with Icecast

You can run both MPD and Icecast with the rc.d scripts:

# /etc/rc.d/icecast start
# /etc/rc.d/mpd start

Note that icecast must be started first for the stream to work.

Step 5: Test / use the stream

Now that you have installed the necessary software you probably want to test/use the stream. Realize that you'll need your client to do two things:

  1. Connect to the mpd server so you can control it
  2. Connect to the stream to actually hear the music. Connecting to the mpd server will alter output to the Icecast server but you won't hear it.

Sonata (a graphical mpd client) and mplayer (a command line client) are just two of the available clients. Note that if you use mplayer, you'll need another way to control the remote mpd server (for example ssh)


  • Install Sonata:
# pacman -S sonata
  • Start it up and you should be greeted by Sonata's preferences.
  • Set 'Name' to the name of your server.
  • Set 'Host' to the IP address of your server.
  • Set 'Port' to '6600'.
  • Click the '+' and repeat the previous steps but instead about your local computer (ie. it's name and IP).
  • Right-click->'Connections' and select your server. Then click on the 'Library' tab, if all is well, you should see your entire music selection that's on your server. Find a folder, right-click and click 'Add'. Clicking on the 'Current' tab will show you your current playlist, which should have the contents of whatever folder you just chose from the library. Double-click on a song. You should see the text get bold and the progress bar show up, just like it's playing, but you won't hear anything. Fear not.
  • Right-click->'Connections' and select your local computer. Then click the 'Streams' tab. Right-click and click 'New'. Make 'Stream Name' the name from your servers /etc/mpd.conf file's audio_output { } section and make the URL IP.of.server:8000/mpd.ogg.m3u. Double-click on this stream.
  • Click on the 'Current' tab and you'll see the URL of the stream as your only item. Double-click on it and after a delay you should hear whatever song you had chosen on the server.


  • Install mplayer
# pacman -S mplayer
  • Start it, telling it to play the playlist that icecast places in the icecast root directory (the playlist redirects mplayer to mpd.ogg)
$ mplayer -playlist http://ip.of.server:8000/mpd.ogg.m3u

To control the remote mpd server, if you have an ssh server on the same machine, you can login and use [nc]mpc[pp] to control it.

Or, if your mpd server is listening on an accessible interface/port (netstat -tnlp on the mpd machine will show mpd listening on, for example) then you can set the MPD_HOST variable which directs a local client like mpc to the remote server.

$ export MPD_HOST=ip.of.server
$ export MPD_PORT=6600      # optional
$ mpc play

Streaming Single Files Using oggfwd and ffmpeg2theora

If you want to stream a single track, for example, you can use this method instead of changing your mpd setup.

  • Install ffmpeg2theora and oggfwd from AUR.
# yaourt -S ffmpeg2theora oggfwd
  • Start icecast using a previously setup config file
$ icecast -c path/to/config.xml
  • Start ffmpeg2theora, sending its output to oggfwd, which forwards to the icecast server for you.
$ ffmpeg2theora --no-skeleton --novideo -o - path/to/audio/file | \
  oggfwd localhost 8000 source_password_here /mountpoint_name_here.ogg

Alternatively, you can use this script:


if [ $# -eq 1 ] 
  echo "Usage: $0 music-file"
  exit 1


set -e
ffmpeg2theora --no-skeleton --novideo -o - "$music" 2> /dev/null | \ 
  oggfwd localhost 8000 "$pass" /"$mountpt".ogg