Setting up a streaming service on the cheap

I’ve been going through some pains trying to work out how to set up an Internet based streaming service for Radio Lonsdale, in our case to provide a studio link for Outside Broadcasts, but in the future it could easily support Internet broadcasting.

Having finally got something working I thought it’d be useful to document what I’ve found for anyone else trying to do the same thing, who are looking for a solution that doesn’t cost a lot of money. Fingers crossed it all works!

Pre-Reqs

  1. This solution isn’t for everyone, it does require a bit of technical nouse (or at least a lack of fear!)
  2. Access to a computer which will act as the streaming server that does not have excessive data transfer restrictions. In my case this is an externally hosted VPS. For others this could be a PC located in your station, it entirely depends on the quality of your Internet connection, and what problem you’re trying to solve.
  3. Access to a computer at the ‘audio sending’ end, running Windows, that is capable of playing audio / receiving audio input.
  4. An Internet connection at the ‘audio sending’ end without major bandwidth restrictions, and a sensible ‘upload’ speed – this is where the trial and error comes in.

Step 1: Icecast2

“Icecast is a streaming media server which currently supports Ogg Vorbis and MP3 audio streams. It can be used to create an Internet radio station or a privately running jukebox and many things in between.” – http://icecast.org

It is open source and distributed under the GNU GPL, version 2 – so for our purposes, it’s free to use.

The Icecast website has a lot of documentation, in my case the external server I have access to is running Linux, and I was able to install Icecast by simply typing:

sudo apt-get install icecast2

The configuration file ‘icecast.xml’ (for me found in /etc/icecast2/icecast.xml) requires editing. I used a text editor on my server, but you could edit this in notepad and re-upload using FTP, etc. Here are some important sections:

<limits>
       <clients>2</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>

For my purposes I’m only really setting up a backhaul to the studio, so I don’t want a large number of sources or listeners. I’ve set both to 2, but you may want to increase the number of clients you’ll support. Just remember that each extra listener increases the data transfer, so test out what you’re able to cope with / afford.

<authentication>
       <source-password>password</source-password>
       <relay-password>password</relay-password>

       <admin-user>admin</admin-user>
       <admin-password>adminpassword</admin-password>
</authentication>

Do not leave these passwords as the default, that’d be silly. I’d also recommend changing the default admin username to something else as well.

<hostname>radio-lonsdale.co.uk</hostname>

This is set to localhost by default, I’ve set it to the address of the server that’s hosting the stream.

<listen-socket>
       <port>8000</port>
       <shoutcast-mount>/stream</shoutcast-mount>
</listen-socket>

Due to how we’re sending audio to the streaming server it was recommended to add the <shoutcast-mount> setting. You can choose whatever you want the mount point to be, /stream seemed sensible to me. You can also choose whatever port you want to use, but there’s no need to change it unless you have a good reason.

Last bit now, in order to get Icecast to run, we need to edit a setting in the defaults – starting the server is disabled until you’ve edited the configuration file properly.

Open up /etc/default/icecast2 in an editor, and change the last line to:

ENABLE=true

Then you can start the server (and stop the server) using the following instructions:

/etc/init.d/icecast2 start
/etc/init.d/icecast2 stop

To test, when the server is running you can see the administration console by visiting:

http://your-server-name-here.com:8000/admin

and logging in using the admin username and password you chose in the config file.

Step 2: Sending Audio using Winamp and ShoutCast DSP

At the ‘audio sending’ end, download and install Winamp (http://winamp.com). From testing, I believe only the Windows version is fully featured enough to install the plugin necessary to stream, but if someone can find a way of doing it on the Mac OS X version please let me know.

Then, search for and install a plugin called:

SHOUTcast DSP Plug-in for Winamp

This gives us a load of new settings that enable us to configure and stream audio. If you go into the Winamp Preferences pane, and select ‘DSP/Effect’ on the left, you should now be able to see the Shoutcast plugin installed.

Shoutcast Prefs

Select it, and click ‘Configure active plug-in’. This should present you with a new window.

Shoutcast - Login

The settings should be as shown. Using this to stream to Icecast does not support the source username field (DJ / User ID) so leave it blank. The password is whatever you configured in icecast.xml for the source.

Connect using ‘Automatic mode’ – I believe it only supports connections using the legacy connection setting, but we may as well let it decide for itself.

Shoutcast - Directory

Nice simple one this – untick ‘Make this stream public’ and in the Name box you can type whatever you like to describe the stream. When someone connects it’ll be what’s displayed as the name.

Shoutcast - Encoder

This is where you choose the type and bit-rate of the stream you’re sending. I’ve chosen to use MP3 and 128kbps, you should test this out and work out what’s best for your circumstances. If you’re only sending voice you could get away with using a lower bit-rate for example.

Shoutcast - Input

Lastly, where you want the stream to take its audio from. By default this is set to Winamp (i.e. a Winamp playlist) but you can select the sound interface in the drop down list, and hence should be able to send any audio you want through to Winamp to encode and stream.

When you’ve done all the config you can click the ‘Connect’ button, and away you go! If you struggle, the ‘Logs’ tab enables you to start logging the errors you’re getting and diagnose them. Googling will help with that.

Step 3: Connecting To The Stream

The last bit is connecting to the stream and listening to it. The address you should find your stream at is…

http://your-server-name-here.com:8000/stream

Enjoy, and good luck with your broadcasting!