Automatic Capture and Convert Digital Camcorder Video

From assela Pathirana
Revision as of 04:37, 28 June 2011 by Root (talk | contribs) (→‎Automating the whole process)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
Koninginnedag 2011 DSC 1893.JPG

Introduction

There are hundreds of software applications that can capture Digital Video from a IEEE 1394 camcorder (pretty much any camcorder after analog hi-8, before MPEG camcorder era). Some for money and others for free. However, faced with several shoe boxes full of Mini-DV tapes, what I needed was a nearly automatic system. Like pop-in the cassette to the camcorder (which is connected to the computer via IEEE 1394 cable) and `press a button' to get the whole content of the cassette captured, deinterlaced and transcoded to MPEG-4 -- a format that is far more suitable for computer storage and playback. The reason is simple, if you do something for one time, clicking buttons on a nice user interface is fun (If you like to do this you can use kino for capture and handbrake for transcoding.), but the fun wears off quickly when you try to do the same for fifty times (=fifty miniDV tapes) in a consistent manner.

Software needed

For my approach I needed three pieces of software:

  • dvgrab - for (obvious) task of grabbing dv from tapes to hard drive.
  • dvcont - for controlling the camcorder from the computer.
  • HandBrakeCLI - commandline version of handbrake software for transcoding the video.

In my current Ubuntu 10.10 system, the whole installation requires two commands.

sudo apt-add-repository ppa:stebbins/handbrake-releases  # as explained at https://edge.launchpad.net/~stebbins/+archive/handbrake-releases
sudo apt-get install handbrake-cli libavc1394-dev dvgrab # libavc1394 provides dvcont command

Now the manual pages of the commands dvgrab, dvcont and HandBrakeCLI (or their respective web pages) will give an overview of the use of these commands.

Automating the whole process

Here is a simple bash script that can automate the whole process of

  1. Rewinding the tape to the begining
  2. Capture the content of the tape
  3. Transcode to mpeg-4
#!/bin/bash
#!/bin/bash
# save as ieee2mpeg4

function handle {
   echo "Error"
   exit 8 
}
trap handle ERR

if [ "$#" -lt 1 ]; then 
   echo "USAGE : $0 <unique-name-of-the-casette> [DEBUG]" 
   exit 1
fi
if [ -d "./library/$1" ]; then 
   echo "directory $1 exists in library. Use another name!"
   exit 5
fi
if [ !  -d "./library" ]; then 
   mkdir ./library
fi
if [ !  -d "./work" ]; then 
   mkdir ./work
fi
mkdir ./library/$1
#rewind the tape
if [ "$#" -gt 1 ]; then set -x; fi
dvcont rewind
echo -n "Rewinding tape : "
while [ "`dvcont status`" != "Winding stopped" ]; do 
	echo -n '*'
done 
echo  " .... done!"
echo "Now capturing dv .."
rm -rf work/*
dvgrab --size 0 --opendml --format raw --autosplit=60 work/capture-
for item in `ls ./work/*.dv |sed 's/.dv$//'` ; do 
	echo $item 
        HandBrakeCLI -i ${item}.dv -o ${item}.m4v -e x264 -b 1000 -B 192 -d slower
done
mv work/capture-*.m4v library/$1

What about editing?

What I needed was a efficient solution that did not involve manual work. If needed I could have edited the videos at captured stage (DV format). But, I chose not to, for spending hours in front of the computer and editing videos is not my idea of fun. On the other hand, it is possible to edit videos at MPEG-4 stage too. (purists may say that that could degrade the quality, which is true. But here we are talking about videos taken by a VGA resolution budget camcorder -- not Hollywood movies!).