Next Previous Contents

11. Streaming MP3's.

A streaming server allows you to transmit MP3 files over a TCP based network. This can be the Internet itself or your local network / intranet.

The connection principal is very similar to that of a web server, files are streamed when a client (the MP3 player) connects to the server.

11.1 Icecast

After downloading and untaring, a good look around the doc/ directory would be a good thing, the HTML manual is very helpful and comprehensive.

If you have downloaded the source code, follow the instructions regarding compiling pertinent to your system.

Icecast will not work correctly unless you correctly set the servername in the config file, icecast.conf, which is located in the etc directory. It must match the name that resolves to your IP address exactly.

If you see the following line when Icecast starts-up you have problems:

-> [05/Jan/2000:17:21:04] WARNING: Resolving the server name [] does not work!

Edit icecast.conf which is located in the etc directory and locate the line containing the entry for "server_name" and enter your servers name. If you are unsure you can find out by using the hostname command, or by cat'ing /etc/hosts.

Once you've made the neccesary changes you'll need to either copy the conf file to the bin directory, or start icecast with the -c option and specify the location, like so:

[dj@megajukebox bin]$ ./icecast -c ../etc/icecast.conf

If everything has been configured correctly, you should see something similar to the following:

[dj@megajukebox bin]$ ./icecast -c ../etc/icecast.conf -d /home/dj/mp3/icecast/  
Icecast Version 1.3.0 Starting...
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.

[05/Jan/2000:18:36:30] Icecast Version 1.3.0 Starting..
[05/Jan/2000:18:36:30] Using stdin as icecast operator console
[05/Jan/2000:18:36:30] Tailing file to icecast operator console
[05/Jan/2000:18:36:30] Server started...
[05/Jan/2000:18:36:30] Listening on port 8000...
[05/Jan/2000:18:36:30] Using [megajukebox] as servername...
[05/Jan/2000:18:36:30] Max values: 1000 clients, 1000 clients per source, 10 sources, 5 admins
-> [05/Jan/2000:18:36:30] [Bandwidth: 0.000000MB/s] [Sources: 0] [Clients: 0] [Admins: 1] [Uptime: 0 seconds]

The -d option sets the directory for log files and templates.

Below is the list of command-line options:

        -c [filename] 

Parse as a configuration file. Please note that any command line
parameters you supply after this override whatever is in file. Also note that
icecast.conf in the current directory is already parsed when you specify
this file, so anything in icecast.conf not overridden by the new configuration
file will be used by the server. 

        -P [port] 

This is the port used for all client, source, and admin connections. It's set
to 8000 by default. 

        -m [max clients] 

Allow this number of client connections. When this number is reached, all
client connections will be refused with 'HTTP/1.0 504 Server Full' 

        -p [encoder password] 

This sets the password that the encoder must use to be allowed to stream
to the server. Note that if you have compiled the server with crypt()
support, this argument must be an encrypted string. 


This will send the icecast server into the background (i.e daemon process).
To use the admin commands now, you have to connect to the server as an
admin, using some sort of telnet client. 

        -d [directory] 

Make all log files created by icecast, and all templates that icecast looks
for be relative to this directory. 

So, thats the server started, but you now need to connect an MP3 source to the server.

You can choose from two applications which deliver MP3 data to the server, Shout and LiveIce.


Shout provides Icecast with a static playlist of MP3's to stream and is included with Icecast.

You create the playlist if the MP3 files you want to stream with the following:

find [MP3 directory] -name '*.mp3' -print > playlist

At it's most basic level, to start the shout service, issue the following:

[dj@megajukebox bin]# ./shout megajukebox -P hackme -p playlist

The -P option specifies the password needed to add a mount-point to Icecast, this is the aptly set as hackme..... I strongly suggest you change it otherwise someone may :) The -p option specifies the location of the playlist file. Below is a list of all of the command line options:

[dj@megajukebox bin]# ./shout
Usage: shout <host> [options] [[-b <bitrate] file.mp3]...
        -B <directory>       - Use directory for all shout's files.
        -C <file>    - Use file as configuration file
        -D <dj_file> - Run this before every song (system())
        -P <password>        - Use specified password
        -S              - Display all settings and exit
        -V              - Use verbose output
        -X <desc>    - Use specified description.
        -a              - Turn on automatic bitrate (transfer) correction
        -b <bitrate> - Start using specified bitrate
        -d              - Activate the dj.
        -e <port>    - Connect to port on server.
        -f              - Skip files that don't match the specified bitrate
        -g <genre>   - Use specified genre
        -h              - Show this text
        -i              - Use old icy headers
        -k              - Don't truncate the internal playlist (continue)
        -l              - Go on forever (loop)
        -m <mount>   - Use specified mount point
        -n <name>    - Use specified name
        -o              - Turn of the bitrate autodetection.
        -p <playlist>        - Use specified file as a playlist
        -r              - Shuffle playlist (random play)
        -s              - (Secret) Don't send meta data to the directory server
        -u <url>     - Use specified url
        -v              - Show version
        -x              - Don't update the cue file (saves cpu)
        -z              - Go into the background (Daemon mode)
        -t              - Enable title streaming


LiveIce can work in 2 modes, it can pass a playlist to Icecast or can pass live audio from the soundcard.

After untaring and reading the README concerning building the package, make sure you have mpg123 installed and available as LiveIce requires it.

There are two ways of configuring LiveIce editing the config file with vi/emacs/or whatever or by using the TK based configuration tool, which is a pretty way of editing it :)

The best place for describing the internals of liveice.cfg can be found at LiveIce's homepage where Scott covers all of the options.

This is a copy of my config file with LiveIce set to mixer mode (stream from a list of MP3's)

NOTE: I've added comments to the file, so if you cut and paste make sure the comments haven't wrapped around to a new line otherwise LiveIce will not work :)

# liveice configuration file
# Automatically generated

SERVER megajukebox              # Your server name * MUST BE THE NAME THE SERVER RESOLVES TO *
PORT 8000                       # The port Icecast is running on

NAME Megajukebox                # Information regarding the name of your server which is sent to MP3 players, and
                                # to directory servers.  
                                # Examples 'Sarah FM' or 'ThisTown: Loud and Heavy Jazz - Internet Radio 24/7' 

GENRE Live                      # Information regarding the genre.  Examples 'Talk' or 'Dance'

DESCRIPTION                     # Information regarding the station.  Example 'The best for reggae in the North'

URL http://megajukebox:8000     # The URL and port of the server.

PUBLIC 0                        # Set this to 1 if you want Icecast to announce your station and list it's details
                                # on a directory server, otherwise leave 0

XAUDIOCAST_LOGIN                # can be either ICY_LOGIN or X_AUDIOCAST_LOGIN.  X_AUDIOCAST is better. 

MOUNTPOINT /techno              # Sets the mountpoint name of the stream for Icecast.  Only used if X_AUDIOCAST is used
                                # otherwise defaults to icy_0 

PASSWORD hackme                 # Icecast's admin password 

SAMPLE_RATE 44100               # The sample rate of the stream 
STEREO                          # Can be MONO or STEREO

NO_SOUNDCARD                    # See below

HALF_DUPLEX                     # Sets the soundcard duplex mode.  Can be HALF_DUPLEX or FULL_DUPLEX
USE_GOGO                        # Sets the encoder to use.  Check the README for the list
BITRATE 128000                  # Sets the bit rate of the stream (see below)
VBR_QUALITY 1                   # Sets the variable bit rate quality.

MIXER                           # See below

PLAYLIST /megajukebox/playlist  # Location of the playlist (see details on the find command later in this chapter) 

TRACK_LOGFILE track.log         # Filename and location to dump list of MP3's streamed

Once you have your config file you start LiveIce like so:
[dj@megajukebox liveice]$ ./liveice
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 44100Hz Stereo
Output Format: 256000 Bps Mpeg Audio
IceCast Server: megajukebox:8000
Mountpoint: /techno
Name: megajukebox - this and that radio - broadcasting 24/7
Genre: Techno
Description: a load of digital noise -> but i know you like it :)

 Press '+' to Finish
adding /megajukebox/demotunes/track_1.mp3
adding /megajukebox/demotunes/track_2.mp3
adding /megajukebox/demotunes/track_3.mp3
adding /megajukebox/demotunes/track_4.mp3
Adding New Channel 1
Adding New Channel 2
Channel 1 selecting 
Channel 2 selecting 
Playing track_1.mp3
searching for Id3v2
searching for Id3v1
copying the data
fixing the nulls
adding the url
closing input file
Using log track.log

The last line is a peak meter.

These are the keyboard controls for mixer mode:

Action                          Channel 1 Key   Channel 2 Key
~~~~~~                          ~~~~~~~~~~~~~   ~~~~~~~~~~~~~
Select next track on channel    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

The above liveice.cfg is for mixermode. To use LiveIce in audio mode change the line relating to MIXER to NOMIXER and set NO_SOUNDCARD to SOUNDCARD and restart LiveIce.

Forgetting to set the correct options will lead to some interesting warning ;)

   946:Error: Line In mode *and* no soundcard??????? Eeejit!

Once you have it all correctly set up and have plugged in an external source, you should be able to stream =:)

[dj@megajukebox liveice]$ ./liveice
Initialising Soundcard
16Bit 22050Hz Stereo Full Duplex 
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: megajukebox:8000
Mountpoint: /daves_band_live_at_the_club
Name: megajukebox - Dave and the Dynamite - Live at the Roxy  
Genre: Live/Rock
Url: http://megajukebox
Description: megajukebox::Louder than a frog in a trashcan..... and almost as musical

 Press '+' to Finish
Lvl: L:   8704 R:  11776 

The last line is a signal level meter, if the input signal is too high you will get a *clip* warning. If you do, turn down the gain of the input source.

The keen eyed amongst you may of noticed that in liveice.cfg the first comment lines point out that the file is automatically generated. If you are using the TK based GUI and you've made manual changes, you will lose them when you save. Either use the GUI or learn vi/emacs :)

11.2 Fluid

After untaring the bundle cd to the directory, then read the README :)

Fluid has three basic modes of operation, transmit, relay and forward. I'll only focus on transmit.

The config files associated for transmit are located in config/MP3TX.cfg. To test the server run with the following, at this point the default config settings should be ok:

java Fluid TX

Naturally enough you'll need Java of some form installed first. You can use either the Blackdown port of JDK available from or if you are using Redhat, Kaffe.

Fluid comes with a few sample MP3 files, so if everything is working you should see something similar to this (I've started the server using Kaffe in this example, you may have to start it using java):

[dj@megajukebox Fluid-Beta2J]$ kaffe Fluid tx
------- Fluid Streaming Server Beta 2 ------- 
This program is ShareWare(tm) and it will not 
be crippled in any way because of it. However 
if you do like the program and will use it    
commercial purposes, we ask of you to contact 
us at the address below for pricing info:     
 Eldean AB                  E-mail:           
 Sjoangsvagen 7    
 S-192 72 Sollentuna                          
   Fluid is Copyright Subside (C) 1998        
       written by Lars Samuelsson                            

* Transmission mode *
Reading config from: config/MP3TX.cfg
Reading playlist: playlist.m3u
Server started on port: 2711
Accepting administrator login on port: 2710
P| Dr. Nick - Hello Everybody

If you get this far, it looks like things are working, but I'm sure you'll want to stream more than the demo files!

You'll need to compile a playlist of the MP3's you want to stream. This will be a static list users will not be able to alter this list or make requests. This playlist is named playlist.m3u and is located by default in the root directory.

To compile a playlist of all MP3's in a particular directory (or disk) use the following command:

find [MP3 directory] -name "*.mp3" -print > playlist.m3u

By default the server uses port 2711, which is where your listeners will connect to, if you need to change this this can be done in the config file.

The server can be remotely administered by telneting to it's admin port, by default port 2710 like so:

[dj@megajukebox Fluid-Beta2J]$ telnet localhost 2710
Connected to localhost.localdomain.
Escape character is '^]'.
You are connected to the -Fluid- Streaming Server
Type "help" for a command reference
The following commands are available:
 help conn curr exit
Information about the currently broadcasted song:
Title:   Beer Talk
Artist:  Homer Simpson
Album:   The Simpsons
Year:    1996
Comment: Borrowed this as an example
Genre:   Comedy

The reference to "jaguar" is the admin password, this is the default. There is no prompt for the password so please don't sit there waiting for one! I suggest that you change the password from the default otherwise you will invite a hack! This can be changed in the config file, which looks like this:
[dj@megajukebox config]$ cat MP3TX.cfg 

# --- The lines are ---
# 1. PORT number (the server will use)
# 2. PORT number (for maintaining the server remotely)
# 3. Maximum number of connections (the server will accept)
# 4  Packetsize when reading/sending (in bytes)
# 5. Bitrate of the mp3s in kbit/s (all mp3s must have same bitrate)
# 6. Delay between songs (in milliseconds)
# 7. Password for remote administration
# 8. Playlist name (list in .m3u format)
# 9. Name of the file to write song info to (from ID3-tag)

The reference to the playlist being in m3u format means that it is in the same format as produced by the find command mentioned earlier.

Update for RC1

Fluid has been updated, and released under a GPL License (Way to go Lars!)

Here are the main differences:

11.3 Litestream

Litestream is similar in it's operation to Icecast. The system is composed of the streamer and the source.

To start the streamer you issue a command in the following format:

[dj@megajukebox]$ litestream <source port> <stream host> <stream port> <max listeners> <log ident> [<yp host> <yp port>]

The options are as follows:

source port Is the port you connect the 'audio' source to.

stream host This is the IP or FQDN of your server (find this out with the hostname command for domain name or cat /etc/hosts for your IP address).

stream port This is the port number clients connect to.

max listeners This is the number of clients who can connect to your server.

log ident Log messages are written to /var/log/messages. <log ident> is a ident string used to identify the Litestream server, eg.

If you use the ident string 'Litestream' the server starting message in /var/log/messages would look similar to:

Sep 18 19:32:20 linux Litestream[1901]: stream.c:555: main: 'server started'

<yp host & yp port> These 2 options specify the host and port of an yp server, used to announce your server to mp3 directory servers.

Here is an example:

[dj@megajukebox]$ litestream 5000 megajukebox 5555 1000 LitestreamServer 

Ok, so that's the server system. Once started it sit's there waiting for an input to be connected, which is done with the source command.

The format is like so:

source <ip or hostname> <port> <name> <genre> <url> <irc> <icq> <aim> <public? (0, 1)> <reported bitrate (16, 18, 56, 128, etc.)> <playlist.txt> <log ident>

Below is the list of options for source.

ip or hostname is the hostname or IP address of the computer running Litestream Server.

port is the port on which Litestream Server is waiting for a streaming source.

name is the name of your stream.

genre is the genre of your stream.

url is the URL for your streams web page.

irc is the IRC channel for your stream.

icq is your ICQ ID.

aim is your AIM ID.

public is either 0 or 1. 0 for private, 1 for public.

reported bitrate is the stream bitrate which will be reported to the YP server. This does not necessarily reflect the actual bitrate of your stream.

playlist.txt is the name of the file containing your playlist.

log ident is the syslog identifier which will be prepended to each log message generated by Litestream Streaming Source.

Here is an example which would match the Litestream command earlier:

[dj@megajukebox]$ source megakukebox 5000 'Megajukebox  The best jukebox ever' Various \#megajukebox 0 N/A 1 128 /jukebox/playlist LitestreamSource

11.4 Apache::MP3 Module

The Apache:MP3 module allows the Apache WebServer to stream MP3's. It does not offer the same level of features as Fluid, Litestream & Icecast.

The module is dependant on MP3::Info and mod_perl, both of which are available on CPAN.

After downloading the files needed a read of the README will help things!

Firstly make the module, then make the config changes to Apache's config files (your changes may be made in either httpd.conf or srm.conf).

You will also have to create directories for icons and a directory hierarchy for MP3's.

Section 6 of the README details the editing (or creation) of a Perl config file.

This is to preload the MP3::Info module which without this may cause Apache to crash.

In httpd.conf create an entry like so:

 Perlrequire /etc/httpd/conf/startup.perl

Alter the /etc/httpd/conf reference to point to where your Apache config files are located on your system.

Now create the file startup.perl at the location specified above. At the very minimum you should have the following (again adjust the path of perl to fit your system).

[dj@megajukebox conf]$ cat /etc/httpd/conf/startup.perl


use MP3::Info();

Then restart Apache and point a web browser at one of your new MP3 directories :)

There is more documentation available on Apache::MP3, from the command-line run the following:

[dj@megajukebox conf]$ perldoc Apache::MP3

11.5 Firewall Bypassing

A large portion of companies and institutions now use firewalls to block users from connecting to certain ports on remote servers.

A way to bypass this is to run your MP3 server using port 80. You will not be able to run a webserver on the same URL or IP address.

When running Icecast in 'firewall bypass' mode you will need to start shout with the option to set the port to port 80, like so:

[dj@megajukebox bin]$ ./shout megajukebox -e 80 -P hackme -p ../playlist 

11.6 Bandwidth considerations

Streaming audio can consume vast quantities of bandwidth if the MP3 servers' bit-rate is set too high.

Consider this scenario. A T1 link has a capacity of approx. 1.55 Mb/Sec. If you stream your MP3's at 128K/Bps stereo, each connecting player will use 256K/Bps, so only 6 users could connect to your MP3 server at any time without problems. And at 256K/Bps, you will not get too many modem users connecting!

So you must make a decision at what to set your stream rates not only on what your server's internet connection is rated at, but what your users will be connecting at. 24K/Bps Stereo will give a reasonable quality signal that 56K modem users will be able to connect to, and for the same T1 line would allow approx. 32 simultaneous connections.

If your server is running on an Intranet, bandwidth issues will still have to be considered especially if your network is running 10M/Sec.

But please let either your ISP or sys admin know you are going to stream otherwise you may be in for a shock. Some ISP's will charge you for bandwidth over a certain limit and sys admins like to know why their network is now running slow :)

11.7 Copyright Issues

I think it's reasonable to assume that record companies will not like you streaming material without their permission or payment of some kind! So what can you stream?

This is an area where you will need to be aware of the legal ramifications, because it will be you who will be liable.

Below are two links, one for the Electronic Frontier Foundation who are advocates of freeing restrictions surrounding the technology. The other link is to the Recording Industry Association of America, which seeks to protect the rights of artists from piracy.

I strongly suggest visiting both of the sites, and any others relevant to where you are physically based.

Next Previous Contents

Hosting by: Hurra Communications Ltd.
Generated: 2007-01-26 17:57:54