Originally Published: Saturday, 18 November 2000 Author: Phil Kerr
Published to: enhance_articles_multimedia/Audio Articles Page: 1/1 - [Printable]

Introduction to Streaming MP3

We've got a great one for you today. Phil Kerr, author of the famed Linux MP3-HOWTO, has written a fantastic introduction to streaming mp3 for our readers. Learn how to stream mp3 from one of the best. Rock on, Phil!

   Page 1 of 1  

MP3 is a standard for encoding audio (mostly music) into a relatively small file.

If you download an MP3 file to your machine and then listen to it, you are essentially copying the MP3 file from the Internet server to your local machine. There now are various waysyou can download MP3's such as:

  • Via your Web browser
  • Via FTP
  • Via a client such as Napster/Gnutella

Streaming is more analogous to listening to a radio station. You "tune in" and listen. There are a handful of servers you can use under Linux.I'llexplain how to set-up an IceCast server together with two different ways of connecting a "source" LiveIce & XMMS-LiveIce.

First you must obtain a copy of IceCast and install it. There are links at the end of this article, including one to IceCast. You should have a choice of what package format to download: Binary, RPM or source code. I'll be downloading the source code.

After downloading you'll need to install it.

tar zxvf icecast-1_3_5_tar.tar.gz
[Lots of lines of the contents, no errors]

cd icecast-1.3.5/
[Lots of lines of checking, no errors?]

[Lots of lines of make, still no errors?]

make install [as root]
[Last few lines of make, no errors? Good!]

bash-2.04# ls -l /usr/local/icecast/

total 24
drwxr-xr-x 2 root root 4096 Nov 16 20:09 bin
drwxr-xr-x 2 root root 4096 Nov 16 20:09 conf
drwxr-xr-x 2 root root 4096 Nov 16 20:09 doc
drwxr-xr-x 2 root root 4096 Nov 16 20:09 logs
drwxr-xr-x 2 root root 4096 Nov 16 20:09 static
drwxr-xr-x 2 root root 4096 Nov 16 20:09 templates

Change directory into conf/. Here we'll find a set of distribution config files. We want icecast.conf.dist. Copy this file to a file called icecast.conf in the same directory and edit the following lines:

  • server_name your.server.name
    This must be changed to your machine's name. You can find this out with the hostname command like so:
    # hostname
    If this is not set correctly IceCast will not work properly.
  • port 8000
    This is the default port clients will connect to. If you are behind a firewall, you will need this port open.

  • encoder_password hackme
    admin_password hackme
    oper_password hackme

    These are the passwords to remotelyadminister the server. If you do not change them you may wonder why your server keeps doing strange things.

There are many more options within the conf file, but these are the most importantto get the server running.

Start it up!

So, configuration now done, it's time to start the server. Change directory to bin/ and type the following:

#./icecast -c ../conf/icecast.conf -b

The options specify the location of the config file, and the -b option starts the server in the background.

bash-2.04# ./icecast -c ../conf/icecast.conf -b
Icecast Version 1.3.5 Initializing...
Icecast comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of Icecast under the terms of the
GNU General Public License.
For more information about these matters, see the file named COPYING.
Starting thread engine...

Just to make sure, check to see if the process is running with a ps command:

bash-2.04# ps -ef|grep icecast
root      7776     1  0 20:48 pts/0    00:00:00 ./icecast -c ../conf/icecast.conf -b
root      7777  7776  0 20:48 pts/0    00:00:00 ./icecast -c ../conf/icecast.conf -b
root      7778  7777  0 20:48 pts/0    00:00:00 ./icecast -c ../conf/icecast.conf -b
root      7779  7777  0 20:48 pts/0    00:00:00 ./icecast -c ../conf/icecast.conf -b
root      7780  7777  0 20:48 pts/0    00:00:00 ./icecast -c ../conf/icecast.conf -b
You can check the status of the server by examining the server logfiles in the log/ directory. OK, sothe server started.You can't wait to start streaming, can you?

We now need to connect a source to the server. That source will provide the server with a list of MP3's or a connection to the soundcard.


LiveIce provides a source from both MP3 files and from the line-in/microphone socket on your soundcard.

You will need a few other files to get things running:

  • Encoder. You will need to have an MP3 encoder installed, I'm using Notlame.
  • Player. I'm using mpg123 as the MP3 player.
  • TCL/Tk. This scripting language is needed to run liveiceconfigure.tk
Download and untar LiveIce, then configure and make like so:
tar zxvf liveice.tar.gz
cd liveice
./install-sh liveice /usr/local/bin [as root]
Yippee, installed! Now we need to configure it. In the Liveice directory there is a TK script which you use to create liveice.cfg named liveiceconfigure.tk. This script launched a GUI based configurator. You'll have to set the values that match your IceCast setup. Here are the others:
  • Public. Announce information to an MP3 directory server.
  • Login type. This is used to set server login options.
  • PCM Audio Format. Selects encoder options.
  • Soundcard. Selects if to use and what output option.
  • Encoder/Executables - encoder. Selects which encoder to use and change options.
  • Mixer Control. Selects mixer options.
  • Logging and save configuration options.
Ok, so now configured correctly, enter liveice and see it run:

bash-2.04# liveice playlist
Initializing Soundcard
16Bit 22050Hz Stereo
opening connection to megajukebox 8000
Attempting to Contact Server
connection successful: forking process
opening pipe!...
writing password
Setting up Interface
Soundcard Reopened For Encoding
Input Format: 16Bit 22050Hz Stereo
Output Format: 32000 Bps Mpeg Audio
IceCast Server: megajuxebox:8000
Mountpoint: liveice
Name: Megajukebox
Genre: Live
Url: http://megajukebox
Description: LiveIce

Press '+' to Finish
adding /storage/samples/sample1.mp3
adding /storage/samples/sample2.mp3
adding /storage/samples/sample3.mp3
adding /storage/samples/sample4.mp3
adding /storage/samples/sample5.mp3
Adding New Channel 1
Adding New Channel 2
Channel 1 selecting
Channel 2 selecting
Playing track01.mp3
searching for Id3v2
searching for Id3v1
making up the info
Using log track.log

You should see numbers flashing after the startup messages. These indicate the volume of the input source. If you selected to use the soundcard input and the signal is too high you will see *clip*.

Below is a list of keyboard commands:

Action Channel 1 Key Channel 2 Key
1 a
Select prev track on channel q z
Start/Stop channel 2 s
Reset channel w x
Increase volume on channel 3 d
Decrease volume on channel e c
Increase speed on channel 4 f
Decrease speed on channel r v
Sticky mode On/Random/Off 5 g
Preview channel t b
Random Track u m


XMMS-LiveIce is a streaming module for XMMS (versions greater that 1.0.0). It allows you to stream MP3's using the XMMS player. If you download the source code, you will have to configure and make as the others.

Once installed you will need to start XMMS and enable the plugin. From the menu's go to Options->Preferences and select Effects. The Effect plugins pulldown should now show LiveIce 1.0.0 (or a similar version number). Select this and click on the Configure button. The parameters are very similar to those of LiveIce and should be set to those of your system.

Once enabled, start playing MP3's as per normal and in the logs of IceCast you should see XMMS as a source.

So, now you should be able to stream MP3's from an IceCast server using LiveIce or XMMS!

Happy MP3'ing!


   Page 1 of 1