tvr: TV Recorder shell script
A friend of mine asked me to record a show for him, since he doesn’t have a VCR. I don’t have a VCR either, and even if I did, what would be the point to record the show on tape while he can’t still play it?
The best solution is my computer. It has Linux and a TV card. I tried a few times before to record TV programs using MEncoder, but without success. This morning, I took time to try again, and I came up with a shell script that makes it work for me.
The script requires the aumix application, the xawtv package and the MPlayer package. MPlayer would only work with my standard BT878 capture card if interfaced via Video4Linux2. Furthermore, it would not change channels even if specified has -tv channel=[number] or tv://[channel]. In this case, I’m using v4lctl (part of the xawtv package) to do it. However, the later would not work until I make a xawtv configuration file, using scantv, listing all available channels on TV.
I use aumix in order to set the input channel of my mixer on the Line track.
So, here it is. Play with it!
#!/bin/bash
# tvr: TV Recorder shell script, version 0.1
# 2006-04-05, by Remi (www.remino.net)
#
# LICENSE: This work is licensed under the Creative Commons
# Attribution-ShareAlike 2.5 Canada License. To view a copy of this license,
# visit http://creativecommons.org/licenses/by-sa/2.5/ca/ or send a letter to
# Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.
CHANNEL=$1
VFLDEV=/dev/video0
TVOPTIONS="-tv driver=v4l2:device=$VFLDEV:normid=1:width=320:height=240"
VIDEOENC="-ovc lavc -lavcopts mbd=1:v4mv"
AUDIOENC="-oac mp3lame"
ENDPOS="-endpos $2"
FILEDATE=`date +%Y%m%d-%H%M%S`
OUTPUTFILE="tv-$1-$FILEDATE.avi"
AUMIXOPTIONS="-lR"
# The following will not work if the channels have not been scanned using scantv
# (Output of scantv must be in xawtv config file, like ~/.xawtv.)
v4lctl -c $VFLDEV setstation $1
# Makes sure the record input on the mixer is set to the Line track.
# The playback volume can be muted without problem.
aumix $AUMIXOPTIONS
mencoder $TVOPTIONS $VIDEOENC $AUDIOENC $ENDPOS tv:// -o $OUTPUTFILE


