Stream your CD collection to work

Prerequisites:

* 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 <source-password>hackme</source-password> 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: http://www.illiminable.com/ogg/

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

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

There's a bunch of other

There's a bunch of other ways to stream music from your server
That's true. My solution however will play MP3, OGG, FLAC, and it will keep it at or below 64Kb/s, which is good for me (my outbound bandwidth is quite small at home), and I'm sure work wouldn't want 900Kb/s FLAC files to chew up their bandwidth.

There's also mod_mp3 for Apache.

PS. Your recover-ssh-from-a-postgres-login was pretty good work :)

Alternatives

There's a bunch of other ways to stream music from your server to work/school/your desktop on the other side of the house. I personally use Ampache, which is a PHP based media library + streaming app of sorts, but there's also GnuMP3d, which is more lightweight. They work by generating a .m3u for you, which then has HTTP urls to the mp3s themselves.