Linux Stories: The Radio Ripper

It was early 2005.  My Southern California commute had grown to 65 miles one way, averaging three hours a day.  I was growing tired of top 40 music and news radio.  After a particularly late night at work, I was listening to my local NPR station when the broadcast for the local minor league baseball team came on.  While I had never been a sports nut, I found that the broadcaster (Mike Saeger, now of the San Antonio Missions) interwove the narrative of the game with fascinating stories about the team, the players and baseball’s past.  Unfortunately, it typically started at 7:00 or 7:30 in the evening, meaning that I would typically catch the first 30 minutes at best before arriving home.

My goal became to record the games to listen to on my commute.  At first I considered piping a radio into a sound card, but I couldn’t get the station in the mountains where I lived.  I eventually figured out that the NPR station broadcasting the games had a website with a live feed.  Upon further digging, I found that the station was using a RealPlayer streaming audio format for its live feed.

I looked at options for automated recording of the feed and was unimpressed with my options on the Windows platform.  After some searching, I found that mplayer on Linux could play a RealPlayer feed, and more importantly, it could record it to a PCM-coded WAV file.  Thus began my quest to build a recording rig.  My goal was to record the game to a WAV file and convert it into a low quality MP3 that I could play from my chewing-gum-pack sized Creative MuVo.

I chose Fedora Core as my distro, mainly because most of the relevant forum posts and blogs I found on the topic had a Fedora or Red Hat focus.  I downloaded Fedora Core 3 to a CD and looked through the scrap pile at work to find a suitable machine.  I wanted something with low power consumption, since California’s electricity rates were astronomical and this machine would be running 24/7.  I settled on a Dell Latitude C600 laptop.  It had a 750MHz mobile Pentium III and 192MB of RAM.  It had been relegated to the scrap heap because it had a weak battery, some missing keys and a broken screen, none of which would be an issue for my purposes.  More importantly, with the lid closed, it drew only 15 watts at full tilt and 12 watts at idle with the 60GB drive spun down.  The weak battery still lasted 30 minutes, which was enough to ride out most power interruptions.

I’m a command line guy–I had to be dragged kicking and screaming into Windows–so I deselected the GUI and went with a minimal install.  All told, the running OS took less than a gigabyte of disk space and 48 megs of the 192 megs of available RAM, leaving plenty for my tools.  I installed mplayer, sox and lame to handle the audio processing.  My shell script would spawn mplayer in the background, wait four hours, and then signal it to terminate.  Sox would then be launched to re-encode the stream into low bit-rate mono, which was then piped into lame to create the final MP3.  The encoding process would take several hours but still complete in time for me to download the file to my MP3 player the next morning.  Scheduling was done by looking at the team’s schedule at the beginning of the week and using a series of ‘at’ commands to run the script at the appropriate days and times.

As baseball season drew to a close, I looked for alternatives.  I looked at downloading NPR weekend shows like Car Talk and Wait Wait–shows that were not yet available as podcasts.  Those shows were available at NPR’s website, again in RealPlayer format.  However, the filenames changed each week, and the shows were broken into segments that had to be downloaded individually.  I was able to use wget to get the HTML for the page and grep to parse out the filenames into a text file.  I then fed the text file into mplayer, one line at a time, to download the segments.  Finally, I used sox to encode and concatenate the individual files into a single file, which was converted to MP3 by lame.

After about a year, I recognized a mistake I had made.  I chose Fedora Core not knowing about their support policy.  Fedora Core 3 only received security patches for about 16 months from its release, or less than a year after I installed it.  There was an unofficial process for upgrading to FC4, but it broke a lot of stuff and took a lot of cleanup.  After that upgrade, I left the system at FC4 until it was decommissioned.

This was my first real-world experience with Linux, and it really helped me to feel comfortable with the operating system.  While I have used Debian, Ubuntu, SuSE and other Linuxes, this experience with Fedora drove me to choose CentOS (or Red Hat if OS support is required) as my go-to Linux server OS.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.