Is it your deepest wish to archive those old VHS cassettes (that you will never watch again anyway) to DVD/HDD and trash them afterward? There is help.

Get a video card, i have a Hauppauge WinTV-PVR-350, which is fine so far.

Unfortunately there is a DMA problem so you have to disable it in the Linux Kernel source (i am serious). This patch is for kernel 2.6.25-gentoo-r8, the ivtv package is kernel-dependent.

Code: hauppauge.patch

--- drivers/media/video/ivtv/ivtv-streams.c.original	2008-12-30 22:07:22.000000000 +0100
+++ drivers/media/video/ivtv/ivtv-streams.c	2008-12-30 22:07:22.000000000 +0100
@@ -81,7 +81,7 @@ static struct {
 	{	/* IVTV_ENC_STREAM_TYPE_MPG */
 		"encoder MPG",
 		VFL_TYPE_GRABBER, 0,
-		PCI_DMA_FROMDEVICE, 0, V4L2_BUF_TYPE_VIDEO_CAPTURE,
+		PCI_DMA_FROMDEVICE, 1, V4L2_BUF_TYPE_VIDEO_CAPTURE,
 		&ivtv_v4l2_enc_fops
 	},
 	{	/* IVTV_ENC_STREAM_TYPE_YUV */
It also did not work when a second NIC was in the machine, no idea why...

You need the ivtv and v4l2 drivers from the kernel.

ivtv-ctrl segfaults under root, but works fine as normal user which is sufficient. I had a cable from SCART to S-VHS which did not transmit any sound to the S-VHS input so i transferred the sound via an additional antenna cable from the VCR to the card. The inputs for this were: video 2, audio 0

Now i have a new cable that plugs into the second video jack of the card. The inputs: video 5, audio 1. This one is fine.

If you archive the VHS cassett for some computer illiterate moron, you might want to burn it onto a single DVD to make it easier to understand. It is easy to limit the max file size and select the sample rate:

Code: haupauge-record-dvd.sh

#!/bin/bash
#
# parameters: 1=minutes, 2=isofilename

# ------- settings -----------
# disk size in MB
#DISKSIZE=4200
DISKSIZE=4240
# audio bitrate in kBit/s
ABR=224
# VCR channel
CHANNEL=41
# max video bitrate (max possible 8000000)
MAXVBR=5000000

# -------- code --------------

TMPDIR=/tmp/dvdencode-${PPID}
mkdir -p $TMPDIR
TMPRAW=$TMPDIR/raw.mpg
TMPFILE=$TMPDIR/clean.mpg
TMPDVD=$TMPDIR/dvd
ISOFILE=recorded-${PPID}.iso

if [ $# == 0 ] 
then
  MINUTES=1
else
  MINUTES=$1
  if [ $# == 1 ]
  then
    ISOFILE=recorded-${PPID}.iso
  else
    ISOFILE=$2.iso
  fi
fi

SECONDS=`echo $[60*$MINUTES]`
# calculate video bitrate in kBit/s
VBR=`echo $[($DISKSIZE*8000-$ABR*$SECONDS)*1024/$SECONDS]`
if [ $VBR -gt $MAXVBR ]
then
 VBR=$MAXVBR
fi

echo ">>>> encoding $MINUTES minutes video for expected max $DISKSIZE MB file with $VBR Bit/s to $ISOFILE"

# select channel 41
ivtv-tune -t europe-west -c $CHANNEL

# video input = composite (s-vhs cable), mode = PAL, audio input = tuner (coax cable), set video bitrate, set audio bitrate, DVD stream type
v4l2-ctl --set-input 2 -s pal-D --set-audio-input=0 -c video_bitrate=$VBR -c audio_layer_ii_bitrate=10 -c stream_type=3

dd if=/dev/video0 of=$TMPRAW 1>&2& PIDDD=$!
(sleep ${SECONDS}s && kill $PIDDD)
ffmpeg -v 0 -vcodec copy -i $TMPRAW -target dvd $TMPFILE && rm $TMPRAW && dvdauthor -o $TMPDVD -t $TMPFILE && dvdauthor -o $TMPDVD -T && rm $TMPFILE && mkisofs -dvd-video -o $ISOFILE $TMPDVD && rm -rf $TMPDIR

#cdrecord -v dev=3,0,0 $ISOFILE && rm $ISOFILE
If you record for yourself, you might want to use DIVX for its great compression capabilities. This script will shrink it 3 times more than the MPG/DVD codec above:

Code: haupauge-record-divx.sh

#!/bin/bash
#
# parameters: 1=minutes, 2=filename

# ------- settings -----------
# VCR channel
CHANNEL=41
# video bit rate
VBR=2000000

# -------- code --------------

if [ $# == 0 ] 
then
  MINUTES=1
else
  MINUTES=$1
  if [ "$#" == "1" ]
  then
    OUTFILE=recorded.${PPID}
  else
    OUTFILE=$2
  fi
fi
SECONDS2=`echo $[30*$MINUTES]`
/bin/date "+%Y.%m.%d %H.%M.%S" 
echo ">>>> encoding $MINUTES minutes video with $VBR Bit/s to $OUTFILE"
ivtv-tune -t europe-west -c $CHANNEL
v4l2-ctl --set-input 5 -s pal-D --set-audio-input=1 -c video_bitrate=$VBR -c audio_layer_ii_bitrate=10 -c stream_type=3

dd if=/dev/video0 of=${OUTFILE}.mpg 1>&2& PIDDD=$!
sleep ${SECONDS2}s
/bin/date "+%Y.%m.%d %H.%M.%S" 
nice -n 5 mencoder ${OUTFILE}.mpg -ovc xvid -xvidencopts bitrate=687:autoaspect -vf pp=lb -oac mp3lame -lameopts fast:preset=standard -o ${OUTFILE}.avi & PIDMENC=$!
#renice 5 -p $PIDMENC
sleep ${SECONDS2}s
/bin/date "+%Y.%m.%d %H.%M.%S" 
kill $PIDDD
renice 0 -p $PIDMENC
wait $PIDMENC
rm ${OUTFILE}.mpg
/bin/date "+%Y.%m.%d %H.%M.%S" 
If you want to SEE what comes into your video card use this:

Code: haupauge-showvideo.sh

#!/bin/bash
#
#BITRATE=3000000
BITRATE=100000

ivtv-tune -t europe-west -c 41
v4l2-ctl --set-input 5 -s pal-D --set-audio-input=1 -c video_bitrate=$BITRATE -c audio_layer_ii_bitrate=10 -c stream_type=3
#mplayer pvr:// -tv chanlist=us-cable:input=0:normid=10:channel=15 -pvr fmt=dvd:aspect=1 -v
#mplayer pvr:// -pvr fmt=dvd:aspect=1 -v
mplayer /dev/video0 -vo x11 -framedrop