PDA

View Full Version : Cleaning up a multi-gen VHS source?


Denaan
27th February 2007, 11:51
I have limited experience using Avisynth for encoding DVDs to XviD, using Gordian Knot-generated scripts that i've adapted slightly, e.g. adding TDeint for deinterlacing. So i'm kind of a newbie though i understand a bit about writing scripts.

Most of my experience is with commercial DVDs, but i have a DVD i'd like to encode that appears to be from a multi-generation VHS transfer -- with some rare vids, so i'm unlikely to find a better copy. I'd like to get the best picture quality possible, given the poor quality of the source.

Here's a link to two short (ca. 5 second) clips:

http://rapidshare.com/files/18516106/OZclip_demuxed.m2v
http://rapidshare.com/files/18524999/OZclip2_demuxed.m2v

I'd appreciate suggestions re scripts, filters, etc. Cheers.

scharfis_brain
27th February 2007, 17:17
This is a filter chain, that
- corrects the interlacing
- raises the overall brightness
- corrects the chroma shift
- reduces the noise by a fiar amount

loadplugin("c:\x\DGDecode.dll")
loadplugin("c:\x\tivtc.dll")
loadplugin("c:\x\ttempsmooth.dll")
loadplugin("c:\x\mvtools.dll")
loadplugin("c:\x\removedirts.dll")

Lambda = 128
BlkSize= 16
Pel = 2

mpeg2source("C:\forum\Denaan\OZclip_demuxed.d2v")
tfm(pp=0)
levels(8,1.3,200,0,255, coring=false)
mergechroma(last.crop(0,2,0,0).addborders(0,0,0,2))

pre=last

vf3=pre.MvAnalyse(BlkSize = BlkSize, Pel = Pel, isB = False, Chroma = True, idx = 3, TrueMotion = false, Sharp = 2, Lambda = Lambda, Overlap = BlkSize/2, Delta=3)
vf2=pre.MvAnalyse(BlkSize = BlkSize, Pel = Pel, isB = False, Chroma = True, idx = 2, TrueMotion = false, Sharp = 2, Lambda = Lambda, Overlap = BlkSize/2, Delta=2)
vf1=pre.MvAnalyse(BlkSize = BlkSize, Pel = Pel, isB = False, Chroma = True, idx = 1, TrueMotion = false, Sharp = 2, Lambda = Lambda, Overlap = BlkSize/2, Delta=1)
vb1=pre.MvAnalyse(BlkSize = BlkSize, Pel = Pel, isB = True , Chroma = True, idx = 1, TrueMotion = false, Sharp = 2, Lambda = Lambda, Overlap = BlkSize/2, Delta=1)
vb2=pre.MvAnalyse(BlkSize = BlkSize, Pel = Pel, isB = True , Chroma = True, idx = 2, TrueMotion = false, Sharp = 2, Lambda = Lambda, Overlap = BlkSize/2, Delta=2)
vb3=pre.MvAnalyse(BlkSize = BlkSize, Pel = Pel, isB = True , Chroma = True, idx = 3, TrueMotion = false, Sharp = 2, Lambda = Lambda, Overlap = BlkSize/2, Delta=3)

cf3=pre.MvCompensate(vf3, idx=3, thSCD2=999)
cf2=pre.MvCompensate(vf2, idx=2, thSCD2=999)
cf1=pre.MvCompensate(vf1, idx=1, thSCD2=999)
cb1=pre.MvCompensate(vb1, idx=1, thSCD2=999)
cb2=pre.MvCompensate(vb2, idx=2, thSCD2=999)
cb3=pre.MvCompensate(vb3, idx=3, thSCD2=999)

interleave(cf3, cf2, cf1, pre, cb1, cb2, cb3)
ttempsmooth(maxr=2, lthresh=10, cthresh=15, lmdiff=5, cmdiff=7)
removedirt()
selectevery(7,3)

Denaan
27th February 2007, 21:17
Thanks! Okay, i searched the forums and manged to find tivtc and ttempsmooth and now i have all the necessary dll's in my plugins directory. I can't wait to try this out, but i'm going to have to wait, because i've got a CPU-intensive XviD encode already in progress. I'll test it out and let you know how it worked as soon as i can.

Cheers.

Didée
28th February 2007, 20:05
Scharfiiiii !
idx = 3
idx = 2
idx = 1
idx = 1
idx = 2
idx = 3

All MVxxx instances are working with exactly the same clip, hence:

idx = 1
idx = 1
idx = 1
idx = 1
idx = 1
idx = 1

scharfis_brain
28th February 2007, 21:21
really? OMG. I never got behind this idx thing :(

Denaan
28th February 2007, 21:57
The results look fabulous! Thanks, again, scharfis_brain. The script (w. cropping and Lanczos resizing) runs VERY slowly, about 1 fps on my 2.6 GHz P4, which for a two-pass encode means a one-hour film would take about 50 hrs to encode!

I have a couple of questions for you below.

Here's a comparison of three screencaps of the same frame, encoded to XviD with the same settings, first with TDeint and no filters, second with TDeint and deen + undot, third with scharfis_brain's script (click on thumbs for full size):

No filters
http://fapomatic.com/thumbs/0708/no_filters.png (http://fapomatic.com/show.php?loc=0708&f=no_filters.png)

Deen + Undot
http://fapomatic.com/thumbs/0708/deen.png (http://fapomatic.com/show.php?loc=0708&f=deen.png)

Script
http://fapomatic.com/thumbs/0708/script.png (http://fapomatic.com/show.php?loc=0708&f=script.png)

Here are the three 5-second clips from which the screens were taken:

http://rapidshare.com/files/18765172/OZ_no_filters.avi
http://rapidshare.com/files/18765484/OZ_deen.avi
http://rapidshare.com/files/18765628/OZ_script.avi

FYI, here is the script of the 2nd clip, same as the first except for the addition of deen and undot:

# PLUGINS
LoadPlugin("C:\x\DGDecode.dll")
LoadPlugin("C:\x\TDeint.dll")
LoadPlugin("C:\x\Deen.dll")
LoadPlugin("C:\x\Undot.dll")

# SOURCE
mpeg2source("Q:\DVD\OZ.d2v", idct=0)

# TRIM
trim(2270,2395)

# DEINTERLACING
TDeint()

# CROPPING
crop(16,2,694,568)

# RESIZING
LanczosResize(640,480)

# DENOISING
Deen ()
Undot ()

I noticed in your script, scharfis, you select up to 3 frames forward and backward to analyze and combine, which gives a total of 7 frames to be interleaved. Just to see how it would affect speed and picture quality, i modified your script to select only 2 frames forward and back, for a total of 5 frames interleaved, changing a portion of the script as follows:

vf2=pre.MvAnalyse(BlkSize = BlkSize, Pel = Pel, isB = False, Chroma = True, idx = 2, TrueMotion = false, Sharp = 2, Lambda = Lambda, Overlap = BlkSize/2, Delta=2)
vf1=pre.MvAnalyse(BlkSize = BlkSize, Pel = Pel, isB = False, Chroma = True, idx = 1, TrueMotion = false, Sharp = 2, Lambda = Lambda, Overlap = BlkSize/2, Delta=1)
vb1=pre.MvAnalyse(BlkSize = BlkSize, Pel = Pel, isB = True , Chroma = True, idx = 1, TrueMotion = false, Sharp = 2, Lambda = Lambda, Overlap = BlkSize/2, Delta=1)
vb2=pre.MvAnalyse(BlkSize = BlkSize, Pel = Pel, isB = True , Chroma = True, idx = 2, TrueMotion = false, Sharp = 2, Lambda = Lambda, Overlap = BlkSize/2, Delta=2)

cf2=pre.MvCompensate(vf2, idx=2, thSCD2=999)
cf1=pre.MvCompensate(vf1, idx=1, thSCD2=999)
cb1=pre.MvCompensate(vb1, idx=1, thSCD2=999)
cb2=pre.MvCompensate(vb2, idx=2, thSCD2=999)

interleave(cf2, cf1, pre, cb1, cb2)
ttempsmooth(maxr=2, lthresh=10, cthresh=15, lmdiff=5, cmdiff=7)
removedirt()
selectevery(5,2)

That sped things up considerably, and the picture quality was still almost as good. It's hard to tell much from a 5-second clip, but the screencaps look about the same.

Here's the same 5-second clip using the modified script:

http://rapidshare.com/files/18771331/OZ_scriptmod.avi

Can you see much of a difference? Any thoughts on the merits of the original vs. mod?

I was able to search and learn about almost everything in the script, but i still have one nagging question:

I'm guessing the following is to "correct the chroma shift", but can you explain how it works?

mergechroma(last.crop(0,2,0,0).addborders(0,0,0,2))

Denaan
28th February 2007, 22:04
Just saw Didée's post after i had already posted.

I'll try it with the idx change and see if that affects speed and/or picture quality. :-P