Transcoding DV Tapes

Today we enjoy half decent high definition video recording capabilities in pretty much any device which has an imaging sensor in it. About ten years ago that wasn’t the case, back then people bought so-called DV cameras. These DV cameras recorded more or less DVD resolution footage with limited compression onto digital video (DV) tapes, usually 60 minutes per tape. Some awkward choices in the DV format were made, particularly the fact that it was recorded at 50 interlaced fields per second, which can be interpolated to either 25 or 50 actual frames per second.

Most DV cameras allowed the content of a DV tape to be directly transfered to a computer fitted with a FireWire 400 interface, a 60 minute tape would result in slightly less than 15 GB of data transfered. This is fairly easy to do on a modern Linux system (keep in mind that the transfer is 1:1, so 60 minute tape requires 60 minutes to entirely transfer):

# dvgrab -rewind -showstatus -timestamp -autosplit -size 20000 -format qt

While most media players on Linux will play these captured video fragments directly, many media players on other platforms won’t. Also the resulting files are ridiculously large, so they aren’t particularly handy to keep around indefinitely. So typically you’ll want to transcode them into something more efficient, for example (at it’s simplest):

# mkdir mp4
# for F in *.mov; do \
    avconv \
      -i $F -filter:v yadif=1 -r 50 \
      -c:v libx264 -preset:v fast -profile:v main -level:v 31 -tune:v film -g 50 -crf 18 \
      -c:a ac3 -b:a 320k \
      mp4/${F}.mp4; \
  done

The above command will transcode all captured video fragments to high quality H264/AVC video and AC3 (Dolby Digital) audio. The effective video quality is controlled via the CRF parameter, transcoding a set of video fragments totaling about 60 minutes, resulted in the following sizes for me:

CRF
17
18
19
20
21
22
23
Size 4.9 GB 4.1 GB 3.4 GB 2.8 GB 2.4 GB 2.0 GB 1.7 GB

Keep in mind that CRF encoding tries to keep the quality constant, so if you have very unsteady or action rich footage the resulting files may end up bigger for you. Also keep in mind that some filesystems don’t allow single files to exceed 2GB, so if you have a single continuous piece of footage of 60 minutes, you probably should use CRF 23, otherwise I’d recommend sticking to CRF 18 for very good quality.

Ideally we’d like our filesystem modification dates to match the recording timestamp and having some metadata in each files can be helpful at times as well, so alternatively we might transcode like so:

# mkdir mp4
# for F in *.mov; do \
    avconv \
      -i $F -filter:v yadif=1 -r 50 \
      -c:v libx264 -preset:v fast -profile:v main -level:v 31 -tune:v film -g 50 -crf 18 \
      -c:a ac3 -b:a 320k \
      -metadata title="$(echo ${F} | sed 's#dvgrab-##' | sed 's#.mov##' | tr '_' ' ' | tr '-' ':')" \
      -metadata artist="John Doe" \
      -metadata album="Holiday" \
      -metadata description="JVC GR-XXXX" \
      mp4/PAL50_$(echo ${F} | sed 's#dvgrab-##' | sed 's#.mov##' | tr -d '.' | tr -d '-').MP4; \
    touch \
      -t $(echo ${F} | sed 's#dvgrab-##' | sed 's#.mov##' | tr -c '[0-9]\n' '_' | awk -F '_' '{print $1 $2 $3 $4 $5 "." $6}') \
      mp4/PAL50_$(echo ${F} | sed 's#dvgrab-##' | sed 's#.mov##' | tr -d '.' | tr -d '-').MP4; \
  done

Lastly you might want to burn the resulting video files to a DVD, and generating a good ISO image is easy enough as well:

# cd mp4
# md5sum *.MP4 > MD5SUMS.TXT
# genisoimage -J -l -V HOLIDAY_2005 -o ../HOLIDAY_2005.ISO .

Most vaguely recent BluRay players should be able to play the files on the resulting disc.