08-17-2006

Record Streaming Radio Using Free Software

I’ve been using free Windows utilities for months now to record some of my favorite online radio shows—ones that aren’t available as podcasts. I had previously used Total Recorder, but the solution I’ll explain below uses only free software and does the recording in the background, so you’re free to record multiple shows at once or listen to other things while recording.

Download the Necessary Utilities
Start by downloading the following four programs:

Copy wget, wait, and close into a directory that is in your path. With the files in the path, you can reference them in batch files without having to specify a directory every time. You can either use a directory that is already in the path, such as c:\windows or c:\winnt, or set aside a new directory specifically for such tools. I usually create a directory called c:\bin and add that to the path.

Wget the Playlist File
You will need to create a file that specifies where to find a given station’s stream. In a browser, open the web site for a station you’d like to record. Right click on the playlist link (often called “listen”) and choosed “Copy Link Location” or “Copy Shortcut.”

Choose a directory where you’d like to store the recorded files, such as c:\radio. Create a subdirectory called \stations to store the playlist files for each station. From that directory, use wget to download a copy of the playlist file, using the URL copied above.

wget http://www.wbez.org/livestream/mp3.m3u

I then rename the playlist to something more meaningful.

ren mp3.m3u wbez.txt

Note: You may be able to specify the stream directly on the mplayer command line, but I have read of possible problems using that method.

The Recording Script
Save the following text to a .bat or .cmd file in the same directory where you’d like to store your recorded audio. I named mine recordradio.cmd.

for /F "tokens=2-4 delims=/ " %%i in ('date /t') do set DATEFORMATTED=%%k%%i%%j
start "%2" /min c:\etc\mplayer\mplayer -playlist .\stations\%1 -dumpstream -dumpfile %2%DATEFORMATTED%.mp3 -vc dummy -vo null
set /a SECONDS=%3 * 60
wait %SECONDS%
close %2

You may need to adjust the second line of the script to reference the correct mplayer and stations directories you created above.

Schedule the Script
Open the Scheduled Tasks utility (Start | Programs | Accessories | System Tools | Schedules Tasks). Choose File | New | Scheduled Task to create a new task. Selec tthe Schedule tab and specify a start time and the appropriate day (or days) you want the recording to run. Next, select the Task tab and enter a command on the “Run:” line, similar to the following:

c:\radio\recordradio.cmd station.txt ShowName #Minutes

The arguments after the command file specify the playlist file, name for the output file, and the number of minutes to record. For instance, you might use the following to record WBEZ, to capture “This American Life” for 60 minutes.

c:\radio\recordradio.cmd wbez.txt ThisAmericanLife 60

Test the Scheduled Task
Verify that the scheduled task will record properly by right-clicking the task and selecting “Run.” This will open two command line windows, one running the script and another running the recording process. Let the recording run for 30 seconds or so, then hit the space bar in the script window to cancel the wait command and end the recording.

You should then see a new file in the \radio directory, such as ThisAmericanLife20060724.mp3. The numbers represent the date the program was recorded, formatted for easier sorting.

Final Tips
This may seem like a hassle the first time you set it up, but adding additional shows is much easier once you’re passed the initial configuration. To find shows to record, check out my article on finding the best of online radio. Some of my favorites include Fresh Air, This American Life, and Solid Steel Radio.

For the best results, sync your computer with a time server to ensure consistent start and stop times. You may want to add a minute or two to the start and end of each recording to allow for shows that don’t start exactly on time.

Bandwidth costs for radio stations can be expensive. Consider donating to the stations you listen to regularly.

I realize that it’s not the most elegant solution, so I’d love to hear suggestions for possible improvements. Feel free to leave comments. And check back here soon, I’ll be posting another script in a few days that records and converts Windows Media and RealAudio streams.

Technorati Tags: , , , , ,

Posted by Matt in music, tech | RSS 2.0

6 Responses to “Record Streaming Radio Using Free Software”
  1. swen Says:

    Doesthis work with real audio streams also?

  2. alberto Says:

    Thank you very much for your clear and useful exposition.

    I guess I should have arrived some day to your way of working but I can never find the time to deal with this completely. :)

    I appreciate your help!
    Have a nice year!

    alberto

  3. Matt Says:

    swen,

    Yes, this does work for real audio streams, but it records them in real audio format. If you want them as mp3s, you need to script an additional step to convert them using something like lame.

  4. ECD Says:

    Audacity does the work. From their site:

    “In the drop-down menu on Audacity’s mixer toolbar, choose “Wave Out” or “Stereo Mix” as the input source. (The exact name may be different, depending on your computer’s sound drivers.) When you press the Record button, Audacity will capture whatever sound is playing on your computer’s speakers.”

  5. Stefano Says:

    I can not record…
    use this syntax: mplayer -playlist “c:\planet.txt” -dumpstream -dumpfile test.mp3 -vc dummy -vo null
    and then I quit this error: Error parsing option on the command line: -playlist
    What I’m wrong?

  6. Ian Says:

    If you want to cut through the nonsense give Media recorder a try, its free, its simple and works with windows task scheduler. Just set it and forget it.

    (screen shot) http://www.freewarefiles.com/screenshot/MediaRecorder11.jpg

    http://www.twinklesoft.com/mediaDownload.html

    ps requires net framework 1 and that it !

Leave a Reply