Streaming your mp3 collection through an Icecast server using ezstream
Posted by jpluimers on 2010/11/22
With more and more devices supporting media streaming, it is nice to have an audio streaming service in your home.
Setting this up on Windows is pretty straight forward.
What you need is this:
- A subdirectory tree with all your songs in MP3 format
- A streaming capable player (Windows Media Player will do)
Lets string these together.
If you want to rip all your CD’s to MP3 files, I have used CDEX for that (which was exceptionally good at extracting audio from CD’s that had scratches on them).
Download and install Icecast
Follow these Floss Manual installation instructions for Icecast on Windows.
Make sure you don’t forget to enable the “Install icecast as a windows service”
Since you now run Icecast as a service, the link on your desktop won’t work to start it.
In order to start/stop/restart your Icecast server, you need these commands:
net stop “Icecast-trunk”
net start “Icecast-trunk”
net stop “Icecast-trunk”
net start “Icecast-trunk”
Note: After changing the Icecast config file, you will need to restart your Icecast service.
Change your Icecast config file.
The Icecast config file is called Icecast.xml, and usually stores in the directory “%ProgramFiles%\Icecast2 Win32” on 32-bit systems and “%ProgramFiles(x86)%\Icecast2 Win32” on 64-bit systems.
On my 32-bit system that was “C:\Program Files\Icecast2 Win32”.
The default configuration of Icecast looks like the one below.
You must to change all the passwords (no more hackme!).
Optionally, you can change the sources limit (if you want to run more than 2 streams through your Icecast server).
I have changed my sources limit to 20, as I’m experimenting around. But in practice, I never had more than 10 concurrent streams running.
I have not changed other limits, as the Icecast server is running on the internal network, so there is enough bandwidth.
If you consider running your Icecast server over the internet, then make sure you do some calculations on your bandwidth and limit your maximum of listeners.
In that case, you also might want to consider the KH branches of Icecast (which allows for some extra bandwidth finetuning).
If you want to configure other options: Icecast has plenty of Icecast.xml configuration documentation.
<!-- This config file contains a minimal set of configurable parameters, and mostly just contains the things you need to change. We created this for those who got scared away from the rather large and heavily commented icecast.xml.dist file. --> <icecast> <limits> <sources>2</sources> </limits> <authentication> <source-password>hackme</source-password> <relay-password>hackme</relay-password> <admin-user>admin</admin-user> <admin-password>hackme</admin-password> </authentication> <hostname>localhost</hostname> <listen-socket> <port>8000</port> </listen-socket> <fileserve>1</fileserve> <paths> <logdir>./logs</logdir> <webroot>./web</webroot> <adminroot>./admin</adminroot> <alias source="/" dest="/status.xsl"/> </paths> <logging> <accesslog>access.log</accesslog> <errorlog>error.log</errorlog> <loglevel>3</loglevel> <!-- 4 Debug, 3 Info, 2 Warn, 1 Error --> </logging> </icecast>
Remember: after changing the Icecast.xml configuration, you must restart the Icecast service.
Download and install EzStream
Installation is straightforward (this is a simple playlist case, you can make this way more complex if you want to):
- Unzip the archive
- Create a static playlist file from your MP3 files
- Create an EzStream xml config file pointing to the playlist
- Run EzStream with that config file
So lets get that to work
Generate a static MP3 playlist file
EzStream can use an M3U file as a playlist.
In our case, the easiest way to create an mp3list.m3u is with a statement like this:
dir /s /b %mp3-root-path%\*.mp3 > mp3list.m3u
It is even easier to store mp3list.m3u in the same directory as ExStream.exe.
Create an EzStream xml config file that references the mp3list.m3u playlist file
Like Icecast, EzStream uses xml config files as well, but with a different content.
The easiest is to have the mp3list.m3u playlist file and mp3list.xml config file are in the same directory as EzStream.exe.
This is the config file I used, saved as mp3list.xml:
<ezstream> <url>http://servername:8000/mp3list</url> <sourcepassword>hackme</sourcepassword> <format>MP3</format> <filename>mp3list.m3u</filename> </ezstream>
The url element references your Icecast server and port (the localhost and port elements inside the Icecast xml config file).
The sourcepassword references the Icecast source password (hackme inside the source-password element in the Icecast xml config file).
The format element tells EzStream to tell Icecast we will be playing MP3 files.
The filename element points to the mp3list.m3u playlist file.
The above confiuration plays the MP3 files in the order in which they appear in the mp3list.m3u.
The below configuration file will play them in random order, because of the number 1 in the shuffle element:
<ezstream> <url>http://servername:8000/mp3list.random</url> <sourcepassword>hackme</sourcepassword> <format>MP3</format> <filename>mp3list.m3u</filename> <shuffle>1</shuffle> </ezstream>
Run EzStream with the right xml config file
This is the simplest part, as mp3list.xml and mp3list.m3u are in the same directory as EzStream.exe:
EzStream.exe -c mp3list.xml
Listen to your MP3 stream
Open your audio player, and have it point to the url mentioned in the mp3list.xml config file:
Hope this gets you going with your Icecast server.
You can do way more complex things, so this is only the first step.