With the Minnesota Orchestra back in business (and now with their music director re-hired), Jessi and I purchased a subscription package of concerts to attend. With the orchestra pulling out all the stops on their repertoire, we wanted to attend almost all of the concerts. But that was unrealistic.

So when we couldn’t attend concerts that we wanted to hear, we could listen to them on the radio. And if we couldn’t listen in, there is the radio stream, which I could capture.

Radio stations have for the most part made streaming easy. Some have made attempts to secure their streams from easily being captured by using proprietary protocols like RTMP. But it remains that a stream is still a stream, and it can always be saved. It may just take a greater or lesser degree of difficulty.

Luckily, many stations opt for the tried-and-true streaming MP3 delivery method that every device can support without special hardware or software. My local classical affiliate is no exception. I found the address to the stream in apmplayer-all.min.js file (I used Chrome to un-minify it).

Then I put together a script that would save the stream…

First, I created a script, and saved it to /home/justin/bin/record_orchestra.sh on my system:

#!/bin/sh

DATE=`date +%Y%m%d`
STREAM='http://cms.stream.publicradio.org/cms.mp3'
DESTINATION="/home/justin/Music/mnorch_$DATE.mp3"
STOP='22:30'

cvlc --demux dump --demuxdump-file $DESTINATION $STREAM &
PID=$!
echo "kill $PID" | at $STOP

The script needs to be added to the crontab of my unix system to kick it off at 8PM on every Friday.

$ crontab -e
# m h dom mon dow command
0 20 * * fri /home/justin/bin/record_orchestra.sh

Script, explained

A little explanation of what’s going on in the script:

I’m using the date command to help me name the files. mnorch_20140214.mp3 for example is Valentines Day – Elgar’s Cello Concerto and Holst’s Planets 😎

I’m using VLC to capture the stream. cvlc is just a wrapper that’s included with VLC. It runs in a “headless” mode where nothing displays – perfect for a cron job. I’m telling it to do a raw dump of the incoming stream so the file doesn’t get transcoded, just saved exactly as it was streamed from the station. The ampersand (&) at the end of the cvlc command makes it run in the background.

Using the $! shell variable, the script saves the process ID of VLC. Then using the at daemon, we tell it to stop VLC “at 10:30PM,” when the show is likely over.

4 thoughts on “Record a streaming radio program

    • Some say they’re warhorses that shouldn’t be played, but if you want to sell a bunch of tickets after taking over a year off, it’s a sure-fire way to get it done.

      Reply
      • I suppose an ideal program would include one or two warhorses, a relatively unknown piece by a known composer, and then something new-ish. Orchestras shouldn’t pander to their audiences, and educating the audiences should be a part of their mission, but unless the “no warhorses” crowd thinks orchestras should be fully subsidized by the state, they might want to consider the ability to sell tickets.

        Reply
        • I think they’ve done a good job at having a good mix. For instance they played Rachmaninoff’s The Rock – one of his earliest pieces, alongside Piano Concerto No. 2.

          No complaints from me, I’ll take what I can get.

          Reply

Leave a Reply