Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Turning a protected RTSP stream into an iTunes podcast Apps
A friend of mine does a radio show that interests me. Unfortunately, being a late night show (midnight) and interstate, for me to listen to this live would require me being awake at 4am or so. Due to record label copyright permissions, this show is not available as a podcast download -- it's 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.

This particular stream is served with the Real Time Streaming Protocol, which means all we really need is the LIVE555 openRTSP command line program. With that installed, it's as simple as calling openRTSP with the stream URL:
openRTSP -4 -a -t -d 3900 rtsp:// 1>name.mp4
This will write the audio stream as a file (named name.mp4 in this example). The next step is to automate this process with a script being launched by crontab (for a Linux server) or launchd (for an OS X server).

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. First, a shell script named Once I had the file, 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 command:
AtomicParsley name.mp4 --podcastFlag true --artist name --title name --advisory explicit --description name --podcastURL name --podcastGUID 1 --year "2008-12-25" --overWrite
This will create a new file, which we can then drag into iTunes. This will now show up as a proper podcast, so it will automatically sync to my iPhone and then be removed once I've listened to it. Now that's a fair bit of manual mucking around, so we can use AppleScript to automate all of this in one nice move, which can be the scheduled with launchd to occur at a convenient time: This script does the following:
  • Looks in a directory in my file server and copies it file locally
  • Loads it into QuickTime, and exports it to add proper tags
  • Sets podcast tags with AtomicPasley
  • Imports it into iTunes
  • Cleans up files
mount volume "afp://path/to/download/drive" as user name "XXXXXXXX" with password "YYYYYYYYY"
tell application "Finder"
    repeat until ((name of every disk contains "download") as boolean)
        delay 2
    end repeat
end tell

set source_location to "download:radioshow"

tell application "Finder"
    set new_file to {get name of files of folder source_location} as text
    with timeout of 7200 seconds --2 hour timeout, incase we're copying over a VPN or something
        copy {file new_file of folder source_location} to desktop
    end timeout
end tell

-- Use QuickTime to export it (to set proper mp4 tags)
set user to do shell script "whoami"
set local_new_file to {"/Users/" & user & "/Desktop/" & new_file} as text
set local_fixed_file to {"/Users/" & user & "/Desktop/" & new_file & ".fixed.mp4"} as text
tell application "QuickTime Player"
    close every window
    open local_new_file
    with timeout of 1800 seconds -- half hour timeout incase export takes a while
        export front document to local_fixed_file as MPEG4 using default settings
    end timeout
end tell
quit application "QuickTime Player"

-- our file is always the format of ccccccccccccccccYYYY-MM-DD.mp4 so lets extract the date
copy characters 17 through 26 of new_file as string to datestamp

-- run AtomicParsley (located in ~/scripts/) to flag it as a podCast
set run_ap to {"/Users/" & user & "/scripts/AtomicParsley " & local_fixed_file & " --podcastFlag true --artist radioshow --title 'radioshow '" & datestamp & " --advisory explicit --album radioshow --description radioshow --podcastURL '' --podcastGUID 1234 --year '" & datestamp & "' --overWrite"} as text
do shell script run_ap

-- import file into iTunes
tell application "iTunes"
    add ({POSIX file local_fixed_file})
end tell

tell application "Finder"
    delete {POSIX file local_new_file}
    delete {POSIX file local_fixed_file}
    delete {file new_file of folder source_location}
end tell
Lastly, the AppleScript is saved as an application, and scheduled with launchd via Lingon, which runs at 8am friday morning:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
[robg adds: I haven't tested this one.]
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (3 votes cast)

Turning a protected RTSP stream into an iTunes podcast | 4 comments | Create New Account
Click here to return to the 'Turning a protected RTSP stream into an iTunes podcast' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Turning a protected RTSP stream into an iTunes podcast
Authored by: eagle on Jan 06, '09 10:54:09AM

I wrote something like this, but it works differently.

I use Audio Hijack Pro to record the stream to a temporary location, then use a cron job to move the temporary files to their permanent location. I wrote a PHP script that generates a podcast feed from the files in that directory, so I then subscribe to that podcast in iTunes.

Fully automated, no manual intervention required. I listen at my leisure, and iTunes downloads new episodes and removes old episodes. A cron job cleans up the recorded shows after a specified number of days.

[ Reply to This | # ]
Turning a protected RTSP stream into an iTunes podcast
Authored by: gsperling on Jan 06, '09 06:38:33PM

Care to publish your process?

[ Reply to This | # ]
Turning a protected RTSP stream into an iTunes podcast
Authored by: eagle on Apr 15, '09 08:47:59AM
Sorry for the late response, but sure - you can download it here:

There is a README.txt file in the tarball that walks you through it. Feel free to email me (address in README) for assistance.

[ Reply to This | # ]
Turning a protected RTSP stream into an iTunes podcast
Authored by: mzso on Jan 06, '09 12:32:45PM
One can use Mplayer and LAME too to record an RTSP stream as WAV and convert into mp3. I've documented this with an example in my blog.

[ Reply to This | # ]