Actions

Convert VHS to DVD

From RonWareWiki

Introduction

I've been trying to convert old VHS tapes of family events to DVD, so they would remain intact in the future. It is maddeningly difficult to get everything working under Linux, and there doesn't seem to be a "point-and-click" solution which works completely. This page is a guide to how I solved that problem in a manner satisfactory to me.

Requirements

You will need:

  1. A VCR player with audio/video output. Most VCRs will work.
  2. An analog-to-digital converter. Mine is "Firewire" connected, which is recommended for capturing video streams.
  3. A DVD writer, and DVD-R media
  4. ffmpeg (get the latest SVN source tree), with this patch
  5. dvdauthor
  6. mkisofs and growisofs

Problems

Lots of things went wrong, trying to convert a simple VHS tape to DVD.

  • At first I tried using Kino, but it always crashed at some point
  • Using "dvgrab" to get the DV (digital video) directly, worked ok - but required over 20G for a 120 minute tape, and another 4G for the mpeg etc. Too much disk space.
  • ffmpeg without options gave a nice small mpeg file, but it was in the wrong format to convert to DVD
  • ffmpeg with the '-target dvd' option make a good mpeg for DVD, but a two-hour tape made an mpeg which was too big
  • the burned DVD would not play in one of my players
  • Saving DV and then converting to mpeg takes almost twice the runtime of the video

Solutions

  • Use updated and patched ffmpeg, which allows directly grabbing DV from the FireWire device and compressing into an mpeg file.
  • Change the quality of the compression to be lower than the default, so a long tape can fit on a DVD
  • Use DVD-R media, so the DVD will play in older standalone players
  • With the dvd script below, recording a T-120 tape in its entirety to DVD takes 140 minutes, instead of the 250 minutes the old way.

For further investigation

  1. Is it possible to view while recording?
  2. How can one choose the minimal quality distortion for a given tape so it fits on a DVD?
  3. Is it possible to automatically detect end-of-recording? That is to say, when a tape is not full, can ffmpeg understand and suppress the empty sections?

Example script

I call this script 'dvd'. Invoke it with the name of the ISO image you will want to create (without the .iso extension). Start playing your VCR, put a blank DVD-R in your writer, and after a bit you'll have a playable DVD of your VHS tape:

#!/bin/bash

qscale=10			# MPEG quality
duration=7200			# 2 hour tape
target=video			# name of the final ISO file
device=/dev/dv1394-0 		# Firewire device
writer=/dev/hdc			# device for DVD writer

syntax()
{
cat <<'EOF'

Converts video from your FireWire device to a DVD.
Syntax: dvd [options] [targetname]
Options:  
	-30, -60, -120, -240 - record for that many minutes
	-d devname - set 'devname' to be your FireWire device (default: /dev/dv1394-0)
	-w devname - set 'devname' to be your DVD writer (default: /dev/hdc)
	-h - print this help
If you don't provide a 'targetname', 'video' will be used (e.g. 'video.iso'
will ultimately be produced).

Make sure you have a blank DVD-R in your writer, and that the video feed has
begun, before you launch this script.

EOF
}
getopt_simple()
{
	while [ ! -z "$1" ]
	do
		case "$1" in
		'-30' 	) duration=1800 ; qscale=1 ;;
		'-60' 	) duration=3600 ; qscale=5 ;;
		'-120' 	) duration=7200 ; qscale=10 ;;
		'-240' 	) duration=14400 ; qscale=15 ;;
		'-d'	) device=$2 ; shift ;;
		'-w'	) writer=$2 ; shift ;;
		'-h'	) syntax ; exit ;;
		*	) target=$1  ;;
				
		esac
		shift
	done
}

getopt_simple $*

echo "Generating mpeg from raw DV"
ffmpeg -f dv1394 -i $device -target dvd -t $duration -qscale $qscale $target.mpg 

echo "Turning the mpeg into a video DVD file system"
dvdauthor -o $target.fs -t $target.mpg
dvdauthor -o $target.fs -T

echo "Making ISO"
mkisofs -dvd-video -o $target.iso $target.fs

echo "Burning DVD"
growisofs -dvd-compat -Z $writer=$target.iso
echo "Done!"