Dump streams using mplayer and at

As you probably know, this part of the year is mostly about Chaos Communication Congress with a lot of great lectures, but you might want to record a stream or two.

When I want to schedule something at specific time, I usually use at but mplayer is picky, so at the end I used following script:

#!/bin/sh -x

mplayer http://streaming-26c3-wmv.fem-net.de/saal$1 -noconsolecontrols \
   -dumpstream -dumpfile saal$1-`date +%Y%m%dT%H%M%S`.wmv &
This will allow mplayer to detach from console, so it will work in backup. Happy hacking!

Update: stopping streams manually is not fun, so here is improved script which has three arguments: room number, from time and to time

#!/bin/sh -x

# usage: record.sh 1 13:45 15:15

room=$1
from=$2
to=$3

url=http://streaming-26c3-wmv.fem-net.de/saal$room
file=`date +%Y%m%d`-$from-$to-saal$room

echo "Record $from - $to $url -> $file"

echo "mplayer $url -noconsolecontrols -dumpstream -dumpfile $file.wmv" | at $from
echo "kill \`ps ax | grep $file\`" | at $to

If you need to see all jobs scheduled, use atq. However, there is no easy way to correlate which task will execute in which time slot in atq output, so I wrote small atq.pl script which displays commands which will be executed (you will need to run it with root privileges).