digitze_your_vhs_tapes

Digitize your VHS Tapes

i started this adventure with a cheap usb device called easyCap. i thaught i could just play a video tape in my old player that i've kept from back in the days, use ffmpeg to convert it to mpeg4 and that's it.. however, the easyCap device was no good at all. the windows drivers are total crap anyway and did not even work correctly in windows 7 and even on xp they kept crashing .. under linux the device constatly dropped frames and was useless. the second try is described at the end of this post. i used an old wintv-pvr 500 card with an on-board mpeg2 encoder where you can just save the stream coming from it to a harddribe. i had to use an old pc for that as it is an old PCI card, but that did at least work.. however, video image quality was still no good. when i searched for a good software filter to correct horizontal disalignemnt between each line i found out that what i really needed for the task was a TBC device. TBC stands for Time base corrector. the thing with old video tapes is this: on a video tape, the lines of each image are stored sequentially. the vcr tries to read each line in a more or less constant pace and puts this out to the tv. to synchronize the lines there is a pulse at the begining or ending of each line, i don't remember the details anymore. however, an old analogue tv does not worry about the exact length of the line, it just keeps projecting it to the screen until it reaches basically the next linebreak. however, digital tv's and capture devices operate with pixels. they scan only so many pixels until a line is complete and then they start with the next one. this results in shifted lines if the output from the vcr is not in a percfectly steady pace which it never will be, as there is too much mechanical friction involved in the process. even worse, when you copy a vcr tape to another, the effect basically gets multiplied and it gets worse every time you coupy the tape. TBC's can be bouth as separate devices, as integrated parts of a VCR and as it turned out, the best ones are installed in old Sony Digital 8 cameras of the more advanced lines. I ended up buying a used DCR-TR8100E which was even hacked to feature dv-in .. the nice thing about that is, that not only can it work as a dv-signal receiver but also as an analoge signal receiver. this means, it can capture an analogue video signal coming from t a vcr and it will then send it through its internal TBC, digitize it and send out a DV-Stream which can be captured by the computer through firewire.

this finally delivers as good an image quality as you can get it from an old blurry VHS tape, but most vertical lines are now close to straight and there is almost no disalignment between the lines. also it managed to produce a steady video image even in parts of the tapes that where disturbed when watching on an old tv..

to capture the video with linux i used the command line tool dvgrab. i used the gui program kino only to crop the captured dv stream before i then re-encoded it in mpeg4 with ffmpeg. kino kept hanging in regular intervals causing frame drops during one or two seconds of video which then resultet in thos seconds of movie not being captured. dvgrab didn't do that, it recorded every single frame even on a 5 hour video i captured.

i'll post those exact command lines with all the parameters i used later on when i use them the nex time as i forgot to note it down the last time i did.. damned..

to capture the video coming through the camera with TBC i use dvgrab

cd <directory where you want to store the recorded movies>
dvgrab -a -i

the -a enables auto scene detection. this only works if your source is a DV tape, -i is the interactive mode. this allowes you to even control your camera and start capturing by hitting the “c” button..

there is no monitor output.. i simply attached a tv to my vcr for that matter..

once your movie is recorded with dvgrab you will notice that it creates several 1GB files which need to be stitched together.. most probably the begining and end of the movie is also not exactly the start and end of your capturing .. so you need to crop the recording too.. for that i use kino. however, on ubuntu there is some problem with the way kino outputs audio, so i start it with this command

padsp kino

first drag and drop all your recorded files into the storyboard. usually kino adds them in the right order, so you only need to trim the first and last part using the trim tab on the right. when you are done you can export the movie using the export tab. in there i choose “DV File” and i set the Filetype to “Raw DV” and under “Other file options” i uncheck everything. then simply click “Export” and kino will creat a singe file trimmed to the real start and end of your movie you want to keep.

the resulting video file is quite big for the quality it offers.. so to archive a set of old vhs tapes you probably would want to shrink that a bit without losing too much of the original “quality” (if i may call it that way). i use MPEG4 for that matter as it does a pretty good job.. it even eliminates some of the grains in the original adding to an overall even better looking picture.

i composed a little script that takes all dv files in a folder and converts them to mpeg4 files.

#!/bin/bash
mkdir originals
for f in *.dv; do 
        ffmpeg -y -i "$f" -b 2M -bt 6M -vcodec libx264 -vpre libx264-slow -vf yadif -acodec libfaac -ac 2 -ar 48000 -ab 128k -threads 6 "$f.mp4"
        mv "$f" originals/
done

Please note that the option “-threads 6” is set.. set this to how many ever cores you have in your system.. i currently am doing this on a single cpu 6 core amd cpu.. so i use 6 threads..

since i had already written it, here it is.. maybe this proves useful for a different project in the future, who knows :)

so i finally took an old pc and put my old hauppauge wintv-pvr 500 in it. the card delivers an mpeg2 stram which can be caputred with close to no cpu load, so no problem here for an old pc :)

in ubuntu install the ivtv-ctrl package and then run

v4l2-ctl -d /dev/video0 -i 2 

this selects the composit input as the current source

now open vlc and choose to open a device, then choose PVR and select no other options just hit play.. you should now see what's coming in to the pvr card.

in the view menu select “advanced controls” you now see a record button which by default will save the current stream as it comes from the card to a subdirectory in your user home called Video. to change this go to tools→prefrences→input & codecs where you see “record directory or filename” .. if you click on “all” under “show settins” in the bottom left corner you should also find the checkbox to chose between raw stream and some default vlc format .. however i recommend leaving it set to record the raw stream.

after you have successfully recorded the move it's time to de-interlace and further compress it (h264 in my case).. i do that with ffmpeg:

ffmpeg -y -i input.mpg -b 750k -bt 4M -vcodec libx264 -vpre libx264-slow -vf yadif -acodec libfaac -ac 2 -ar 48000 -ab 128k -threads 6 output3.mp4
  • digitze_your_vhs_tapes.txt
  • Last modified: 13.06.2012 22:34
  • by Pascal Suter