Stream your CD collection to work

Tags: streaming audio, howto, multimedia,

Added: 2007-10-12T12:26

Stream your CD collection to work


* You have a large CD collection.
* You work for a decent company that won't begrudge you 64Kb/s *, and doesn't have insanely paranoid firewall policies.
* You'd like a nice random selection of your music to listen to at work.
* You run Linux.

But you don't want to have to copy files to and from an MP3 player, or you don't have the space on your player.

So rather than rip your CDs, copy them to the player, carry the player to work, and listen to it like that, why not just set up a private streaming server?

It's what I did.

(* In perspective, it would take 64 such streams to fill a 2Mb pipe, so it's very small. And it actually seems to stream at about 48-56kb/s)

So, how do you do it?

Rip all of your CDs to MP3 (OGG if you prefer, or Flac if you have lots of space).

emerge -av1 rip

Install the Open Source IceCast streaming server, and ezstream

emerge -av1 icecast ezstream

Edit your /etc/icecast2/icecast.xml file, and change the line that says hackme to something different!

rc-update add icecast default && /etc/init.d/icecast start

should start it up.

The next bit is trickier. I use a batch file to generate an m3u file containing all of my music. I then randomised the file, and set ezstream to play from that file. I then wrapped the whole process in a loop, so that if ezstream chokes on a file, the sequence repeats.

bunzip2 /usr/doc/ezstream-0.2.0/conf/ezstream_reencoding_example_vorbis.xml.gz > ~/ezstream.xml

Change the url, sourcepassword, format to VORBIS, filename to the m3u file you're going to create (/home/cd-rips/all.m3u), and enable the reencode section.

Create a script to fire it all up (~/bin/stream):

cd /home/cd-rips || die

echo Finding
find . -type f \( -iname "*.ogg" -o -iname "*.mp3" -o -iname "*.flac" \) > all.m3u.alpha
echo Randomising
cat all.m3u.alpha | ~/bin/rand > all.m3u

echo Sleeping
sleep 5

ezstream -c ~/ezstream.xml

The rand command is a little C program, compiled up. You can find the source by searching for it. %22This+is+m3u+rand+version+0.1%22+rand.c

The following command will start it looping at boot time. It uses "su", as I run it as root from /etc/conf.d/local.start.

/bin/su - yourusername -c "nohup bash -c \"while :; do ~/bin/stream ; done\" &"

Now, visiting http://your-ip-address:yourport/ should show you the "Icecast Status Page". There should be a "Click to Listen" link, which you can open in XMMS, Audacious, or any other streaming media player. If you want OGG support in Windows Media Player, you can try this:

This was written from memory, so give me some slack if the above doesn't work, and leave a comment.

posted by Calum on 2007-10-12T12:26 under

Add a comment

Your IP:
Please enter 9072630 here: