| :: Articles :: Streaming audio on GNU/Linux - the miniest HOWTO|
|25 Jan 2006|
Well, since I was asked…
This should hopefully fill you in with a basic idea of what’s
required to stream your own online radio station. This is not intended as a
thorough explanation - some experience is assumed (eg, being able to
install software). The purpose of this article is to go through the bare essentials.
What you’ll need:
The server consists of two main components, the streaming server (Icecast) and the source client (Ices). Icecast streams the audio to your listeners and Ices provides the encoded audio to stream. For my setup I run Icecast on my “always on” server box and Ices an my desktop, but you can run them both on the same machine. Icecast has very little processing overhead and Ices shouldn’t interfere with most desktop tasks (It runs in about 10-15% cpu on my Athlon 1800+). They both use fairly simple XML configuration files which are well commented.
On the server side I created a directory called .icecast/ in my home directory to hold configuration data, web templates etc. A sample template/configuration should be supplied with your Icecast installation - probably in /usr/share/icecast/. If you installed from source they can be found in the source directory. I copied admin/, conf/, log/ and web/ to ~/.icecast/. Next was tailoring the Icecast configuration to my needs. The important options are:
- clients - This sets the upper limit on the number of clients which can connect, including the source client. This should take into account your available upload bandwidth and the bitrate of your stream.
- authentication - You should select strong passwords for all the accounts you can log into - we’re talking root password material here. It might also be a good idea to change the actual account names.
- hostname - If you have a dyndns domain or similar pointing to your server put it here
- listen-socket port - Something open
- paths - Set these to the directories created in ~/.icecast/
Now you can launch the Icecast server with:
$ icecast -c ~/.icecast/conf/icecast.xml &
You can check the error log - if your configuration is sound you should see a line like:
[2006-01-23 13:38:10] INFO main/main Icecast 2.3.1 server started
For the Ices files I created a directory off my home directory called .ices/. This contains the configuration and log files. You can find a sample configuration file in /usr/share/ices or the Ices source directory - ices-alsa.xml is suitable for most setups. The things you’ll need to change are:
- logpath - The .ices directory you created is the best place for this.
- pidfile - Set this to ~/.ices/ices.pid - we’ll need it later
- metadata - It’s a good idea to change this to reflect the content of your stream.
- metadatafilename - set this to ~/.ices/ices-metadata
- instance - You’ll need to change the server settings to point at the machine you installed Icecast on. You might also like to change the encode quality, downmixing and resampling. I chose 44.1kHz, stereo, q0 ogg-vorbis. This gives a stream of about 64kbps.
Now you can run ices with:
$ ices .ices/ices-alsa.xml &
You’ll need to set a default capture source. I used aumix to set it to capture anything that’s played on the soundcard (see the red button)
You should be able to do this with alsamixer. I couldn’t do it with kmix. Recording everything on the soundcard gives you the opportunity to stream live from your soundcard’s line in - you could stream from a record deck or add a microphone.
There’s a very simple reason I chose amaroK and that is the availability of a Python script called ices-metadata which plugs into amaroK and sends correct track metadata to Ices. Upon installation of this script in amaroK change the configuration to reflect the location of the Ices pid and metadata files we set above. Using this the correct track and artist names are supplied with your stream.
You don’t have to use the setup I described above, of course. There are alternative source clients you can use such as DarkIce, the Oddcast plugin or if your processing power is limited, IceGenerator which streams already encoded files. There are also other options for streaming audio servers, including SHOUTcast, the Darwin Streaming Server and VideoLAN.
You can also supply several streams to a single server - using Ices this involves adding instance entries to the configuration file. You could, for example, have a high bitrate stream for your LAN and a low bitrate stream for internet users.
Icecast has a web template to display information about the available streams. You can customise this to fit your needs - for example, I removed links to other pages (such as admin and the redundant status link) provided a link to my last.fm profile to act as a track history.
If you are concerned about security (and you should be!) you can run the Icecast server as a low privilege user in a chrooted environment.
You may find the following helpful:
Choosing a Good Password
PAM and password control
Setting up the SoundBlaster ISA Series
About the author, John Barrett.