Mihai Surdeanu

Setup a streaming audio server using Icecast and Ices

Today, we will continue the series of tutorials on IT domain by providing a short tutorial on helping you to setup a streaming audio server using Icecast on your own VPS.

There are only 15 steps to follow. Let’s start!

Step 1: The first step is to download all dependencies needed before actually trying to install Icecast:

dnf install compat-openssl10
dnf --enablerepo=PowerTools install libtheora-devel
dnf --enablerepo=PowerTools install speex-devel

Step 2: After having all dependencies installed, we can proceed with RPM package fownload for Icecast – version 2.4.4:

wget https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/i/icecast-2.4.4-1.el7.x86_64.rpm

Step 3: The next step is to continue with the installation:

rpm -i icecast-2.4.4-1.el7.x86_64.rpm

Step 4: Double check the installation status – ok or not ok? :

icecast -v

If everything works as expected, the output of the above command will be “Icecast 2.4.4” (without quotes).

Step 5: Build a custom configuration file to fill your needs based on the one from here. Follow all the comments from there to understand all properties. One example is also provided below (icecast.xml):

<icecast>
        <location>MihaiSurdeanu.ro</location>
        <admin>{YOUR_ADMIN_EMAIL_ADDRESS}</admin>

        <limits>
                <clients>5</clients> <!--represents number of clients allowed to connect in the same time-->
                <sources>1</sources> <!--represents the total number of sources allowed-->
                <threadpool>2</threadpool> <!--3 threads to handle all client requests-->
                <queue-size>65535</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>{YOUR_SOURCE_PASSWORD}</source-password>
                <admin-user>{YOUR_ADMIN_USER}</admin-user>
                <admin-password>{YOUR_ADMIN_PASSWORD}</admin-password>
        </authentication>

        <hostname>{YOUR_IP_ADDRESS}</hostname> <!--your server will be binded to a specific IP address-->
        <listen-socket>
                <port>8000</port> <!--default port is 8000, but you can change it-->
        </listen-socket>
        <fileserve>1</fileserve>

        <paths>
                <basedir>/path/icecast</basedir> <!--location of your icecast installation-->
                <webroot>/path/icecast/web</webroot>
                <adminroot>/path/icecast/admin</adminroot>
                <logdir>/log/icecast</logdir> <!--location of your logs directory-->
                <pidfile>/log/icecast/icecast.pid</pidfile>
                <alias source="/" dest="/status.xsl"/>
        </paths>

        <logging>
                <accesslog>access.log</accesslog>
                <errorlog>error.log</errorlog>
                <playlistlog>playlist.log</playlistlog>
                <loglevel>1</loglevel>
                <logsize>10000</logsize>
                <logarchive>1</logarchive>
        </logging>

        <security>
                <chroot>0</chroot>
                <changeowner>
                        <user>icecast</user> <!--run the process as icecast user and avoid running it as root!-->
                        <group>icecast</group>
                </changeowner>
        </security>
</icecast>

Step 6: Start Icecast process in background:

icecast -b -c icecast.xml

Step 7: Now, you should be able to access the following URL from your browser: http://{YOUR_IP_ADDRESS}:8000. Demo: https://mihaisurdeanu.ro:8000/


Step 8: The next part of the tutorial is to configure a streaming client that will act as a generator. This component will be responsible for creating a streaming station and will deliver the content to end user. I’m going to deliver the content in OGG format. It’s recommended to use OGG instead of MP3 because this format is open source and is smaller in terms of size. Having all elements in mind, the best solution for this client is IceS.

Step 9: Other few dependencies are required as prerequisites for this client. One of them is libshout.

wget http://downloads.us.xiph.org/releases/libshout/libshout-2.3.1.tar.gz
tar xf libshout-2.3.1.tar.gz
cd libshout-2.3.1
./configure --prefix=/path/icecast
make
make install

Step 10: Now, we can continue with IceS compilation:

wget http://downloads.us.xiph.org/releases/ices/ices-2.0.2.tar.bz2
tar xf ices-2.0.2.tar.bz2
cd ices-2.0.2/
./configure --prefix=/path/icecast
make
make install

Step 11: IceS comes with his own configuration file (ices.xml). You can use as template:

<ices>
        <background>1</background> <!--run as a daemon process-->
        <pidfile>/log/icecast/ices1.pid</pidfile>

        <logpath>/log/icecast</logpath>
        <logfile>ices1.log</logfile>
        <logsize>10000</logsize>
        <loglevel>2</loglevel>
        <consolelog>0</consolelog>

        <stream>
                <metadata>
                        <name>RadioStation 1: Inspiring and Motivating</name>
                        <genre>Varios</genre>
                        <description>Compilation music for inspiring and motivating people.</description>
                        <url>https://mihaisurdeanu.ro:8000</url>
                </metadata>
                <input>
                        <param name="type">basic</param>
                        <param name="file">/path/icecast/playlist.txt</param> <!--next step is about playlist file-->
                        <param name="random">1</param> <!--select files randomly-->
                        <param name="once">0</param> <!--if value is 1, IceS will stop after running one time the entire content-->
                        <param name="restart-after-reread">1</param> <!--when playlist is changed, the list is loaded without restart-->
                </input>
                <instance>
                        <hostname>{YOUR_IP_ADDRESS}</hostname>
                        <port>8000</port>
                        <password>{YOUR_SOURCE_PASSWORD}</password>
                        <mount>/radiostation1</mount>

                        <encode>
                                <nominal-bitrate>48000</nominal-bitrate> <!--48 Kbps-->
                                <samplerate>44100</samplerate>
                                <channels>2</channels> <!--stereo-->
                        </encode>
                </instance>
        </stream>
</ices>

Step 12: Upload your media content in one directory: /path/location/to/media/. Make sure file extension is OGG and not MP3!

Step 13: Compute the playlist file:

find /path/location/to/media/ -name "*.ogg" > /path/icecast/playlist.txt

Step 14: Start IceS process in background, as another user:

su icecast
./ices ices.xml

Step 15: Start to listen your own music. Web interface: http://{YOUR_IP_ADDRESS}:8000.

That’s all. Good luck!

Mihai

Pasionat de IT. Pasionat de viață. Pasionat de tot ceea ce înseamnă a face o viață mai bună, plină de înțelegere, ajutor reciproc și iubire de aproape.

Adaugă comentariu

Arhive

Arhiva personală