PVR Recorder-Script

I’m running a Hauppauge PVR150 along an older Primio analog TV-card. I wasn’t really happy with the scripts, which were mentioned on the IVTV-Wiki. In particular I didn’t like how the recording period needed to be entered. So I wipped up this little script. For actual timed copy of the video stream ffmpeg is used in copy mode.

#peak_bitrate=5500000   # for a little better quality 

if [[ -z "$channel" || -z "$length" || -z "$output" ]] ; then
    echo must supply exactly 3 arguments
    exit 1;

ivtv-tune -d $device -t europe-west -c $channel
v4l2-ctl -d $device \
    -c video_peak_bitrate=$peak_bitrate,video_bitrate=$bitrate,stream_type=3
ffmpeg -y -v 0 -i $device -t $length -vcodec copy \
    -acodec copy $output 2>/dev/null

It is executed with three arguments:

rec-tv.sh <channel> <record period> <output file name>

I’m starting the recording with something like this:

echo ./rec-tv-sh E5 1:45:00 recording.mpg | at 22:00

An improvement to be implemented is a mapping from raw channel numbers to sensible program names.

With the peakbitrate/bitrate combination of 4800000/4300000 you get about 2 hours and 10 minutes onto a standard DVD. With the 550000/4800000 combination you get about 1 hour and 50 minutes onto a DVD, while the picture is somewhat better.