Turning a protected RTSP stream into an iTunes PodCast (with linux and OSX)

A friend of mine does a radio show interstate that interestsme. Unfortunately, being a late night show (midnight) and interstate, for me to listen to this live would require me being awake a t 4am or so. Due to record label copyright permissions, this show is not available as a podcast download - its only available for live or delayed streaming. Undeterred, I wanted to automatically grab the stream and make it available on my iPhone for listening when it suited me, while out and about.

Getting the stream as a file with linux

The availability of the delayed stream, means this problem can be tackled with a cronjob on my gentoo linux server. This particular stream is served with the Real Time Streaming Protocol which means all we really need is the live555 media libraries. For Gentoo this was as easy as issuing "emerge live" as root on the commandline. For Ubuntu this would be "apt-get install liblivemedia-utils".

Then its as simple as calling openRTSP with the stream url. ie:

openRTSP -4 -a -t -d 3900 rtsp://streaming.server.com.au:80/streaming.server.com.au/name.mp4 1>name.mp4

This will write the audio stream  as a file.

The next step is to automate this process with a script being launched by cron. In this case, the name of the stream is in the format radioshow_YY_MM_DD.mp4. So my script will grab today's stream.
radioshow.sh:

1
2
3
#!/bin/sh
filename="radioshow_"`eval date +%Y-%m-%d`".mp4"
openRTSP -a -t -4 -d 7300 rtsp://streaming.server.com.au:80/streaming.server.com.au/$filename > /mnt/download/radioshow/$filename

Since this show is a weekly one, my crontab is setup to download the stream at 1:30pm every thursday.

crontab line: #download behind the mirror every thursday at 1:30pm 30 13 * * 4 /home/bed/radioshow.sh

Converting to a PodCast with OSX

Once we have the files, I wanted to put it in my iTunes library flagged as a PodCast. A commandline tool AtomicParsley enables us to set the appropriate mp4 tags so iTunes sees the file as a PodCast, however AtomicParsley doesn't like the mp4 tags created by openRTSP. To get around this we can load our file in QuickTime, and then re-export it to mp4. This will now be a file with mp4 tags that AtomicParsley can modify. We can then execute the following …

Read More