This is a read-only archive. Find the latest Linux articles, documentation, and answers at the new Linux.com!

Linux.com

Feature: Internet & WWW

Broadcast your music with Icecast

By Kurt Edelbrock on April 17, 2008 (4:00:00 PM)

Share    Print    Comments   

You can stream your music collection to the whole Internet from your favorite Linux distribution. Take some playlist files, add in the functionality of the Icecast server, and you have your own Web-based radio stream. Use it to listen to music remotely on your home machine, or tell your friends and become the next Internet radio phenomenon.

Icecast is a collection of programs and libraries that creates a Web server for your stream. Icecast grabs your audio from a source program and allows it to be accessed by going to a URL. It seamlessly communicates with Shoutcast, announcing the presence of your stream all over the world if you wish. Others can listen to your stream through programs like VLC, MPlayer, and Xine.

You need a source program to give audio to your Icecast server. We'll use Ices, which comes in two flavors: the 0.x version supports sending an MP3 stream, and the 2.x version supports the Ogg Vorbis format. Unfortunately, configuring the Icecast server and the Ices source client can be difficult, especially for new users.

While many distributions, including Ubuntu and Debian, include the packages in their repositories, we'll walk through how to compile them by hand. The first step is to install the packages' dependencies: libxml2, libxslt1 curl, libxslt1-dev, vorbis-tools, libogg-dev, libvorbis-dev, and libshout3-dev. You can then download the files for Icecast and Ices. Extract both archives to folders, and then move into each folder and configure and install them using the usual ./configure; make; make install commands.

Configuring Icecast

The configuration file for Icecast is located in /usr/local/etc/icecast.xml, or it may be in a different place depending on your distribution. Most of the general settings for your server are stored in this file. You need to change the <source-password> field, which is used by the source client to stream audio into the server, in order to safeguard Icecast. The <admin-password> field authenticates you to view the XML statistics created for your stream. To get Icecast to use the right domain and port number, edit the <listen-socket> field. <logdir> specifies the location where the logs will be stored. Set the correct permissions to allow the server to edit the directory.

You must also configure the mount settings, especially if you plan to allow public access to your audio stream and want to set the name, Web site, or an introductory audio clip to be played when users first access the server. You can find them under the <mount> section. Some of these settings include the <max-listeners>, <stream-name>, <stream-description>, <stream-url>, and <genre>. The stream-url refers to the address listed in public directories. You can modify the URL users type in by changing the mount point within the <mount-name> tag. If you wish to serve a password-protected stream, you can do so with the <username> and <password> tags. If you want to create multiple mount points to work with more than one stream, you can duplicate the entire section (including the <mount> tags) and place it below the previous listing.

Once you've modified the configuration you can start the server by typing icecast -c /usr/local/etc/icecast.xml. You may need to edit the path if you have your configuration file in an alternative location. You can verify whether the server started by checking the log with top or htop, or by pointing your browser to http://yourip:port/admin/stats.xml. The username is admin and the password is the data you put into the <source-password>.

Using IceS to stream audio

Once the Icecast server is set up and awaiting audio, you must configure your source client to send audio to the server. For this example, I will assume that the Icecast server and the IceS source client will be on the same machine, though that doesn't need to be the case.

The first step is to create a playlist file that tells the client what music to play, and in what order. Create the playlist.txt file by opening a text editor and inserting file references in the following format:

# insert the /path/to/your/audio/files.mp3 /music/track1.mp3 /music/track2.ogg # etc...

There's an even easier way to create a playlist file if all of the audio files on the list are stored in a single directory. Execute the following command from a browser to copy the names of all of the files in the directory with a .mp3 extension to a text file:

find /path/to/audio/directory -iname "*.mp3" > playlist.txt

You can do the same thing with .ogg files by changing the -iname parameter, or you can drop the -iname "*.mp3" portion completely to grab all of the files in the specified directory. If you choose to grab everything, make sure there are only audio files on the playlist or it will create an error in Ices. Once you've created a playlist file, start the IceS client via the command line:

ices -h yourhost.com -P your-password -F /location/of/playlist.txt

Unfortunately, Ices won't generate a random playlist for you without the use of a separate shell script written by the user. To create random playback, the easiest thing to do it generate a playlist with all of the music you want played on it, and then set the random playback parameter to true in the configuration file. To do that, open /etc/ices2/ices-playlist.xml in a text editor, and change the value for <param name="random"> to 1. Ices will then behave in a way similar to the shuffle setting on most audio programs.

You can leave the -h option blank to have Ices default to the localhost address. Add the -p portnumber command to change the port if it was changed from the default port in the Icecast configuration file.

Now, direct your browser or stream player to the address and mount point specified in the configuration file, and you should hear the first song in the playlist, assuming you are the first listener connected. The source client will continue to feed music into the Icecast server, and listeners who access the feed later will join the playlist at its current point.

When you are finished with your audio stream, you can shut it down via the killall ices and the killall icecast commands.

Before you announce your new music stream all over the Web, remember that stream providers are liable to pay royalties on all copyrighted music they play. Though there is still some debate and controversy over the future projected costs of these fees, the Library of Congress provides rate information for those living in the United States.

Once you have your very own streaming server up and running, you never have to be separated from your music again. Access it over the Web from any of your computers, or use it to show your friends the newest song you wrote. Use it at work to rebroadcast meetings and conference calls for absent coworkers and employees. Or even better, quit your day job and take on other Web broadcasters in the battle for the best Internet radio station. All of this and more is possible with Icecast on your Linux machine.

Kurt Edelbrock is a technology journalist, blogger, and university student. He writes for a variety of open source publications, and serves as a technical consultant for a large public university.

Share    Print    Comments   

Comments

on Broadcast your music with Icecast

Note: Comments are owned by the poster. We are not responsible for their content.

Broadcast your music with Icecast - live?

Posted by: Anonymous [ip: 204.254.118.4] on April 17, 2008 10:37 PM
Nice article. If I can make a suggestion for a part 2: it would be great to see some information about streaming from a live source instead of from pre-recorded files.

#

Broadcast your music with Icecast

Posted by: Anonymous [ip: 159.238.13.55] on April 17, 2008 11:15 PM
MPD is an exceptional source for Icecast, then you can have web control, playlists, and more.

#

Jinzora is better and a lot easier....

Posted by: Anonymous [ip: 72.196.6.129] on April 18, 2008 03:39 AM
I have never been able to get Icecast working.... tweak and tweak the xml file and it always gives a parsing error and dies. I have never been able to get it to work even after hours and hours of googling and trying new things. If you want to stream your music just go out and get Jinzora. It's a lot easier to set up and works flawlessly. www.jinzora.org

#

Broadcast your music with Icecast

Posted by: Anonymous [ip: 58.147.35.56] on April 18, 2008 07:46 AM
Yes, nice article, but I'm using shoutcast with ice.
It is smooth and no problem. make sure do the crontab for it too.

You can test in http://radio.perak.org/

JuzHax.

#

Broadcast your music with Icecast

Posted by: Anonymous [ip: 86.150.196.231] on April 21, 2008 09:35 PM
For goodness' sake, you can just install a little Amarok script and get it done in seconds, broadcast everything in your playlist to an icecast/shoutcast URL. the script is called "icecast2 livestream (ices2)".

DanDart

#

Broadcast your music with Icecast

Posted by: Anonymous [ip: 130.115.137.18] on April 22, 2008 03:07 PM
Install SqueezeCenter (previously called slimserver) and make it real easy on yourself.

#

This story has been archived. Comments can no longer be posted.



 
Tableless layout Validate XHTML 1.0 Strict Validate CSS Powered by Xaraya