Icecast2 HOWTO

Rodolfo Martínez
April 17, 2006

This document describes how to set up an Icecast2 server for broadcasting audio over the Internet.


Table of Contents

  1. Prerequisites.
  2. How it works.
  3. Installing
    1. libshout.
    2. icecast2.
    3. lame.
    4. ices0.
  4. Configuring
    1. icecast2.
    2. ices0.
  5. Running icecast2.
  6. Running ices0.
  7. Running icecast2 and ices0 at the system boot.
  8. Listening the streaming with an audio program

Prerequisites

Table 1. Program requirements
File Description Required?
icecast-2.3.1 Icecast is a streaming media server which currently supports Ogg Vorbis and MP3 audio streams. Yes
ices-0.4 Source client for broadcasting in MP3 format to an icecast2 server. Yes
lame-3.96.1 LAME is an LGPL MP3 encoder. Optional

Table 2. Library requirements
Library Description Required?
libshout-2.2 Library for communicating with and sending data to an icecast server. Yes
libogg Manipulates ogg bitstreams. Yes
libvorbis Supports the Vorbis General Audio Compression Codec. Yes
libxml2 Used to parse the config files. Yes
libxslt Used for building the web-frontend. Yes
curl-7.1x Icecast may be compiled without curl, however this will disable all Directory server interaction. Optional

How it works

The Server opens one or several ports (8000 by default) for the broadcast, it runs a daemon (icecast2) which waits for audio content that will be provided by the client(s) (ices0) in mp3 or ogg format.

One server can broadcast several audio streams simultaneously; also it provides the audio stream information throught a web interface.

The client reads an ogg or mp3 file and sends it to the server.

Any user who wants to listen the audio will connect to the server through an audio program; such as, Windows Media Player®, Winamp, XMMS, Media Player, etc...


Figure 1. Architecture

Installing libshout

  1. Make sure that curl, libvorbis, libogg, libxml2 and libxslt are installed. All of these libraries are available in the DVD/CD installation in most Linux distributions.
  2. Download libshout.
  3. Untarring, configuring, compiling and installing:
    $ tar -zxvf libshout-2.2.tar.gz
    $ cd libshout-2.2
    $ ./configure --prefix=/usr
    $ make
    $ su
    # make install
    # exit
    

Installing icecast2

  1. Download icecast2.
  2. Untarring, configuring, compiling and installing:
    $ tar -zxvf icecast-2.3.1.tar.gz
    $ cd icecast-2.3.1
    $ ./configure
    $ make
    $ su
    # make install
    # exit
    

Installing lame

  1. Download lame.
  2. Untarring, configuring, compiling and installing:
    $ tar -zxvf lame-3.96.1.tar.gz
    $ cd lame-3.96.1
    $ ./configure --prefix=/usr
    $ make
    $ su
    # make install
    # exit
    

Installing ices0

  1. Download ices0.
  2. Untarring, configuring, compiling and installing:
    $ tar -zxvf ices-0.4.tar.gz
    $ cd ices-0.4
    $ ./configure --with-lame
    $ make
    $ su
    # make install
    # exit
    

Configuring icecast2

  1. Create user and group for icecast2:
    $ su -
    # groupadd icecast2
    # useradd icecast2 -g icecast2
    
  2. Change icecast2/ices0 ownership:
    # cd /usr/local/bin
    # chown icecast2.icecast2 icecast ices
    # mkdir /usr/local/share/icecast/log
    # chown -R icecast2.icecast2 /usr/local/share/icecast
    
  3. Edit icecast2's configuration file:
    # vim /usr/local/etc/icecast.xml
    and change the lines:
    ...
    <hostname>localhost</hostname>
    ...
    <logdir>/usr/local/var/log/icecast</logdir>
    <webroot>/usr/local/share/icecast/web</webroot>
    <adminroot>/usr/local/share/icecast/admin</adminroot>
    ...
    <chroot>0</chroot>
    <!--
    <changeowner>
    	<user>nobody</user>
            <group>nogroup</group>
    </changeowner>
    -->
    ...
    
    to:
    ...
    <hostname>your_hostname or ip</hostname>
    ...
    <logdir>/log</logdir>
    <webroot>/web</webroot>
    <adminroot>/admin</adminroot>
    ...
    <chroot>1</chroot>
    <changeowner>
    	<user>icecast2</user>
            <group>icecast2</group>
    </changeowner>
    ...
    
  4. Save and close the file

Configuring ices0

  1. Edit ices0's configuration file:
    # cp /usr/local/etc/ices.conf.dist /usr/local/etc/ices.conf
    # vim /usr/local/etc/ices.conf
    
    and change the lines:
    ...
    <File>playlist.txt</File>
    ...
    <Background>0</Background>
    <Verbose>0</Verbose>
    ...
    <Hostname>localhost</Hostname>
    <Password>letmein</Password>
    ...
    <Bitrate>128</Bitrate>
    <Reencode>0</Reencode>
    ...
    
    to:
    ...
    <File>/tmp/playlist.txt</File>
    ...
    <Background>1</Background>
    <Verbose>1</Verbose>
    ...
    <Hostname>icecast2 server's hostname or ip</Hostname>
    <Password>icecast2 server's source password (hackme by default)</Password>
    ...
    <Bitrate>64</Bitrate>
    <Reencode>1</Reencode>
    ...
    
  2. Save and close the file.
  3. Create the playlist:
    cd /path/to/music's/dir
    find `pwd` -name \*.mp3 > /tmp/playlist.txt
    

Running icecast2

# icecast -c /usr/local/etc/icecast.xml &

Running ices0

# ices -c /usr/local/etc/ices.conf &

Running icecast2 and ices0 at system's boot

  1. Save the following file in /etc/init.d/icecast2:
    case "$1" in
    	start)
    		/usr/local/bin/icecast -c /usr/local/etc/icecast.xml > /dev/null &
    		;;
    	stop)
    		killall icecast
    		;;
    	*)
    		echo "Usage: $0 {start|stop}"
    		exit 1
    		;;
    esac
    
  2. Save the following file in /etc/init.d/ices0:
    case "$1" in
    	start)
    		/usr/local/bin/ices -c /usr/local/etc/ices.conf >/dev/null &
    		;;
    	stop)
    		killall --signal SIGINT ices
    		;;
    	*)
    		echo "Usage: $0 {start|stop}"
    		exit 1
    		;;
    esac
    
  3. Make them executable and create symbolic links:
    # chmod 755 /etc/init.d/icecast2
    # chmod 755 /etc/init.d/ices0
    
    # cd /etc/init.d/rc3.d
    # ln -s ../icecast2 S80icecast2
    # ln -s ../ices0 S81ices0
    
    # cd /etc/init.d/rc5.d
    # ln -s ../icecast2 S80icecast2
    # ln -s ../ices0 S81ices0
    
    # cd /etc/init.d/rc0.d
    # ln -s ../ices0 S80ices0
    # ln -s ../icecast2 S81icecast2
    
    # cd /etc/init.d/rc6.d
    # ln -s ../ices0 S80ices0
    # ln -s ../icecast2 S81icecast2
    

Listening the streaming with an audio program

  1. Launch your favorite Internet browser (i.e. Firefox)
  2. Open http://icecast2:8000
  3. Click on "Click to listen" link and enjoy!