Advertisement

You are here: Home > Irc > Icecast


How to install IceCast

  • wget http://downloads.xiph.org/releases/icecast/icecast-2.4.1.tar.gz
  • tar -zxvf icecast-2.4.1.tar.gz
  • cd icecast-2.4.1
  • ./configure
  • make
  • make install
This command installs the compiled software in the appropriate place on your system. To check this has all gone well type the following:
  • icecast
This is the command that starts your newly installed Icecast2 server..

Complete install and configuration guide!

Creating your own internet radio station isn�t very hard. There is a nice software called Icecast which can do it for you. Icecast was designed to stream any audio file if a appropiate streaming client is available. For OGG/Vorbis you can use ices and for MP3 icegenerator. Here is a small tutorial how to setup Icecast for streaming OGG/Vorbis and MP3. I am using Slackware Linux again.
This article contains the following topics:

Setting up the server: Icecast
Setting up the OGG/Vorbis streaming client: ices
Setting up the MP3 streaming client: icegenerator

Setting up the server: Icecast

First get the software:

# mkdir -p /usr/src/icecast
# cd /usr/src/icecast
# wget http://downloads.xiph.org/releases/icecast/icecast-2.4.1.tar.gz

Next extract the sources and change into the new driectory:

# tar xf icecast-2.4.1.tar.gz
# cd icecast-2.4.1

Then configure the sources:

# ./configure �prefix=/opt/icecast/2.4.1

And finally compile the sources and install the binaries:

# make

# make install

You should have now the icecast binary under /opt/icecast/2.3.2/latest/bin:

# ls /opt/icecast/2.4.1/bin/
icecast*

Now go into the icecast directory and link the 2.3.2 directory to latest:

# cd /opt/icecast
# ln -s 2.4.1 latest

Now configure icecast by editing the icecast.xml file. First move the orignal sample file to an alternate place:

# cd /opt/icecast/latest/etc
# mv icecast.xml icecast.xml.orig
# vi icecast.xml


10
10
5 524288
30
15 10
1
65535

Its�atrap!
icecast
Its�anothertrap!

dc01
8000 1


/opt/icecast/latest/share/icecast
/opt/icecast/latest/share/icecast/web
/opt/icecast/latest/share/icecast/admin
/var/log/icecast
/var/run/icecast/icecast.pid

access.log
error.log
playlist.log 1
10000
1

0

icecast
icecast
The above icecast.xml is very simple. The first section LIMITS defines how many radio stations you maximum want to provide (sources=10), how many clients may connect (clients=10) etc. The second section GENERIC defines a username, hostname (dc01), port (8000) for the server itself etc. The section PATHES defines the pathes to the webgui. Icecast has a small and simple webgui to see what is going on and this section defines where to find the web documents. The LOGGING section is of course for logging, where and what to log etc. The SECURITY section defines that the Icecast software itself should run under the user icecast and the group icecast.
Now we need three more things to do: create a user and a group called icecast as defined in the icecast.xml configuration file, create the place for the logs and a place for the pid file. First create the icecast user with the ID 200 and the group icecast with the ID 200:

# groupadd -g 200 icecast
# useradd -d /var/log/icecast -m -g icecast -s /bin/bash -u 200 icecast

With the -m option set the directory for the logs was automatically created and the second step can be spared. Only the directory for the pid file is now needed:

# mkdir -p /var/run/icecast
# chown -R icecast:icecast /var/run/icecast

Now give it a try and start the icecast server:

# /opt/icecast/latest/bin/icecast -c /opt/icecast/latest/etc/icecast.xml -b
Starting icecast2
Detaching from the console
Changed groupid to 200.
Changed userid to 200.

Your server is now running as your icecast user and logs will be produced under /var/log/icecast:

# ls /var/log/icecast/
access.log error.log playlist.log

Check that it is really running:

# pgrep -fl icecast
4434 /opt/icecast/latest/bin/icecast -c /opt/icecast/latest/etc/icecast.xml -b

Also the icecast server should be reachable via webgui under your given hostname and port, in my case http://dc01:8000/, when you have setup one or more stations they will show up here. The user for the administrative webgui is defined in the icecast.xml file above � icecast. The password in this case is It�sanothertrap!.

Setting up the OGG/Vorbis streaming client: ices

Before you can compile ices you need the libshout library. First download it:

# cd /usr/src/icecast
# wget http://downloads.us.xiph.org/releases/libshout/libshout-2.2.2.tar.gz

Then extract the tar file and change into the new directory:

# tar xf libshout-2.2.2.tar.gz
# cd libshout-2.2.2

Run the configure script:

# ./configure �prefix=/opt/icecast/latest

And compile the sources and install the library:

# make

# make install

Now download the ices client:

# cd /usr/src/icecast
# wget http://downloads.us.xiph.org/releases/ices/ices-2.0.1.tar.bz2

Extract the tar file and change into the new directory:

# tar xf ices-2.0.1.tar.bz2
# cd ices-2.0.1/

Before you run the configure script, export the PKG_CONFIG_PATH variable so ices will be able to include the libshout library:

# export PKG_CONFIG_PATH=/opt/icecast/latest/lib/pkgconfig:$PKG_CONFIG_PATH
# ./configure �prefix=/opt/icecast/latest

Now compile the sources and install the binaries:

# make

# make install

Check that the ices client is available:

# ls /opt/icecast/latest/bin/
icecast* ices*

Finally configure the ices client and create your first OGG/Vorbis radio station:

# cd /opt/icecast/latest
# vi ices1.xml


1
/var/run/icecast/ices1.pid


/var/log/icecast
ices1.log
2048
3
0

Testradio: One
Varios
Local Test Radio

http://dc01:8000/


basic/opt/icecast/latest/etc/playlist1.txt101

dc01
8000 It�satrap! /one.ogg
The ices configuration file is as easy as the icecast configuration file. The section GENERIC defines to run ices in background and where the pid file can be found. The section LOGGING is all about logging, where and what to log. The STREAM section needs a little more attention. It defines the radio station itself like the name of the station, where the icecast server can be reached etc. The password is the source password from the icecast configuration file. If you don�t set a password here everybody can connect to your icecast server and create a station. One more thing: the playlist. The playlist is a plain text file and contains all your songs you want to play. Every OGG/Vorbis file inside this file must have the full path, eg:

# cd /opt/latest/etc
# vi playlist1.txt
/export/music/artist/album/song1.ogg
/export/music/artist/album/song2.ogg

You can create this list easily with find:

# find /export/music -name �*.ogg� > /opt/icecast/latest/etc/playlist1.txt

With the ices configuration file and the playlist created, start up ices as user icecast:

# su � icecast -c �/opt/icecast/latest/bin/ices /opt/icecast/latest/etc/ices1.xml�

Now take a look into the log file:

# cat /var/log/icecast/ices1.log
[2011-12-16 12:17:05] INFO signals/signal_usr1_handler Metadata update requested
[2011-12-16 12:17:05] INFO playlist-basic/playlist_basic_get_next_filename Loading playlist from file �/opt/icecast/latest/etc/playlist1.txt�
[2011-12-16 12:17:05] INFO playlist-builtin/playlist_read Currently playing �/export/music/artist/album/song2.ogg�
[2011-12-16 12:17:05] INFO stream/ices_instance_stream Connected to server: dc01:8000/one.ogg

As you can see the first radio station is ready and available under http://dc01:8000/one.ogg. Now try to connect to your streaming server with an audio client and enjoy listening to your radio:

$ ogg123 http://dc01:8000/one.ogg
Audio Device: Advanced Linux Sound Architecture (ALSA) output
Playing: http://dc01:8000/one.ogg
Ogg Vorbis stream: 2 channel, 44100 Hz
Album: album
Artist: artist
Description:
Genre:
Title: song2.ogg

For each radio station you want to provide you need to create a single ices configuration file with it�s own playlist etc. Eg. you can create a seperate radio station for your Rock music and a seperate radio station for your Pop music.

Setting up the MP3 streaming client: icegenerator

To stream MP3 files you need a streaming client like icegenerator. Before you can compile icegenerator you have to install libshout first (if not done already):

# cd /usr/src/icecast
# wget http://downloads.us.xiph.org/releases/libshout/libshout-2.2.2.tar.gz

Then extract the tar file and change into the new directory:

# tar xf libshout-2.2.2.tar.gz
# cd libshout-2.2.2

Run the configure script:

# ./configure �prefix=/opt/icecast/latest

And compile the sources and install the library:

# make

# make install

To compile icegenerator downlod the source package from http://sourceforge.net/projects/icegenerator/ and store it in your src directory. Then go into the src directory and extract the source:

# cd /usr/src/icecast
# tar xfz icegenerator-0.5.5-pre2.tar.gz
# cd icegenerator-0.5.5-pre2

Now run the configure script (the �prefix option will be ignored, just run the configure script without the �prefix option):

# ./configure

And compile the sources and install the binaries:

# make

# make install

Check that icegenerator is available:

# ls -lah /usr/local/bin/ice*
-rwxr-xr-x 1 root root 55K 2011-12-16 12:41 /usr/local/bin/icegenerator*

Now configure icegeneratori and create your first MP3 radio station:

# cd /usr/local/etc
# vi icegen1.cfg
IP=192.168.1.73
PORT=8000
SERVER=2
MOUNT=/two.mp3
PASSWORD=It�satrap!
FORMAT=1
MP3PATH=m3u:/usr/local/etc/playlist2.m3u
LOOP=1
SHUFFLE=1
NAME=Testradio: Two
DESCRIPTION=Local Test Radio
GENRE=Varios
URL=http://dc01:8000/
LOG=2
LOGPATH=/var/log/icecast/icegen1.log
BITRATE=48000
SOURCE=icecast

The configuration file is a bit more complicated than the ices configuration file. At first you to define the IP and port for your Icecast server (in my case dc01, which is 192.168.1.73). The SERVER option is for the icy or http protocol, here it is http. MOUNT and PASSWORD are same as the OGG/Vorbis station, where to reach the station itself (http://dc01:8000/two.mp3) and how to authenticate. The FORMAT option is for either streaming MP3i (1) or OGG/Vorbis (0). LOOP and SHUFFLE for looping the playlist and randomized plaing. NAME, DESCRIPTION and GENRE will describe your radio. MP3PATH defines which files to stream, in this case all from a m3u compatible playlist (created later). URL tells where to reach the streaming server or any other address. This address will maybe displayed by your player. Specifiy LOG and LOGPATH for logging. The BITRATE defines the streaming quality and the last option SOURCE is the username for the icecast server.
Next create the playlist:

# vi /usr/local/etc/playlist2.m3u
/export/music/artist/album/song1.mp3
/export/music/artist/album/song2.mp3

Or just use find:

# find /export/music -name �*.mp3? > /usr/local/etc/playlist2.m3u

Now give it a try and start icegenerator. Remember that libshout is accessable under /opt/icecast/latest/lib, so you have to export the LD_LIBRARY_PATH variable first when you start icegenerator as user icecast:

# su � icecast -c �export LD_LIBRARY_PATH=/opt/icecast/latest/lib:$LD_LIBRARY_PATH; /usr/local/bin/icegenerator -f /usr/local/etc/icegen1.cfg�

Check that it is running:

# pgrep -fl icegen
31255 icegenerator -f /usr/local/etc/icegen1.cfg

And take a look at the log:

# cat /var/log/icecast/icegen1.log
Fri Dec 16 13:44:38 2011: Connected to stream server
Fri Dec 16 13:44:38 2011: Now playing song1.mp3
Fri Dec 16 13:48:41 2011: Wait for all child process to terminate�

And finally try playing it:

$ mplayer http://dc01:8000/two.mp3
MPlayer 20100218-4.4.3 (C) 2000-2010 MPlayer Team

Playing http://dc01:8000/two.mp3.
Resolving dc01 for AF_INET6�
Couldn�t resolve name for AF_INET6: dc01
Resolving dc01 for AF_INET�
Connecting to server dc01[192.168.1.73]: 8000�
Name : two
Website: http://dc01:8000/
Public : no
Bitrate: 48000kbit/s
Cache size set to 320 KBytes
Cache fill: 2.50% (8192 bytes)
ICY Info: StreamTitle=�song2';
Cache fill: 12.50% (40960 bytes)
ICY Info: StreamTitle=�song2';

Audio only file format detected.
==========================================================================
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
mpg123: Can�t rewind stream by 725 bits!
AUDIO: 44100 Hz, 2 ch, s16le, 192.0 kbit/13.61% (ratio: 24000->176400)
Selected audio codec: [mp3] afm: mp3lib (mp3lib MPEG layer-2, layer-3)
==========================================================================
AO: [oss] 44100Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback�

That�s it again. A simple nice internet radio station to play around.