Friday, April 20, 2012

Record stream media using mplayer

I really like a radio program that goes on air on a local radio. The radio is small, so they do not have a web site and podcasts even less. But they do have an online version of the radio broadcast.

Since the program goes live at 6am every day I always missed it (yes, I am not a morning type of person). To avoid such complications I wrote a simple bash script that calls mplayer to record the streaming radio at a given time of the day. The code goes like this:

#!/bin/bash

LENGTH="65m" # lenght of the recording

mplayer -quiet -dumpstream -dumpfile RECORDED.dump \
mms://&
echo $! >~/.mplayer-dumpstream.pid
sleep $LENGTH && kill `cat ~/.mplayer-dumpstream.pid`
rm ~/.mplayer-dumpstream.pid
So when I want to listen to the show I just use the unix "at" command to run this script at a given time. For instance:
# at -f script.sh -v 6am tomorrow
That is it. By the way, you can do that for video streaming as well. Enjoy

No comments:

Post a Comment

 
Locations of visitors to this page