online radio station

goal: create my own shoutcast-like audio streaming server

apps used: icecast and ezstream

Just got a hold of a vps i finally can play with, w00t. And it’s just now that I had the time to do something with it. I’m thinking of migrating this blog there one of these days. The first thing I’ve thought of doing is setting up my own online radio station. The first app that came to mind was shoutcast(link shoutcast.com). But it’s not opensource =/. Googling around, I discovered icecast(link icecast.org). There are 2 major components in an online radio station: a streaming server(which is icecast) and a source client(there are various apps that be used for this). The soure client may reside on a computer different to the streaming server, but in my setup they’re gonna be on the same machine

The 1st one is where your listeners will connect to listen to the music you’ll be broadcasting, the latter is what you’ll use to broadcast your content. Think of it this way, the stream server is the radio station 95.5. Whenever you want to listen to this station you turn on your radio and jog the dial to that station. The source client is your dj, he speaks stuff and plays songs on air. He uses the radio station as his medium to let the listeners hear what he has on playing. Also the dj doesn’t have to be physically present in the radio station’s bldg to be able to broadcast through the radio station itself. Basically that’s how it works, although it can do more than what I intend it to do. At this time I only want to be broadcasting a specific playlist.

First step was to install icecast, I downloaded the source rpm from:

http://icecast.org/download.php

Ran rpmbuild –rebuild against the .src.rpm file and installed the needed dependencies. Once done building it, installed it, edited the config file and ended up with this config

(/etc/icecast.xml):

<icecast>
<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>xtremeleetpassw0rd</source-password>#for source client
<relay-password>anotherleetpassw0rd</relay-password>
<admin-user>admin</admin-user>
<admin-password>notsoleetpassw0rd</admin-password>
</authentication>
<hostname>starvingpenguin.com</hostname>
<listen-socket>
<port>8000</port>
</listen-socket>
<fileserve>1</fileserve>
<paths>
<basedir>/usr/share/icecast</basedir>
<logdir>/var/log/icecast</logdir>
<webroot>/usr/share/icecast/web</webroot>
<adminroot>/usr/share/icecast/admin</adminroot>
<alias source=”/” dest=”/status.xsl”/>
</paths>
<logging>
<accesslog>access.log</accesslog>
<errorlog>error.log</errorlog>
<loglevel>3</loglevel>
<logsize>10000</logsize>
</logging>
<security>
<chroot>0</chroot>
<changeowner>
<user>nobody</user>
<group>nobody</group>
</changeowner>
</security>
</icecast>

After config was done, ran icecast with:

icecast -bc /etc/icecast.xml

Set up of 1st component is done, now comes the 2nd part which is installing a source client app. I chose to use ezstream because I uh, I like the name that’s why. The source code can be downloaded here.

./configure, make, then make install. I then had to create a config file for ezstream, sample configs can be found in /usr/local/share/examples/ezstream. I copied the sample ezstream_mp3.xml and made some changes to it to satisfy what I needed to do.

vi
<ezstream>
<url>http://localhost:8000/stream</url>
#your streaming server’s http://ip-or-host:port/stream
<sourcepassword>xtremeleetpassw0rd</sourcepassword>
#refer to your icecast.xml’s <source-password>
<format>MP3</format>
<filename>playlist.m3u</filename>#this still needs to be created
<stream_once>1</stream_once>#when file from <filename> is done being streamed, repeat.
<svrinfoname>pilip’s  Stream</svrinfoname>
<svrinfourl>http://www.starvingpenguin.com</svrinfourl>
<svrinfogenre>anything</svrinfogenre>
<svrinfodescription>music that i mostly listen to</svrinfodescription>
<svrinfobitrate>128</svrinfobitrate>
<svrinfochannels>2</svrinfochannels>
<svrinfosamplerate>44100</svrinfosamplerate>
<svrinfopublic>0</svrinfopublic>
</ezstream>
:wq /usr/local/music/my_first_stream.pl

Next is to create the playlist “playlist.m3u”. One way to do that would be to (my audio files are stored in /usrlocal/music):

find /usr/local/music -name *.mp3 >/usr/local/music/playlist.m3u

The file should now contain the filenames of my audio files along with their absolute paths.

To start streaming and have it run in the background:

ezstream -c /usr/local/music/my_first_stream.xml &

To access this stream, you can use the media players listed here: http://www.icecast.org/3rdparty.php. MSWindows’ own mediaplayer works too btw. The url to the stream would then be: http://starvingpenguin.com:8000/stream

goal completed.

TODOs:
-create start/stop script for icecast

This entry was posted in Uncategorized and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

Security Code:

This site uses Akismet to reduce spam. Learn how your comment data is processed.