Unattended stream recording with MPlayer
Feb 03, 2011, 22:05 (0 Talkback[s])
(Other stories by Silas Brown)
"The Linux movie player program MPlayer has an option to record
an Internet-broadcast video stream for playing later. The recording
can be done from the command line. This is useful for two reasons:
(1) you can record at a time when you are too busy to watch, (2) if
your Internet connection is poor for realtime video but reasonable
for non-realtime bandwidth (some low-end cable connections are like
this), then you might get better results by using ssh to log into a
well-connected remote box, record the broadcast from there, and
then download the resulting file in non-realtime (assuming the
broadcast is short, otherwise this might not be practical).
"However, many versions of MPlayer have trouble doing this
unattended. Firstly, if the connection to the stream goes down for
whatever reason, MPlayer makes no attempt to re-establish it, and
secondly it's difficult to tell MPlayer when to stop recording
(there are command-line timing options but they don't always work,
and interrupt signals can be ignored).
"One workaround is to write a script in Python (or some other
language) that runs MPlayer inside a "pseudo-terminal" and control
it via this terminal. The script can then take responsibility of
restarting MPlayer if necessary, and sending a keystroke to close
it down at the end."