Schedule your radio show recordings with ffmpeg and cron

January 4, 2012

Not so long ago, i updated one of my previous posts on ffmpeg with a line on how to record your favourite internet stream to disk with ffmpeg.

Actually that line doesn’t really work well if you want to record a show that’s on the radio every week, on a given day and a given time. People familiar with cron, the unix schedule program, will know you can just give it some coordinates, and it will run your comments at certain intervals. So i tried feeding that particular command to cron, but cron always failed to record my show, because ffmpeg generates way too much output. I found a workaround for that too, by redirecting all output to /dev/null.

How to do it?
(for Mac OSX or any GNU/Linux distro with cron and ffmpeg installed)
1. Determine the ffmpeg command you wish to schedule. Maybe my other posts about ffmpeg can help you.
e.g.: ffmpeg -i http://mp3.streampower.be/stubru-high.mp3 -f mp3 -acodec libmp3lame -ab 128k -ar 44100 -t 02:00:00 /home/toon/Desktop/stubru.mp3

2. Open a terminal window and type this to open your crontab file in a easy editor:
EDITOR=nano crontab -e

3. Determine the 5 crontab schedule numbers to tell cron when to execute your command (1: minute, 2: hour, 3: day of the month, 4: month, 5: day of the week with 0 for sunday). You can use wildcards (*) if you want any digit to be okay, lists (,), or ranges (-). For more info, check this reference.
I want to record every sunday at 19:00h, so for me it’s
0 19 * * 0

4. Insert those in the editor, then insert your command (devide everything with spaces).
When that is done, we still need to add the magical string to make crontab and ffmpeg work together. So type another space, and add this to the end of the crontab line: > /dev/null 2>&1. For me the result looks like this:
0 19 * * 0 ffmpeg -i http://mp3.streampower.be/stubru-high.mp3 -f mp3 -acodec libmp3lame -ab 128k -ar 44100 -t 02:00:00 /home/toon/Desktop/stubru.mp3 > /dev/null 2>&1

5. Press Ctrl+O and Ctrl+X to save and quit the Nano editor.

6. Enjoy Your Scheduled Recordings! 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: