Using Icecast2 and IceGenerator to create MP3 radio stream on Debian 6 & 7

This is a quick and easy way to create your own internet radio stream. By using two bits of lightweight software and MP3 files on your server, you will be able to create a stream that can be accessed from anywhere in the world. We will be using Icecast2 and IceGenerator to feed a playlist of MP3s to Icecast.

First install icecast2.

apt-get update
apt-get install icecast2

Icecast should now display a warning that you must edit a file before it will start working. We can fix this up after we have set the passwords for icecast

sudo nano /etc/icecast2/icecast.xml

You can go through and edit this as you wish. There are two main areas that are essential, though most can be left alone.

  • Change all the passwords under <authentication> – source, relay and admin.
  • You then need to change the mountpoint under <shoutcast-mount> to your personal preference.<shoutcast-mount>/radiostream.mp3</shoutcast-mount> for instance would allow you to access your radio stream from your URL:8000/radiostream.mp3. Note the.mp3 extension for mount points is not required. You can also change the default port from 8000 if you wish to do so.

Now that we have changed the passwords and Icecast is secure, let’s fix that warning message we received when installing it.

sudo nano /etc/default/icecast2

Go right down to the bottom and replace ENABLE=false with ENABLE=true

Now we can start Icecast

sudo /etc/init.d/icecast2 start

Now go to your URL:8000 or IP:8000 in a web browser to ensure that the Icecast web interface is working.

Now we install IceGenerator to feed Icecast the MP3 file playlist.

wget http://www.becrux.com/pages/projects/icegenerator/icegenerator-0.5.5-pre2.tar.gz
tar -xzvf icegenerator*
cd icegenerator*
sudo ./configure
sudo make
sudo make install

A configuration file needs to be created. Use nano to create config.txt in your home folder/icegenerator directory and paste in the following config file example.

cd $home
mkdir icegenerator
cd icegenerator
nano config.txt

NAME=Name of Streaming Server

IP=127.0.0.1
PORT=8000
# 2 – Icecast 2.0 (HTTP protocol compatible)
SERVER=2
SOURCE=source
PASSWORD=passwordofsource
FORMAT=1
RECURSIVE=1
DUMPFILE=
LOOP=1
SHUFFLE=1
BITRATE=48000
PUBLIC=0
METAUPDATE=5
MDFPATH=/myhomefolder/icecast/global.mdf
LOG=2
LOGPATH=/myhomefolder/icecast/icegenerator.log
DATAPORT=8796

#######################################################

MOUNT=/radiostream

MP3PATH=m3u:/myhomefolder/icecast/music.m3u

GENRE=Type of Music

DESCRIPTION=Radio Description

URL=http://MyURL:8000/radiostream

Now enter the following command

find /path/to/mp3s/ | grep .mp3 > music.m3u

OR alternatively in the above configuration file set

MP3PATH=pth://path/to/mp3s

That’s it!

Run the following (note you may need to use sudo)

icegenerator -f /pathtohomefolder/icegenerator/config.txt

You should now be able to use your web browser/media device/software such as VLC to access your stream at http://yourURL:8000/radiostream

Common problems (if things don’t work)

  • Check all your paths in the IceGenerator config.txt to see that the files they are referencing are in the right place
  • Ensure the ‘source’ password in the IceGenerator config.txt match the one that was set in the Icecast configuration file
  • Check the logfile for IceGenerator (location set in IceGenerator config.txt)

The following tutorials/information provided inspiration and example configuration files and can be used for further reference