Linux Hints & Tips 


Select which section to go to:
 
Installing Linux | IDE CD Burner | Web Mail | Linux Router Project | IceCast streaming server

 
 

Streaming MP3's over your home/office network

by Kevin Brouelette [kevin1a at varlog dot net]


 
 

Using the following links as a guide I was able to setup my own "Icecast" MP3 Radio Station which plays my MP3 music on my home network so that any computer on the network can listen to the stream anytime they want or even select a particular song that they like to hear.

http://www.icecast.org/

http://www.yolinux.com/TUTORIALS/LinuxTutorialAudioStreaming.html

http://www.europe.redhat.com/documentation/HOWTO/MP3-HOWTO-11.php3
 
 
 
 
 

First some basic concepts:

What 'Icecast' does is stream out whatever audio you happen to pipe into it. Running Icecast by itself won't do anything but sit there and wait for you to send it something to stream out. You have to use an additional program to pipe something into Icecast in order to stream the content.

The audio content can be one of many different things from streaming your mp3's from your hard drive, playing an audio cdrom over the network, or taking 'live' input from your soundcards' 'line-in' and sending it out over the network.

Most of the source code has a /doc directory with usefull documentation [read it] as well as the icecast mailing list archives at www.icecast.org.

We are basically just stratching the surface of Icecast, but we will easily have our own MP3 radio station running by the time we are finished.
 
 
 
 

Let's get going!

First off, we need to download and install the icecast streaming server. Just grab 2 programs icecast-1.3.11 and ices-0.2.2 [devel version] from http://www.icecast.org/download.html

Untar the icecast source to /usr/src/icecast-1.3.11 . Change to this directory and read INSTALL for the commands to create the icecast server.
You can use the following for the basic setup we are doing.

./configure

make

su -c "make install "

The last command  created a new directory /usr/local/icecast which is the top level directory for the icecast software .

Next.. edit the config files for icecast in /usr/local/icecast/conf .

The main icecast.conf is very well commented as to what each setting does. My file is below. I removed all the original comments but added in my own comments for you to follow the basic changes needed to get started.
 
 

####change these for your particular setup############ 

location Inside_lan

rp_email kevin1a at varlog dot net 

server_url http://192.168.44.100 

########################################## 
 

max_clients 100 

max_clients_per_source 100 

max_sources 10 

max_admins 5 

throttle 10.0 

sleep_ratio 0 

use_meta_data 0 

streamurllock 0 

streamtitletemplate %s 

streamurl http://yp.icecast.org 

nametemplate %s 

desctemplate %s 

mount_fallback 1 
 

#### Change these passwords to your own################ 

encoder_password linuxcast 

admin_password linuxcast 

oper_password linuxcast 

####################################################### 
 

touch_freq 5 

port 8000 

port 8001 
 
 

#### Set your HOSTNAME here############################ 

server_name MP3_STREAMER 

####################################################### 
 
 

force_servername 0 

logfile icecast.log 

accessfile access.log 

usagefile usage.log 

logfiledebuglevel 0 

consoledebuglevel 0 

reverse_lookups 0 

console_mode 0client_timeout 30 

kick_clients 0 
 
 

#####Set this to where your mp3 files live ################# 

staticdir /storage/mp3 

######################################################### 
 
 

templatedir /usr/local/icecast/templates 

logdir /usr/local/icecast/logs 

stats_log stats.log 

statshtml_log stats.html 

stats_time 60 

alias radiofri http://195.7.65.207:6903 

kick_relays 10 

transparent_proxy 0 
 
 
 

####I'm still  understanding how we handle acl. I used the following ##### 

acl_policy 1 

allow admin all 

####################################################################### 

 


 
 

Lets start up icecast:

Change to /usr/local/icecast/bin and start icecast and pass the [-c] config file and [-p] password arguments and [&] send it into the background.

./icecast -c ../etc/icecast.conf -p linuxcast &

Music!!

Let's make a playlist of our mp3's before we start to work on ices. My mp3's live in /storage/mp3 so I create a playlist like this:

find /storage/mp3 -name '*.mp3' > /usr/local/icecast/conf/shout.playlist
 

Take a look at the playlist file. It's just simply giving the PATH to each mp3 on your filesystem that you want included in the playlist.

Edit the playlist to suit your needs. You may have more than one playlist if you want to categorize by type of music.
 
 

Let's Build Ices.

Untar ices to /usr/src/ices-0.2.2 and change into this directory. Check the INSTALL for various options/features you may want to include.

We will build it as follows:

./configure

make

su -c "make install "

Again the new ices binary will be put in /usr/local/icecast/bin and the default config file will be /usr/local/icecast/conf/ices.conf

Here is my ices.conf file. It's in XML format. [note where we set the password]
 
 
<?xml version="1.0"?>

<ices:Configuration xmlns:ices="http://www.icecast.org/projects/ices">

<Playlist>

<!-- This is the filename used as a playlist when using the builtin playlist handler. -->

<File>apan.txt</File>

<!-- Set this to 0 if you don't want to randomize your playlist, and to 1 if you do. -->

<Randomize>1</Randomize>

<!-- Either builtin, perl, or python. -->

<Type>builtin</Type>

<!-- Module name to pass to the playlist handler if using perl or python. If you use the builtin playlist handler then this is ignored -->

<Module>ices</Module>

</Playlist>
 
 
 

<Execution>

<!-- Set this to 1 if you want ices to launch in the background as a daemon -->

<Background>0</Background>

<!-- Set this to 1 if you want to see more verbose output from ices -->

<Verbose>0</Verbose>

<!-- This directory specifies where ices should put the logfile, cue file and pid file (if daemonizing). -->

<BaseDirectory>/tmp</BaseDirectory>

</Execution>
 
 
 

<Stream>

<Server>

<!-- Hostname or ip of the icecast server you want to connect to -->

<Hostname>localhost</Hostname>

<!-- Port of the same -->

<Port>8000</Port>

<!-- Encoder password on the icecast server -->

<Password>linuxcast</Password>

<!-- Header protocol to use when communicating with the server. Use xaudiocast for icecast, or icy for shoutcast compatibility -->

<Protocol>xaudiocast</Protocol>

</Server>
 
 
 

<!-- The name of the mountpoint on the icecast server -->

<Mountpoint>ices</Mountpoint>

<!-- The name of the dumpfile on the server for your stream. DO NOT set this unless you know what you're doing.

<Dumpfile>ices.dump</Dumpfile>

-->

<!-- The name of you stream, not the name of the song! -->

<Name>Cool ices default name from XML</Name>

<!-- Genre of your stream, be it rock or pop or whatever -->

<Genre>Cool ices genre from XML</Genre>

<!-- Longer description of your stream -->

<Description>Cool ices description from XML</Description>

<!-- URL to a page describing your stream -->

<URL>Cool ices URL from XML</URL>

<!-- 0 if you don't want the icecast server to publish your stream on the yp server, 1 if you do -->

<Public>1</Public>

<!-- Stream bitrate, used to specify bitrate if reencoding, otherwise

just used for display on yp and on the server. Try to keep it accurate -->

<Bitrate>128</Bitrate>

<!-- If this is set to 1, and ices is compiled with liblame support,

ices will reencode the stream on the fly to the stream bitrate. -->

<Reencode>0</Reencode>

<!-- Number of channels to reencode to, 1 for mono or 2 for stereo -->

<Channels>2</Channels>

</Stream>

</ices:Configuration>


 
 

Let's start it up and feed it some music:

Change to /usr/local/icecast/bin and launch ices:

./ices -r -C ../etc/ices.conf -F ../etc/shout.playlist -P linuxcast &

The -r randomizes the playlist set with -F . I point to the ices.config file with -C, and -P connects to icecast with the correct password.
 

Listen up!

Now you can connect to the stream from any host on the lan using Xmms, Winamp, Realplayer, etc. For example using Xmms, 'open location'

with ctrl-l and type "http://192.168.44.100:8000/shout.playlist". Change the IP address to the IP of your Icecast server.
 
 

Take a look at the current stream and connections by opening a web browser and browsing "http://192.168.44.100:8000/list.cgi"

Icecast provides it's own self contained webserver running on port 8000.
 

You can also play your streams from a console if you have mpg123 installed.

mpg123 http://192.168.44.100:8000/shout.playlist
 

 

Kevin Brouelette

kevin1a at varlog dot net

March 24th 2002