Capture and encoding DV with CentOS 5

It has been more than a year ago. I was planning to backup some footage that was stored on mini-DV tapes, These tapes where shot some years ago using my JVC GR-DVP3 mini-DV camcorder. I thought it would be wise to make some kind of backup, since I’m not planning on buying another mini-DV camcorder when this one should stop working. However when finally I had some time and more importantly was in the mood to start this project, my camcorder refused reading the data on tape. Apparently the heads have gotten dirty and it needed a cleaning tape to get it removed. At this point my project stranded. I didn’t feel like spending money on a device I wasn’t going to use anymore, until a few weeks ago.

While ordering a new cartridge for my printer, I noticed an attractive deal on 5 mini-DV tapes including a cleaning tape. After receiving the package and running the cleaning tape for about 10 seconds, my camcorder was up and running again. Now I had to figure out all over again how to get dvgrab running on my CentOS 5 laptop and encoding the footage to a format that would play seamlessly on my Xtreamer. Here we go…

CentOS 5 and FireWire

Getting CentOS 5 working with firewire is a little tricky. The default CentOS 5 kernel doesn’t include firewire support. Therefore you should use the CentOSPlus kernel that is available thru the CentOSPlus repository.Here you can read more in to detail about the CentOSPlus repository:

To enable the CentOSPlus repository, edit the file /etc/yum.repos.d/CentOS-Base.repo and search for the [centosplus] section. Change enabled=0 to enabled=1 to enable the CentOSPlus repository.

Next, update the kernel by running: ‘yum update’ and reboot your system in order to use the newly installed kernel. After restarting your system, verify that you are running the centosplus kernel.

[root@ascii ~]# uname -r
2.6.18-194.32.1.el5.centos.plus
[root@ascii ~]#

Next, try loading the raw1394 module.

[root@ascii ~]# lsmod | grep 1394
[root@ascii ~]# modprobe raw1394
[root@ascii ~]# lsmod | grep 1394
raw1394                60785  0 
ieee1394              393913  1 raw1394
[root@ascii ~]# ls -ld /dev/raw1394
crw------- 1 root root 171, 0 Feb 16 12:56 /dev/raw1394
[root@ascii ~]#

Your system should now be ready to use dvgrab.

Using dvgrab

Install dvgrab using yum install dvgrab. With this utility you can capture DV or MPEG-2 Transport Stream (HDV) video and audio data from FireWire. On the net I found a useful script written by Florin Andrei for running dvgrab.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/sh
 
# 20060421
# Florin Andrei <florin@andrei.myip.org>
 
if [ ! $1 ]; then
  echo "Usage: $0 dirname"
  exit
fi
name=$1
 
mkdir -v ${name} || exit
pushd ${name}
mkdir -v dv || exit
pushd dv
 
dvgrab --autosplit --size 0 --format dv2 --opendml \
  --noavc --timestamp --frames 0 --buffers 200 ${name}-
popd
popd

Just save this script in for example /usr/local/bin/grab and run the script like grab video1 and press play on your camcorder. The script will create a directory ‘video1′ and puts the captured data inside it. Dvgrab will detect whenever a new recording starts and store it into a separate file.

Using mencoder

Now that the raw DV data from tape have been captured to disk, I want to encode it to a format that playbacks fine on my Xtreamer. This was the most difficult part. I’ve found a lot of encoding examples using ffmpeg and mencoder, but a lot to those didn’t work or seems to playback horrible. But I’m happy to tell that I’ve found a solution that works fine for me.

But first, install mencoder. Mencoder is available thru the rpmforge repository. Here you can read all about how to make use of this repository:

After hooking up with the rpmforge repository, use yum install mencoder to install mencoder on your system.

I have written a little script that could be run from within the directory that contains the captured DV data. It’s a bit ugly, but I think it contains useful information.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/perl -w
#
# 20110216 Niels van Sluis, <niels@van-sluis.nl>
 
use strict;
 
my $mencoder = "/usr/bin/mencoder";
my $encode1 = "-ovc x264 -x264encopts pass=1:turbo:bitrate=2000:frameref=1:analyse=all:me=umh:subme=4:trellis=1:bframes=1:subq=4:mixed_refs:weight_b:no_fast_pskip:direct_pred=auto:mixed_refs:nr=200 -vf pp=fd,scale=720:576,harddup -oac copy";
my $encode2 = "-ovc x264 -x264encopts pass=2:bitrate=2000:frameref=3:analyse=all:me=umh:subme=6:trellis=1:bframes=1:subq=6:mixed_refs:weight_b:no_fast_pskip:direct_pred=auto:mixed_refs:nr=200 -vf pp=fd,scale=720:576,harddup -oac copy";
my $concat = "-forceidx -oac copy -ovc copy";
 
my $cmd;
my $f;
my $filelist = "";
 
 
my @files = <*>;
foreach $f (@files) {
  if($f =~ /avi$/) {
    $filelist .= "ff-$f ";
    $cmd = "$mencoder $f -o /dev/null $encode1";
    system($cmd);
    $cmd = "$mencoder $f -o ff-$f $encode2";
    system($cmd);
  }
}
 
$cmd = "$mencoder $concat -o full.avi $filelist";
print $cmd, "\n";
system($cmd);

To be honest I’ve not yet finished my little project to backup my DV tapes. Luckily I now have some documentation in case I choose to postpone this job to next year… ;-)

Leave a Reply