This is a short, un-detailed howto of how to create your own internet station using the MPD music player daemon and icecast. There are some drawbacks with this solution, but since I have been an avid MPD user for a long time, this solution integrates nicely with what I am used to. Read on for complete instructions
Advantages:
- Integrates directly with MPD
- Quite customizable and very nice to control via an SSH shell.
Drawbacks:
- Ogg Vorbis is the only audio format supported as of now
- There is a bug when resuming playback that has been paused for a long time
Prerequisites
- Your favorite Linux distribution. On this current server I have gentoo, while my favorite is Ubuntu. Your choice!
- A good internet connection. Streaming music over a slow internet connection will probably halt your other traffic.
Software used:
- mpd, at least version 0.12.0
- icecast, I use version 2.3.1
- your favorite MPD client, I favour “ncmpc”
- a listener client, on Windows I use foobar2000 (you need ogg support for your player)
Let’s get started. Install all the above software on your computers, see the howto on the wiki for this.
Configure icecast. This can be a bit tricky and ther are many ways to fail in this step. You should:
- Set hostname (mine is stream.broach.se)
- Set the source password (the password that mpd will have to specify to be able to stream to the icecast server)
- Set the admin password.
Icecast can be a bit tricky to configure, especially since it uses an XML file. The configuration is probably located at /etc/icecast/icecast.xml.
You also need to choose whether to use burst-on-connect. I have turned burst-on-connect on to reduce latency between MPD and the listener client, and I have no problems with lag. Remember that I mostly sit on high-speed internet connections and therefore your situation and configuration might vary.
Now configure mpd. See the howto on the wiki again. I use quality 4.00, which gives a bitrate of a bit lower than 128, which is OK for web-radio. If you are an audiophile you should use 5.00 or more. Also set the correct password needed to connect to the icecast server. This is the source password you have typed in the icecast xml file. If everything seems OK, fire up icecast and then MPD.
My mpd.conf:
[sourcecode language="css"]music_directory “/var/music”
playlist_directory “/var/lib/mpd/playlists”
db_file “/var/lib/mpd/database”
log_file “/var/log/mpd.log”
error_file “/var/log/mpd.error.log”
pid_file “/var/run/mpd/mpd.pid”
audio_output {
type “shout”
name “Music stream”
host “localhost”
port “8000″
mount “/stream.ogg”
password “password”
quality “2″
user “source”
description “All kinds of music”
genre “Everything”
} # end of audio_output[/sourcecode]
Replace “user” and “password” with the information you specified in your icecast configuration.
Start icecast, then mpd, and then your mpd client to play some music. Now mpd streams music encoded as an Ogg Vorbis stream to icecast, which is now waiting for listeners. Goto another computer and start to listen to “http://your-server-adress:8000/stream.ogg.m3u”, which will be the name of the audio stream.
Everything should work now. If it doesn’t, you probably have a configuration issue. If the playback is skippy and it seems that MPD plays the file at wrong speed (ie. the timer seems to go very fast and jump a few seconds now and then), you have encountered the skipper bug. Restart MPD and resume playback. I don’t have another solution to this bug yet, but luckily it only occurs when you haven’t played any music for a few minutes. Prevent it to happen by always have a song in your MPD playlist. This bug was solved by upgrading libshout from 2.0 to 2.1. Thanks to the guys in the #mpd IRC channel for this!
Wishlist:
- A configuration option for MPD that sends a silent audio stream when the music is offline or paused. This prevents the skipper bug, and allows all clients to be connected even though you pause the music. You won’t have to reconnect again when starting to play, because there always has been a connection
- Reverse proxy support for icecast. I have the icecast server located behind my router, and the generated URL is invalid because port 80 on the webserver is routed to the icecast server for the domain “stream.broach.se”, but not “etnoy.broach.se” and “www.broach.se”. Therefore I need to manually change the source code to make this work. I resolved this problem by manually adding a stream.ogg.m3u file to the web directory containing the correct URL for the strem. Hackish, but it works well.
Report any problems by commenting on this blog entry, or ask me a question by e-mail.
Updated 06/07 2006
Updated 11/01 2006
Updated 11/03 2006
Updated 07/01 2007