Sat 29 Dec 2007
Scheduling Video (and Audio) Stream Recording on Linux
Posted by admin under bash , linux , shell , ubuntu , videoComments Off
Say you want to record a video live stream from the internet for example from the Streaming CCC Congress in Berlin 2007.
This can be accomplished using the glorious mplayer HOWTO Rip Streams With MPlayer.
To stop the recording after a certain amount of time use this simple script (see also my post Finding Child Process Pids … ):
#!/bin/bash
URL=$1
FILE=$2
# duration in minutes
DURATION=$3
mplayer -framedrop -autosync 30 -cache 10000 -dumpstream $URL -dumpfile $FILE &
sleep $DURATIONm
kill %+
Now you need to start this script at a certain time. For that you could use the linux “at” command (see at). To run it you have to export the DISPLAY variable on ubuntu (see Bug #94933):
export DISPLAY=$DISPLAY ; export TERM=$TERM; echo "echo 'Hallo'" | at now
But I prefer KAlarm from KDE to schedule tasks which should run only once.
Run KAlarm, create New Alarm, choose Action “Command”, enter the path to your script with appropriate arguments for stream url, dumpfile and duration in minutes:
/home/myhome/scripts/stream_ripper.sh mms://streaming-internet.fem.tu-ilmenau.de/saal3 test.asf 60
, adjust all other settings which are quite self explaining. Use the template feature of KAlarm for similiar tasks.