Category Archives: Apps

Streaming Music with Icecast and Musicpd

Date published: January 3rd, 2008
Posted in Apps, RootBSD | No Comments ยป

Streaming music on FreeBSD can be very easy with the right applications. I will be outlining how to stream music using the Music Player Daemon and Icecast.

Unfortunately for some reason the Music Player Daemon (mpd henceforth) is set up to not compile with support for libshout which is needed for it to play with Icecast. Luckily as long as you have libshout (/usr/ports/audio/libshout) installed getting mpd to install with support for it is fairly simple. Navigate to /usr/ports/audio/musicpd and open up the Makefile in your favorite editor. Somewhere around line 40 should be a line that reads ‘CONFIGURE_ARGS= –disable-shout’, change this to read ‘CONFIGURE_ARGS= –enable-shout’ and it should compile just fine. Why this option is explicately disabled I do not know but hopefully it will be fixed in the near future. If you go poking around in the Makefile and aren’t able to fine the line to change they may have already fixed it.

Anyway, install musicpd now followed by Icecast (/usr/ports/audio/icecast2). I also installed phpMp, a web interface for mpd to manage the stream and playlists. It can be found in /usr/ports/www/phpmp. After everything is installed go to /usr/local/etc/ to do the configuring. Along with this post are two example configuration files, mpd.cond and icecast.xml for their respective applications. In my mpd.conf I have created a user to place all the required files under. If you use the web interface this users home directory will really only have a database file used by mpd in it along with a log. If you wanted you could create a public_html for the user and run phpMp out of it. In the configuration file for mpd you will need to update the paths if they are different, the stream name if you so desire, and connection information for Icecast (host, port, password). The password and other connection details you choose should be specified the same in icecast.conf. Working from the top down in icecast.xml you should first change/specify the source and relay passwords under authentication (the one used for mpd should also be used here), the administrative username and password, the hostname for the server, and the port to run on. Unless you need to change logging information the rest should be alright.

Edit /etc/rc.conf and add the lines ‘icecast_enable=”YES”‘ and ‘musicpd_enable=”YES”‘. Then do ‘/usr/local/etc/rc.d/icecast start’ followed by ‘/usr/local/etc/rc.d/musicpd start’. If Icecast started correctly you should be able to load the status page at http://hostname:portnumber. Once you have verified that Icecast is running correctly test mpd by executing ‘mpc add <some>’ and then loading /stream.ogg from Icecast. If you can hear the music playing then congratulations, you have properly set up Icecast and musicpd.Musicpd Configuration
Icecast Configuration