The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My work

  • My badges

  • Twitter Updates

  • My Flickr Stream

    20140417-Windows-8.1-Update-says-it-failed-but-it-succeeded

    20140417-Windows-8.1-Update-says-it-failed-but-it-succeeded--Windows-Help-and-Support--cannot-find-any-info--how-surprising-it-never-does

    20140329-VMware-vSphere-Client-4.1-retry-with-compatibility-settings

    More Photos
  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,250 other followers

Streaming your mp3 collection through an Icecast server using ezstream

Posted by Jeroen Pluimers 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:

  1. A subdirectory tree with all your songs in MP3 format
  2. Icecast
  3. EzStream
  4. 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

Download the most recent Windows Setup from the Icecast site (at the moment of writing, version 2.3.2 is the lastest version).

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:

Stop:

net stop “Icecast-trunk”

Start:

net start “Icecast-trunk”

Restart:

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

Even though EzStream comes from the xiph.org site, it is actually referenced on the Icecast site.
The current version 0.5.6 download comes without  an installer.

Installation is straightforward (this is a simple playlist case, you can make this way more complex if you want to):

  1. Unzip the archive
  2. Create a static playlist file from your MP3 files
  3. Create an EzStream xml config file pointing to the playlist
  4. 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:

http://servername:8000/mp3list

Conclusion

Hope this gets you going with your Icecast server.

You can do way more complex things, so this is only the first step.

Enjoy!

–jeroen

One Response to “Streaming your mp3 collection through an Icecast server using ezstream”

  1. Alirio Diaz said

    excellent thank you for your comments.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

Join 1,250 other followers

%d bloggers like this: