Configuring Linux to stream MP3 music over a TCP/IP network
is a matter of installing and configuring just two RPMs. These are Icecast–an
MP3 server, and Shout–which streams MP3 data to the MP3 server for
broadcasting. On the client side, you’ll need MP3 players like Winamp for
Windows, or X11amp and Mpg123 for Linux. So, let’s get going on how to
configure Linux for playing MP3s over your network.
We’ve given both Icecast and Shout RPMs in the CD with this
issue. You’ll find them in the \cdrom\linux directory. To install the RPMs,
mount the CD, go to this directory and type the following:
rpm -ivh icecast*.rpm
rpm -ivh shout*.rpm
Now, to configure Icecast, you have to edit the file
icecast.conf located in the directory /etc/icecast. The entries in this file are
in the form:
parametername parameter
Go to the parameter mount_fallback, and set its value to 1 or
0. So, when a stream requested by a client is not found, a value of 1 will
broadcast a default stream–the oldest stream on your server–over your
network, while a value of 0 will give an HTTP 404 error instead.
Next,
go to the encoder_password, admin_password, and oper_password. These would have
a default value of hackme. Give a password for each. Of these, encoder_password
is important as you’ll need it later for configuring Shout. The admin_password
is used to access the admin console of the Icecast server. The oper_password
authorizes the person with administrative rights to use operator commands. We
gave the same password for each as follows:
encoder_password pcq
admin_password pcq
oper_password pcq
Now,
scroll down until you find the parameter hostname, port, and server_name. Change
the server_name to the hostname of your Linux machine–you can find this by
typing hostname at the command line console. Leave the rest to default.
Now, scroll down till you find the parameter staticdir.
Change this to the directory where you’ll store MP3 files, for example:
staticdir /opt/mp3
Now save the file, place your MP3 files in this directory and
run Icecast by typing:
icecast -b
The -b parameter makes it a daemon (background process).
Clients can now access MP3 files stored in the directory you’ve
specified. To play a file in Winamp or X11amp, the client will have to type the
following URL:
http://shekhar.PCQLABS:8000/file/rock.mp3
Here, shekhar.PCQLABS:8000 is the machine name and port
number, and /file/rock.mp3 will play the file rock.mp3.
If you’re using mpg123–a command line MP3 player for
Linux, type:
mpg123 http://shekhar. PCQLABS: 8000/file/rock.mp3
The filename (rock.mp3) should be correct. You can also see a
list of all the MP3 files in the directory by entering the following URL in a
browser:
http://shekhar.PCQLABS: 8000/file/
Configuring Shout for streaming
If you want to stream MP3s over your network–instead of
individual clients connecting to the server to access MP3 files–you have to
configure Shout. This requires editing a file called shout.conf found in the
/etc/icecast directory. This file is also in the form:
parametername parameter
If you’re running Shout and Icecast on the same machine,
leave server_name to localhost. If it’s on a different machine, change it to
the server_name you’d given in the icecast.conf file. However, you must
confirm that the machine running Shout is able to locate the machine running
Icecast by its name (in our case, it was shekhar.PCQLABS).
Leave the port to default, and change the password to the
encoder password you’d given earlier.
The next line is:
mount default
This defines a stream named default. You can make
configuration files–shout.conf–with different mount names such as rock,
jazz, techno, etc, instead of default. Each of these can have a different
playlist, and you can run more than one copy of Shout with each configuration
file using the -C command line parameter (as we’ve shown later in this
article).
Now, leave the playlist parameter as it is. It specifies the
name of the playlist file as shout.playlist. Set the parameter loop–which is
"yes" by default–to "no" if you don’t want it to play
the songs on your playlist repeatedly. You can shuffle the songs in the playlist
by setting shuffle to "yes". Last, set the parameter daemon to
"yes" to run Shout as a background process. Save the file.
Now you need to construct the shout.playlist file. To include
all MP3 files in all mounted partitions:
find / -name *.mp3 -print > shout.playlist
To include only MP3 files in a specific directory:
find /opt/mp3 -name *.mp3 -print > shout.playlist
Copy shout.playlist in /etc/icecast directory, and run Shout
by typing shout at the console. By default, it looks for a configuration file
shout.conf in /etc/icecast. If you want to run more than one copy of Shout using
different configuration files:
shout -C
A detailed documentation of Shout is located in /usr/doc/shout-0.8.0.
Find the PID (ProcessID) of Shout. When it’s running, you
can send the following signals to it:
kill -s SIGINT
to play the next song
kill -s SIGUSR1
to reshuffle the playlist
kill -s SIGHUP
to make Shout re-read the configuration files.
Configuring clients
In Winamp and X11amp, press CTRL-L and feed the URL as:
http://shekhar.PCQLABS:8000/default
If you’re running more than one copy of Shout with
different playlists having different mount (stream) names–for example, rock,
jazz, etc:
http://shekhar.PCQLABS:8000/rock
http://shekhar.PCQLABS:8000/jazz
You can also use the IP address of the Linux machine running
Icecast. But remember to specify port 8000.
If you’re using mpg123, fire it up at the console as:
mpg123 http://shekhar.PCQLABS: 8000/default