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
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.