Pejman Moghadam / Slackware

Slackware 13.37 - Setup an online radio station using icecast / ices

Public domain


icecast Server

cd /usr/src/
wget -c "http://pmoghadam.com/homepage/Pages/Deposit/Source-packages/icecast-2.3.3.tar.gz"
su - install
cd /usr/src/
tar xf icecast-2.3.3.tar.gz
cd icecast-2.3.3
./configure --prefix=/usr --sysconfdir=/etc/icecast
make 
make install DESTDIR=/usr/local/encap/icecast-2.3.3
cp /usr/local/encap/icecast-2.3.3/etc/icecast/icecast.xml{,.default}
mkdir /usr/local/encap/icecast-2.3.3/usr/share/icecast/log
logout

cd /usr/local/encap/icecast-2.3.3
mv usr/share/doc/ usr/

cat > /usr/local/encap/icecast-2.3.3/postinstall << EOF
#!/bin/bash
chown -R nobody:nogroup /usr/share/icecast
EOF
chmod +x /usr/local/encap/icecast-2.3.3/postinstall

cd /usr/local/encap/
chown -R root:root icecast-2.3.3

mkencap icecast-2.3.3/
epkg icecast-2.3.3

/etc/icecast/icecast.xml

<icecast>

    <location>Earth</location>
    <admin>icemaster@localhost</admin>

    <limits>
        <clients>100</clients>
        <sources>2</sources>
        <threadpool>5</threadpool>
        <queue-size>524288</queue-size>
        <client-timeout>30</client-timeout>
        <header-timeout>15</header-timeout>
        <source-timeout>10</source-timeout>
        <burst-on-connect>1</burst-on-connect>
        <burst-size>65535</burst-size>
    </limits>

    <authentication>
        <source-password>sourcehackme</source-password>
        <relay-password>relayhackme</relay-password>
        <admin-user>admin</admin-user>
        <admin-password>adminhackme</admin-password>
    </authentication>

    <hostname>localhost</hostname>

    <listen-socket>
        <port>8000</port>
        <bind-address>127.0.0.1</bind-address>
        <shoutcast-mount>/stream</shoutcast-mount>
    </listen-socket>

    <fileserve>1</fileserve>

    <paths>
        <basedir>/usr/share/icecast</basedir>
        <logdir>/log</logdir>
        <webroot>/web</webroot>
        <adminroot>/admin</adminroot>
        <pidfile>/icecast.pid</pidfile>
        <alias source="/" destination="/status.xsl"/>
    </paths>

    <logging>
        <accesslog>access.log</accesslog>
        <errorlog>error.log</errorlog>
        <playlistlog>playlist.log</playlistlog>
            <loglevel>3</loglevel> <!-- 4 Debug, 3 Info, 2 Warn, 1 Error -->
            <logsize>10000</logsize> <!-- Max size of a logfile -->
        <logarchive>1</logarchive>
    </logging>

    <security>
        <chroot>1</chroot>
        <changeowner>
            <user>nobody</user>
            <group>nogroup</group>
        </changeowner>
    </security>
</icecast>

Launch icecast

/usr/bin/icecast -b -c /etc/icecast/icecast.xml
tail -f /usr/share/icecast/log/error.log
http://localhost:8000/admin/stats.xml
    user: admin
    pass: adminhackme

libshout (client side)

cd /usr/src
wget -c "http://pmoghadam.com/homepage/Pages/Deposit/Source-packages/libshout-2.3.1.tar.gz"
su - install
cd /usr/src/
tar xf libshout-2.3.1.tar.gz
cd libshout-2.3.1
./configure --prefix=/usr && make
make install DESTDIR=/usr/local/encap/libshout-2.3.1
logout
cd /usr/local/encap/libshout-2.3.1
mv usr/share/doc/ usr/
cd /usr/local/encap/
chown -R root:root libshout-2.3.1/
mkencap libshout-2.3.1/
epkg libshout-2.3.1
ldconfig

ices client

cd /usr/src
wget -c "http://pmoghadam.com/homepage/Pages/Deposit/Source-packages/ices-2.0.2.tar.gz"
su - install
cd /usr/src/
tar xf ices-2.0.2.tar.gz 
cd ices-2.0.2
./configure --prefix=/usr/ --sysconfdir=/etc/ices
make
make install DESTDIR=/usr/local/encap/ices-2.0.2
cd /usr/local/encap/ices-2.0.2/
mkdir -p var/log/ices
mkdir -p etc/ices
cp usr/share/ices/ices-*.xml etc/ices
touch etc/ices/ices.xml
logout
cd /usr/local/encap/
mkencap ices-2.0.2
epkg ices-2.0.2

playback : /etc/ices/ices.xml

<?xml version="1.0"?>
<ices>
    <background>1</background>
    <logpath>/var/log/ices</logpath>
    <logfile>ices.log</logfile>
    <!-- 1=error,2=warn,3=info,4=debug -->
    <loglevel>4</loglevel>
    <!-- set this to 1 to log to the console instead of to the file above -->
    <consolelog>0</consolelog>
    <pidfile>/var/log/ices/ices.pid</pidfile>

    <stream>
        <metadata>
            <Name>Radio Pejman</Name>
            <Genre>General genre</Genre>
            <Description>Pejman's Online Radio Station</Description>
        </metadata>

        <!-- input module

            The module used here is the playlist module - it has 
            'submodules' for different types of playlist. There are
            two currently implemented, 'basic', which is a simple
            file-based playlist, and 'script' which invokes a command
            to returns a filename to start playing. -->

        <input>
            <module>playlist</module>
            <param name="type">basic</param>
            <param name="file">/etc/ices/playlist.txt</param>
            <param name="random">0</param>
            <!-- if the playlist get updated that start at the beginning -->
            <param name="restart-after-reread">0</param>
            <!-- if set to 1 , plays once through, then exits. -->
            <param name="once">1</param>
        </input>

            <!-- Stream instance
            You may have one or more instances here. This allows you to 
            send the same input data to one or more servers (or to different
            mountpoints on the same server). Each of them can have different
            parameters. This is primarily useful for a) relaying to multiple
            independent servers, and b) encoding/reencoding to multiple
            bitrates.
            If one instance fails (for example, the associated server goes
            down, etc), the others will continue to function correctly.
            This example defines two instances as two mountpoints on the
            same server.  -->
        <instance>
            <!-- Server details:
                You define hostname and port for the server here, along with
                the source password and mountpoint.  -->
            <hostname>localhost</hostname>
            <port>8000</port>
            <password>sourcehackme</password>
            <mount>/ices.ogg</mount>

            <!-- Reconnect parameters:
                When something goes wrong (e.g. the server crashes, or the
                network drops) and ices disconnects from the server, these
                control how often it tries to reconnect, and how many times
                it tries to reconnect. Delay is in seconds.
                If you set reconnectattempts to -1, it will continue 
                indefinately. Suggest setting reconnectdelay to a large value
                if you do this.
            -->
            <reconnectdelay>2</reconnectdelay>
            <reconnectattempts>2000</reconnectattempts> 

            <!-- maxqueuelength:
                This describes how long the internal data queues may be. This
                basically lets you control how much data gets buffered before
                ices decides it can't send to the server fast enough, and 
                either shuts down or flushes the queue (dropping the data)
                and continues. 
                For advanced users only.
            -->
            <maxqueuelength>80</maxqueuelength>

            <!-- Live encoding/reencoding:
                Currrently, the parameters given here for encoding MUST
                match the input data for channels and sample rate. That 
                restriction will be relaxed in the future.
                Remove this section if you don't want your files getting reencoded.
            -->
            <encode>  
                <nominal-bitrate>64000</nominal-bitrate> <!-- bps. e.g. 64000 for 64 kbps -->
                <samplerate>44100</samplerate>
                <channels>2</channels>
            </encode>
        </instance>

    </stream>
</ices>

/etc/ices/playlist.txt

/root/music/01.ogg
/root/music/02.ogg
/root/music/03.ogg
/root/music/04.ogg

Launch ices

ices /etc/ices/ices.xml

Listen

mplayer http://localhost:8000/ices.ogg

BY: Pejman Moghadam
TAG: icecast, ices, radio
DATE: 2012-08-23 23:50:42


Pejman Moghadam / Slackware [ TXT ]