Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 20th January 2014, 04:44   #1  |  Link
hydra3333
Registered User
 
Join Date: Oct 2009
Location: crow-land
Posts: 539
salvaging "home" transfers of old VHS home videos to DVD

Hello. Following on from these :-
"The power of Avisynth: restoring old 8mm films" http://forum.doom9.org/showthread.php?t=144271
"Capturing and restoring old 8mm films" http://forum.doom9.org/showthread.php?t=165975
"The power of Avisynth: salvaging "botched" transfers of old 8mm films to DVD." http://forum.doom9.org/showthread.php?t=161493
... a few questions about motion stabilization and equivalent scripts:

a) At http://forum.doom9.org/showthread.php?p=1618761#post1618761 there are some "March 2013" functions to perform motion stabilization.
They use MSuper, MAnalyse, MDepan, DepanStabilize rather than DePanEstimate and DePanStabilize.
Is this the way to go ? eg
Code:
blksize=8 # 4, 8 or 16 ( default is 8 ). Larger blocks are less sensitive to noise, are faster, but also less accurate.
overlap=4 # overlap value (0 to 4 for blksize=8) Must be even and less than block size
dct=0 # use dct=1 for clip with light flicker
super0 = MSuper(pel=2,chroma=true,sharp=2)
vect0 = MAnalyse(super0,isb=false, blksize=blksize, overlap=overlap, dct=dct, chroma=true)
globalmotion = MDepan(vect0, pixaspect=1.094, thSCD1=400, zoom=true, rot=true, range=2) #1.094 for standard PAL
DepanStabilize(data=globalmotion, rotmax=5, cutoff=0.5, prev=3, next=3, pixaspect=1.094, dxmax=20, dymax=20, method=1) # lower vibration frequency cutoff
b) My sources are about 150 old and very grainy VHS-C PAL home-video tapes captured to mpeg2 DVD (blockily) by a combo VHS-DVD recorder.
This sample clip (18Mb) is one of the less blocky ones by far:
http://www.mediafire.com/watch/s4wcr...F-testclip.mpg

I'm uncomfortable with the result from the script below, too much detail is lost but I am unsure how to trade off noise vs detail for these sources. Any suggestions ?
http://www.mediafire.com/view/9d5uup...napshot-01.png

Code:
MPEG2Source("G:\test\GOLF-testclip.d2v",info=0,ipp=true,cpu=0) 
# 
AssumeFPS(25) 
AssumeTFF()  
cropbottom(20).addborders(0,10,0,10) # because the bottom 20 lines are very badly corrupted across the board.
changefps(last,last,true) # http://forum.doom9.org/showthread.php?p=1473445#post1473445 
ii=LAST
SetMTmode(mode=2,threads=4) 
# 1. DEBLOCK really blocky source the hard way. see http://doom10.org/index.php?topic=2309.msg12233#msg12233 
SeparateFields()   # no need for pointresize, field block appear to be square
deblock_QED() # treat the blockiness introduced by the last step of the vhs-to-mpeg2dvd capture
#deblock_QED(quant1=48) # treat the blockiness introduced by the last step of the vhs-to-mpeg2dvd capture
Weave() 
AssumeTFF()  
# 2. smdegrain handles interlaced. # tr=3 means mdegrain3.
SMDegrain(tr=2, Contrasharp=true, RefineMotion=false, plane=4, Interlaced=true, pel=2, prefilter=3, blksize=8, overlap=4, Chroma=false)  
# 3. QTGMC deinterlace into double framerate, sharpen whilst we're doing it
# Preset     = "Placebo", "Very Slow", "Slower", "Slow", "Medium", "Fast", "Faster", "Very Fast", "Super Fast", "Ultra Fast", "Draft". Default "Slower" 
# SLMode     = (0,1,2,3,4) Sharpness limiting: 0 = off, [1 = spatial, 2 = temporal] : before final temporal smooth, [3 = spatial, 4 = temporal] : after final temporal smooth 
# Sharpness  = (0.0...) How much to resharpen the temporally blurred clip (default is always 1.0 unlike original TGMC) 
# NoiseDeint 	(string) 	When noise is taken from interlaced source, how to 'deinterlace' it before restoring. "Bob" & "DoubleWeave" are fast but with minor issues: "Bob" is coarse and "Doubleweave" lags by one frame. "Generate" is a high quality mode that generates fresh noise lines, but it is slower. Unknown value selects "DoubleWeave"
# StabilizeNoise 	(bool) 	Use motion compensation to limit shimmering and strengthen detail within the restored noise. Recommended for "Generate" mode
QTGMC(Preset="Slow", EdiThreads=2, Sharpness=1.4, SLMode=1, NoiseDeint="Generate", StabilizeNoise=true) # result is double framerate progressive, so re-interlate it later 
#
# 4. --- do the motion stablization here - Does QTGMC keep motion vectors that I can re-use in "MDepan" ? if so, I wonder how ?
#blksize=8 # 4, 8 or 16 ( default is 8 ). Larger blocks are less sensitive to noise, are faster, but also less accurate.
#overlap=4 # overlap value (0 to 4 for blksize=8) Must be even and less than block size
#dct=0 # use dct=1 for clip with light flicker
#super0 = MSuper(pel=2,chroma=true,sharp=2)
#vect0 = MAnalyse(super0,isb=false, blksize=blksize, overlap=overlap, dct=dct, chroma=true)
#globalmotion = MDepan(vect0, pixaspect=1.094, thSCD1=400, zoom=true, rot=true, range=2) #1.094 for standard PAL
#DepanStabilize(data=globalmotion, rotmax=5, cutoff=0.5, prev=3, next=3, pixaspect=1.094, dxmax=20, dymax=20, method=1) # lower vibration frequency cutoff
# 5. HDRAGC to adjust colours. i wonder if this is this similar to AUTOLEVELS,AUTOWHITE in FRED/JOHN scripts ?
SetMTmode(mode=5,threads=4) 
HDRAGC(coef_gain=0.1, min_gain=0.1, max_gain=0.5, coef_sat=1.0, corrector=0.8, reducer=2.0, black_clip=1.0) 
SetMTmode(mode=2,threads=4) 
#
# To do RE-INTERLACING http://forum.doom9.org/showthread.php?p=1110741#post1110741  
#    AssumeTFF().SeparateFields().SelectEvery(4, 0, 3).Weave() -
#  * AssumeBFF().SeparateFields().SelectEvery(4, 0, 3).Weave() -
#    AssumeTFF().SeparateFields().SelectEvery(4, 1, 2).Weave() -
#    AssumeBFF().SeparateFields().SelectEvery(4, 1, 2).Weave() -
# DE-INTERLACING and RE-INTERLACING http://forum.doom9.org/showthread.php?p=1374335#post1374335 
AssumeTFF()  
Blur(0,0.25).SeparateFields().SelectEvery(4,0,3).Weave() #reinterlace - ASSUMED TFF HERE # BLUR(0,1) per http://forum.doom9.org/showthread.php?p=1488308#post1488308 
AssumeTFF()  
AssumeFPS(25) 
jj=LAST
#
compareboxed4(ii,"original",jj,"deblocked+degrained+QTGMC") 
#
Function compareboxed2(Clip a, string asub, Clip b, string bsub) { 
	hClip = a.height() 
	wClip = a.width() 
	stackvertical(stackhorizontal(a.crop(0*wClip/2,0*hClip/2,-1*wClip/2,-1*hClip/2).subtitle(aSub,size=6), \ 
                                      b.crop(1*wClip/2,0*hClip/2,-0*wClip/2,-1*hClip/2).subtitle(bSub,size=6)), \ 
                      stackhorizontal(b.crop(0*wClip/2,1*hClip/2,-1*wClip/2,-0*hClip/2).subtitle(bSub,size=6), \ 
                                      a.crop(1*wClip/2,1*hClip/2,-0*wClip/2,-0*hClip/2).subtitle(aSub,size=6)))  
} 
Function compareboxed4(Clip a, string asub, Clip b, string bsub) { 
	hClip = a.height() 
	wClip = a.width() 
	stackvertical(stackhorizontal(a.crop(0*wClip/4,0*hClip/4,-3*wClip/4,-3*hClip/4).subtitle(aSub,size=6), \ 
	                              b.crop(1*wClip/4,0*hClip/4,-2*wClip/4,-3*hClip/4).subtitle(bSub,size=6), \ 
	                              a.crop(2*wClip/4,0*hClip/4,-1*wClip/4,-3*hClip/4).subtitle(aSub,size=6), \ 
	                              b.crop(3*wClip/4,0*hClip/4,-0*wClip/4,-3*hClip/4).subtitle(bSub,size=6)), \ 
	              stackhorizontal(b.crop(0*wClip/4,1*hClip/4,-3*wClip/4,-2*hClip/4).subtitle(bSub,size=6), \ 
	                              a.crop(1*wClip/4,1*hClip/4,-2*wClip/4,-2*hClip/4).subtitle(aSub,size=6), \ 
	                              b.crop(2*wClip/4,1*hClip/4,-1*wClip/4,-2*hClip/4).subtitle(bSub,size=6), \ 
	                              a.crop(3*wClip/4,1*hClip/4,-0*wClip/4,-2*hClip/4).subtitle(aSub,size=6)), \  
	              stackhorizontal(a.crop(0*wClip/4,2*hClip/4,-3*wClip/4,-1*hClip/4).subtitle(aSub,size=6), \ 
	                              b.crop(1*wClip/4,2*hClip/4,-2*wClip/4,-1*hClip/4).subtitle(bSub,size=6), \ 
	                              a.crop(2*wClip/4,2*hClip/4,-1*wClip/4,-1*hClip/4).subtitle(aSub,size=6), \ 
	                              b.crop(3*wClip/4,2*hClip/4,-0*wClip/4,-1*hClip/4).subtitle(bSub,size=6)), \ 
	              stackhorizontal(b.crop(0*wClip/4,3*hClip/4,-3*wClip/4,-0*hClip/4).subtitle(bSub,size=6), \ 
	                              a.crop(1*wClip/4,3*hClip/4,-2*wClip/4,-0*hClip/4).subtitle(aSub,size=6), \ 
	                              b.crop(2*wClip/4,3*hClip/4,-1*wClip/4,-0*hClip/4).subtitle(bSub,size=6), \ 
	                              a.crop(3*wClip/4,3*hClip/4,-0*wClip/4,-0*hClip/4).subtitle(aSub,size=6)))  
} 
Function compareboxed8(Clip a, string asub, Clip b, string bsub) { 
	hClip = a.height() 
	wClip = a.width() 
	stackvertical(stackhorizontal(a.crop(0*wClip/8,0*hClip/8,-7*wClip/8,-7*hClip/8).subtitle(aSub,size=6), \ 
	                              b.crop(1*wClip/8,0*hClip/8,-6*wClip/8,-7*hClip/8).subtitle(bSub,size=6), \ 
	                              a.crop(2*wClip/8,0*hClip/8,-5*wClip/8,-7*hClip/8).subtitle(aSub,size=6), \ 
	                              b.crop(3*wClip/8,0*hClip/8,-4*wClip/8,-7*hClip/8).subtitle(bSub,size=6), \ 
	                              a.crop(4*wClip/8,0*hClip/8,-3*wClip/8,-7*hClip/8).subtitle(aSub,size=6), \ 
	                              b.crop(5*wClip/8,0*hClip/8,-2*wClip/8,-7*hClip/8).subtitle(bSub,size=6), \ 
	                              a.crop(6*wClip/8,0*hClip/8,-1*wClip/8,-7*hClip/8).subtitle(aSub,size=6), \ 
	                              b.crop(7*wClip/8,0*hClip/8,-0*wClip/8,-7*hClip/8).subtitle(bSub,size=6)), \ 
	              stackhorizontal(b.crop(0*wClip/8,1*hClip/8,-7*wClip/8,-6*hClip/8).subtitle(bSub,size=6), \ 
	                              a.crop(1*wClip/8,1*hClip/8,-6*wClip/8,-6*hClip/8).subtitle(aSub,size=6), \ 
	                              b.crop(2*wClip/8,1*hClip/8,-5*wClip/8,-6*hClip/8).subtitle(bSub,size=6), \ 
	                              a.crop(3*wClip/8,1*hClip/8,-4*wClip/8,-6*hClip/8).subtitle(aSub,size=6), \ 
	                              b.crop(4*wClip/8,1*hClip/8,-3*wClip/8,-6*hClip/8).subtitle(bSub,size=6), \ 
	                              a.crop(5*wClip/8,1*hClip/8,-2*wClip/8,-6*hClip/8).subtitle(aSub,size=6), \ 
	                              b.crop(6*wClip/8,1*hClip/8,-1*wClip/8,-6*hClip/8).subtitle(bSub,size=6), \ 
	                              a.crop(7*wClip/8,1*hClip/8,-0*wClip/8,-6*hClip/8).subtitle(aSub,size=6)), \ 
	              stackhorizontal(a.crop(0*wClip/8,2*hClip/8,-7*wClip/8,-5*hClip/8).subtitle(aSub,size=6), \ 
	                              b.crop(1*wClip/8,2*hClip/8,-6*wClip/8,-5*hClip/8).subtitle(bSub,size=6), \ 
	                              a.crop(2*wClip/8,2*hClip/8,-5*wClip/8,-5*hClip/8).subtitle(aSub,size=6), \ 
	                              b.crop(3*wClip/8,2*hClip/8,-4*wClip/8,-5*hClip/8).subtitle(bSub,size=6), \ 
	                              a.crop(4*wClip/8,2*hClip/8,-3*wClip/8,-5*hClip/8).subtitle(aSub,size=6), \ 
	                              b.crop(5*wClip/8,2*hClip/8,-2*wClip/8,-5*hClip/8).subtitle(bSub,size=6), \ 
	                              a.crop(6*wClip/8,2*hClip/8,-1*wClip/8,-5*hClip/8).subtitle(aSub,size=6), \ 
	                              b.crop(7*wClip/8,2*hClip/8,-0*wClip/8,-5*hClip/8).subtitle(bSub,size=6)), \ 
	              stackhorizontal(b.crop(0*wClip/8,3*hClip/8,-7*wClip/8,-4*hClip/8).subtitle(bSub,size=6), \ 
	                              a.crop(1*wClip/8,3*hClip/8,-6*wClip/8,-4*hClip/8).subtitle(aSub,size=6), \ 
	                              b.crop(2*wClip/8,3*hClip/8,-5*wClip/8,-4*hClip/8).subtitle(bSub,size=6), \ 
	                              a.crop(3*wClip/8,3*hClip/8,-4*wClip/8,-4*hClip/8).subtitle(aSub,size=6), \ 
	                              b.crop(4*wClip/8,3*hClip/8,-3*wClip/8,-4*hClip/8).subtitle(bSub,size=6), \ 
	                              a.crop(5*wClip/8,3*hClip/8,-2*wClip/8,-4*hClip/8).subtitle(aSub,size=6), \ 
	                              b.crop(6*wClip/8,3*hClip/8,-1*wClip/8,-4*hClip/8).subtitle(bSub,size=6), \ 
	                              a.crop(7*wClip/8,3*hClip/8,-0*wClip/8,-4*hClip/8).subtitle(aSub,size=6)), \ 
	              stackhorizontal(a.crop(0*wClip/8,4*hClip/8,-7*wClip/8,-3*hClip/8).subtitle(aSub,size=6), \ 
	                              b.crop(1*wClip/8,4*hClip/8,-6*wClip/8,-3*hClip/8).subtitle(bSub,size=6), \ 
	                              a.crop(2*wClip/8,4*hClip/8,-5*wClip/8,-3*hClip/8).subtitle(aSub,size=6), \ 
	                              b.crop(3*wClip/8,4*hClip/8,-4*wClip/8,-3*hClip/8).subtitle(bSub,size=6), \ 
	                              a.crop(4*wClip/8,4*hClip/8,-3*wClip/8,-3*hClip/8).subtitle(aSub,size=6), \ 
	                              b.crop(5*wClip/8,4*hClip/8,-2*wClip/8,-3*hClip/8).subtitle(bSub,size=6), \ 
	                              a.crop(6*wClip/8,4*hClip/8,-1*wClip/8,-3*hClip/8).subtitle(aSub,size=6), \ 
	                              b.crop(7*wClip/8,4*hClip/8,-0*wClip/8,-3*hClip/8).subtitle(bSub,size=6)), \ 
	              stackhorizontal(b.crop(0*wClip/8,5*hClip/8,-7*wClip/8,-2*hClip/8).subtitle(bSub,size=6), \ 
	                              a.crop(1*wClip/8,5*hClip/8,-6*wClip/8,-2*hClip/8).subtitle(aSub,size=6), \ 
	                              b.crop(2*wClip/8,5*hClip/8,-5*wClip/8,-2*hClip/8).subtitle(bSub,size=6), \ 
	                              a.crop(3*wClip/8,5*hClip/8,-4*wClip/8,-2*hClip/8).subtitle(aSub,size=6), \ 
	                              b.crop(4*wClip/8,5*hClip/8,-3*wClip/8,-2*hClip/8).subtitle(bSub,size=6), \ 
	                              a.crop(5*wClip/8,5*hClip/8,-2*wClip/8,-2*hClip/8).subtitle(aSub,size=6), \ 
	                              b.crop(6*wClip/8,5*hClip/8,-1*wClip/8,-2*hClip/8).subtitle(bSub,size=6), \ 
	                              a.crop(7*wClip/8,5*hClip/8,-0*wClip/8,-2*hClip/8).subtitle(aSub,size=6)), \ 
	              stackhorizontal(a.crop(0*wClip/8,6*hClip/8,-7*wClip/8,-1*hClip/8).subtitle(aSub,size=6), \ 
	                              b.crop(1*wClip/8,6*hClip/8,-6*wClip/8,-1*hClip/8).subtitle(bSub,size=6), \ 
	                              a.crop(2*wClip/8,6*hClip/8,-5*wClip/8,-1*hClip/8).subtitle(aSub,size=6), \ 
	                              b.crop(3*wClip/8,6*hClip/8,-4*wClip/8,-1*hClip/8).subtitle(bSub,size=6), \ 
	                              a.crop(4*wClip/8,6*hClip/8,-3*wClip/8,-1*hClip/8).subtitle(aSub,size=6), \ 
	                              b.crop(5*wClip/8,6*hClip/8,-2*wClip/8,-1*hClip/8).subtitle(bSub,size=6), \ 
	                              a.crop(6*wClip/8,6*hClip/8,-1*wClip/8,-1*hClip/8).subtitle(aSub,size=6), \ 
	                              b.crop(7*wClip/8,6*hClip/8,-0*wClip/8,-1*hClip/8).subtitle(bSub,size=6)), \ 
	              stackhorizontal(b.crop(0*wClip/8,7*hClip/8,-7*wClip/8,-0*hClip/8).subtitle(bSub,size=6), \ 
	                              a.crop(1*wClip/8,7*hClip/8,-6*wClip/8,-0*hClip/8).subtitle(aSub,size=6), \ 
	                              b.crop(2*wClip/8,7*hClip/8,-5*wClip/8,-0*hClip/8).subtitle(bSub,size=6), \ 
	                              a.crop(3*wClip/8,7*hClip/8,-4*wClip/8,-0*hClip/8).subtitle(aSub,size=6), \ 
	                              b.crop(4*wClip/8,7*hClip/8,-3*wClip/8,-0*hClip/8).subtitle(bSub,size=6), \ 
	                              a.crop(5*wClip/8,7*hClip/8,-2*wClip/8,-0*hClip/8).subtitle(aSub,size=6), \ 
	                              b.crop(6*wClip/8,7*hClip/8,-1*wClip/8,-0*hClip/8).subtitle(bSub,size=6), \ 
	                              a.crop(7*wClip/8,7*hClip/8,-0*wClip/8,-0*hClip/8).subtitle(aSub,size=6)))  
}
hydra3333 is offline   Reply With Quote
Old 20th January 2014, 05:45   #2  |  Link
hydra3333
Registered User
 
Join Date: Oct 2009
Location: crow-land
Posts: 539
Here's a much noisier and blockier sample (10Mb). I had to use
Code:
deblock_QED(quant1=48)
SMDegrain(tr=3, ...)
where results were more satisfactory.
Clip: http://www.mediafire.com/watch/laqy2...01-noaudio.mpv
Pic: http://www.mediafire.com/view/ndnook...01-noaudio.png

Last edited by hydra3333; 20th January 2014 at 05:51.
hydra3333 is offline   Reply With Quote
Old 20th January 2014, 06:05   #3  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,447
I've done many hundreds of hours of VHS to digital transfers. The first thing is to use a really good deck with a time base corrector. It sounds like you have to accept the results from an inferior transfer which was then encoded by a real-time consumer MPEG-2 encoder. So, you're going to be a little behind before you start.

Having said that, the first thing to do is make sure you get the proper black and white levels. Both the black and the white levels appear to be too high: it looks like the entire histogram needs to be pushed downwards.

I always recommend NOT deinterlacing, unless you will never be watching on a TV set and only watching on a computer. Deinterlacing always degrades the video, no matter how well it is done.

I don't think you need to use delocking on this source, at least not for the clip I saw.

I have posted, several times, the starting point script (I always tweak) that I use for VHS transfers. I reduce chroma noise (always a problem with VHS transfers) with an old Virtualdub plugin (CNR) followed by MDegrain (MVTools2) to reduce noise. I then sometimes apply very, very light sharpening. This approach never loses detail, and if your script is losing detail when your source is VHS (which has virtually no detail to begin with), then your script is doing the wrong things.

As for motion stabilization, the Depanstabilize approach used in those film restoration scripts is appropriate for that problem because film always contains gate weave, and that simple motion stabilization technique works well to eliminate that problem. However your VHS clip has very large camera movement, and you would be much better off using the correct tool for that problem. I would highly recommend using Deshaker inside of VirtualDub. You can Google my name and "Deshaker" and you'll find that I've written both a guide, as well as several scripts designed to be used with Sony Vegas, both of which should show you how this is done.

Here's the ten-year-old guide:

A Guide To Using Deshaker.

I can send you the link to the Vegas scripts, if you are a user of that product.

To save you from finding the VHS restoration script that I've posted before, here it is again:
Code:
#Denoiser script for interlaced video using MDegrain2

SetMemoryMax(768)

Loadplugin("C:\Program Files\AviSynth 2.5\plugins\MVTools\mvtools2.dll")
LoadPlugin("c:\Program Files\AviSynth 2.5\plugins\CNR\Cnr2.dll")

SetMTMode(5,6)
#Modify this line to point to your video file
source=AVISource("E:\fs.avi").killaudio().AssumeBFF()
SetMTMode(2)

#Only use chroma restoration for analog source material
chroma=source.Cnr2("oxx",8,16,191,100,255,32,255,false) #VHS
#chroma=source.Cnr2("oxx",8,14,191,75,255,20,255,false) #Laserdisc 

#Set overlap in line below to 0, 2, 4, 8. Higher number=better, but slower
output=MDegrain2i2(chroma,8,0,0)
#output=MDegrain2i2(chroma,8,4,0)  #Better, but slower

#stackvertical(source,output)
#stackhorizontal(source,output)

return output

#-------------------------------

function MDegrain2i2(clip source, int "blksize", int "overlap", int "dct")
{
Vshift=0 # 2 lines per bobbed-field per tape generation (PAL); original=2; copy=4 etc
Hshift=0 # determine experimentally 
overlap=default(overlap,0) # overlap value (0 to 4 for blksize=8)
dct=default(dct,0) # use dct=1 for clip with light flicker

fields=source.SeparateFields() # separate by fields

#This line gets rid of vertical chroma halo
#fields=MergeChroma(fields,crop(fields,Hshift,Vshift,0,0).addborders(0,0,Hshift,Vshift))
#This line will shift chroma down and to the right instead of up and to the left
#fields=MergeChroma(fields,Crop(AddBorders(fields,Hshift,Vshift,0,0),0,0,-Hshift,-Vshift))

super = fields.MSuper(pel=2, sharp=1)
backward_vec2 = super.MAnalyse(isb = true, delta = 2, blksize=blksize, overlap=overlap, dct=dct)
forward_vec2 = super.MAnalyse(isb = false, delta = 2, blksize=blksize, overlap=overlap, dct=dct)
backward_vec4 = super.MAnalyse(isb = true, delta = 4, blksize=blksize, overlap=overlap, dct=dct)
forward_vec4 = super.MAnalyse(isb = false, delta = 4, blksize=blksize, overlap=overlap, dct=dct)

MDegrain2(fields,super, backward_vec2,forward_vec2,backward_vec4,forward_vec4,thSAD=400) 

Weave()
}
johnmeyer is offline   Reply With Quote
Old 20th January 2014, 07:42   #4  |  Link
hydra3333
Registered User
 
Join Date: Oct 2009
Location: crow-land
Posts: 539
Thank you very much I will try that.

The second clip is a bit blocky
)
hydra3333 is offline   Reply With Quote
Old 20th January 2014, 09:19   #5  |  Link
Ghitulescu
Registered User
 
Ghitulescu's Avatar
 
Join Date: Mar 2009
Location: Germany
Posts: 5,764
Quote:
Originally Posted by hydra3333 View Post
b) My sources are about 150 old and very grainy VHS-C PAL home-video tapes captured to mpeg2 DVD (blockily) by a combo VHS-DVD recorder.
I fully support JohnMeyer.
I suggest you recapture those cassettes once again, if you still have them.
Your case is unfortunately typical for this situation: people use the cheapest/crappiest device they have (not to spend money on good gear) then pretend miracles from freeware solutions (again not to spend money). Not only that SISO (garbage in, garbage out) applies, but if one would count the time spent (at minimum wage rate ), the electricity and the nerves, it's by far the most expensive alternative (and also the worst).
The blocking I see seems to suggest an encoding rate of less than 2Mbps (or 4-8h mode, depending on the recorder). If one would care about these recordings he'd probably would chose the highest bitrate the recorder had (XP, or 1h mode), in the end no VHS-C cassette reaches 1h total run time. Two cassettes per DVD wouldn't have been that problematic, especially if one would have used DVD-RWs.

If you cannot reuse the cassettes (eg discarded), then the next best solution is to find youtube enhancers, because the quality of your samples is even below youtube. Only Italian shopping channels had this lower bitrate
__________________
Born in the USB (not USA)
Ghitulescu is offline   Reply With Quote
Old 20th January 2014, 15:26   #6  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,447
I was able to make quite a bit of improvement using a variation of the script I posted above. Here is a DV codec version of the result:

"Restored" Version

I did the color correction in Vegas. I am a big fan of using the right tool for the job, and most NLEs have far better ways of correcting color than can be done in AVISynth.

You might want to add, at the end of this script, some sort of standard deblocking filter. I think it might have a chance, using the "restored" version uploaded above as the source, to actually get rid of the blocks.

I looked carefully for detail loss, and didn't see anything significant. If you look at the gauze on the feeding tube in frame 218, I think you'll see that the cross-hatch pattern on the gauze is maintained. Here's a before/after of that frame (this particular frame did not exhibit much blockiness):



If you look at the baby's lower lip, and the areas around the eyes, I think you'll actually see some detail that was obscured by the noise in the original.

One thing I did notice: the speed of this video, even at 25 fps, seems to be way too fast. I didn't see any obvious places where frames were dropped. Was this file processed in any way before uploading?

Here's the variation of the script that I used to create the clip I just uploaded:

Code:
#This is the recommended script for VHS as of April, 2012

SetMemoryMax(768)

Loadplugin("C:\Program Files\AviSynth 2.5\plugins\MVTools\mvtools2.dll")
LoadPlugin("c:\Program Files\AviSynth 2.5\plugins\CNR\Cnr2.dll")

SetMTMode(5,6)
#Modify this line to point to your video file
source=AVISource("E:\fs.avi").killaudio().AssumeTFF()
SetMTMode(2)

#Only use chroma restoration for analog source material
chroma=source.Cnr2("oxx",8,16,191,100,255,32,255,false) #VHS

#output=MDegrain2i2(chroma,8,0,0)
output=MDegrain2i2(chroma,8,4,0)  #Better, but slower

#stackvertical(source,output)
#stackhorizontal(source,output)
#return output.Levels(16, 1, 235, 0, 255, coring=false)

return output

#-------------------------------

function MDegrain2i2(clip source, int "blksize", int "overlap", int "dct")
{
  Vshift=0 # 2 lines per bobbed-field per tape generation (PAL); original=2; copy=4 etc
  Hshift=0 # determine experimentally 

  overlap=default(overlap,0) # overlap value (0 to 4 for blksize=8)
  dct=default(dct,0) # use dct=1 for clip with light flicker

  fields=source.SeparateFields() # separate by fields

  #This line gets rid of vertical chroma halo
  #  fields=MergeChroma(fields,crop(fields,Hshift,Vshift,0,0).addborders(0,0,Hshift,Vshift))

  #This line will shift chroma down and to the right instead of up and to the left
  #  fields=MergeChroma(fields,Crop(AddBorders(fields,Hshift,Vshift,0,0),0,0,-Hshift,-Vshift))

  super = fields.MSuper(pel=2, sharp=1)
  backward_vec2 = super.MAnalyse(isb = true, delta = 2, blksize=blksize, overlap=overlap, dct=dct)
  forward_vec2 = super.MAnalyse(isb = false, delta = 2, blksize=blksize, overlap=overlap, dct=dct)
  backward_vec4 = super.MAnalyse(isb = true, delta = 4, blksize=blksize, overlap=overlap, dct=dct)
  forward_vec4 = super.MAnalyse(isb = false, delta = 4, blksize=blksize, overlap=overlap, dct=dct)

  MDegrain2(fields,super, backward_vec2,forward_vec2,backward_vec4,forward_vec4,thSAD=400) 

  unsharpmask(60,3,0) #not sure whether to put this before or after the weave.

  Weave()
}

Last edited by johnmeyer; 20th January 2014 at 15:29. Reason: Removed first sentence because I realized the blocks in the PNG file were before/after comparisons
johnmeyer is offline   Reply With Quote
Old 21st January 2014, 01:47   #7  |  Link
hydra3333
Registered User
 
Join Date: Oct 2009
Location: crow-land
Posts: 539
Quote:
Originally Posted by johnmeyer View Post
I was able to make quite a bit of improvement using a variation of the script I posted above.
...
I did the color correction in Vegas. I am a big fan of using the right tool for the job, and most NLEs have far better ways of correcting color than can be done in AVISynth.
...
You might want to add, at the end of this script, some sort of standard deblocking filter.
...
One thing I did notice: the speed of this video, even at 25 fps, seems to be way too fast. I didn't see any obvious places where frames were dropped. Was this file processed in any way before uploading?
Yes, I also noticed it seemed a bit fast; the vhs-to-dvd process was direct with no other processing so it must be the DVD recorded "doing it".
A "limited" budget and I don't have vegas... I'll try colour correction via avisynth somehow (at that time the skin tone of the small individual was a tad closer to "purple").
On a hypothesis "undo the issues in reverse order" would it appropriate to deblock first since that was the last thing "done" ?
Quote:
Originally Posted by Ghitulescu View Post
I suggest you recapture those cassettes once again, if you still have them.
Your case is unfortunately typical for this situation: people use the cheapest/crappiest device they have (not to spend money on good gear) then pretend miracles from freeware solutions (again not to spend money).
The blocking I see seems to suggest an encoding rate of less than 2Mbps (or 4-8h mode, depending on the recorder). If one would care about these recordings he'd probably would chose the highest bitrate the recorder had (XP, or 1h mode), in the end no VHS-C cassette reaches 1h total run time.
Only Italian shopping channels had this lower bitrate
I must have Italian heritage No, but from time to time we do have to make do with what we've got. The capture rate was the highest the LG RC689D had.
Checking an old cupboard, I found a "Gadget Geek DIVA112" USB/Composite capture device and an unbranded "Video Stabilizer model no. VDK6" with composite connectors and 2 buttons - "sharpen" and "norm" which I guess may be a TBC.
I will see if they turn on. And locate a capture codec eg Huffyuv (if it installs/works on win7) and a capture program (eg Vdub)... I will search doom9 for latest posts about that.
hydra3333 is offline   Reply With Quote
Old 21st January 2014, 02:11   #8  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,564
Deblocking should definitely always be done before other processing. It's up to you if you want to deinterlace or not, but if so that should always be next. Then you can denoise, color correct, etc. QTGMC includes deblocking and denoising, though, so doubling up might be why it looks like overkill.

If the videos still exist, it'll be a giant pain in the ass to do it all over again but the result will be worth it in the end. Hopefully you can let most of them go overnight and at work once the workflow is ready.

It might be a decent time to edit them down as long as you're touching with them all now. I hate to say it, but most family and wedding video never gets revisited because of so many easy to remove lulls.
foxyshadis is offline   Reply With Quote
Old 21st January 2014, 09:08   #9  |  Link
hydra3333
Registered User
 
Join Date: Oct 2009
Location: crow-land
Posts: 539
OK, deblock first.
Quote:
Originally Posted by hydra3333 View Post
Checking an old cupboard, I found a "Gadget Geek DIVA112" USB/Composite capture device and an unbranded "Video Stabilizer model no. VDK6" with composite connectors and 2 buttons - "sharpen" and "norm" which I guess may be a TBC.
I will see if they turn on.
I recalled an old thread http://forum.doom9.org/showthread.php?t=151269 about the DIVA112 ... audio driver issues then. Let's see if Win7 etc fixes it.
hydra3333 is offline   Reply With Quote
Old 21st January 2014, 09:43   #10  |  Link
Ghitulescu
Registered User
 
Ghitulescu's Avatar
 
Join Date: Mar 2009
Location: Germany
Posts: 5,764
Quote:
Originally Posted by hydra3333 View Post
No, but from time to time we do have to make do with what we've got. The capture rate was the highest the LG RC689D had.
Checking an old cupboard, I found a "Gadget Geek DIVA112" USB/Composite capture device and an unbranded "Video Stabilizer model no. VDK6" with composite connectors and 2 buttons - "sharpen" and "norm" which I guess may be a TBC.
I only meant that the quality has to be kept from the beginning.
I doubt that "geek device" of yours had a TBC, these are pretty expensive and very rare. I assume they had only an high-band enhancer, like the treble control in audio. Because your cassettes are the first generation, a TBC is not absolutely necessary (a TBC is always needed in taping, yet one has to use what one has), the capturing card/device should be able to reconstruct the timing quite accurately.
On the other hand, the LG of yours captured quite well the small format, some videos could have issues with the tracking.
__________________
Born in the USB (not USA)
Ghitulescu is offline   Reply With Quote
Old 21st January 2014, 13:16   #11  |  Link
hydra3333
Registered User
 
Join Date: Oct 2009
Location: crow-land
Posts: 539
OK and thanks to everyone who responded.
The USB "Gadget Geek DIVA112" only captured to mpeg2 with its own software and I noticed more issues with it than the DVD recorder although it was less blocky.
I also found an old TV2000-XP PCi card ... which wouldn't fit into any of my motherboard slots
Back to square one, the LG DVD recorder to capture.
JohnMeyer was good with his colour adjustment, by that date the skin had indeed moved largely toward a more normal tone. I see he also used unsharpmask within the warpsharp package, so the workflow becomes:
Code:
AssumeFPS(25) 
AssumeTFF()  
changefps(last,last,true) # http://forum.doom9.org/showthread.php?p=1473445#post1473445 
#Crop(clip clip, int left, int top, int -right, int -bottom, bool align)  
crop(12,8,-12,-20) # for my VHS-C cassettes only 
# 1. DEBLOCK really blocky source the hard way. see http://doom10.org/index.php?topic=2309.msg12233#msg12233 
SeparateFields()   # no need for pointresize, the field blocks appear to be square
#deblock_QED() # for those captures with less blockiness
deblock_QED(quant1=48) # treat the blockiness introduced by the last step of the vhs-to-mpeg2dvd capture
Weave() 
AssumeTFF()  
# 2. see JohnMeyer # http://forum.doom9.org/showthread.php?p=1663043#post1663043
#Only use chroma restoration for analog source material
Cnr2("oxx",8,16,191,100,255,32,255,false) #VHS
# 3. SMDegrain is equivalent to MDegrain2i, apparently it also also uses prefiltered clip etc for a bit more "accuracy" and these sources need all the help they can get
# tr=2 means mdegrain2
SMDegrain(tr=2, Contrasharp=true, RefineMotion=false, plane=4, Interlaced=true, pel=2, prefilter=3, blksize=8, overlap=4, Chroma=false)  
# 4. see JohnMeyerhttp://forum.doom9.org/showthread.php?p=1663102#post1663102
SeparateFields().unsharpmask(60,3,0).Weave()  #not sure whether to put unsharpmask inside SeparateFields-Weave
# 5. colour adjustment of some kind goes in here 
#Addborders(left,top,right,bottom) # for my VHS-C cassettes only 
addborders(12,8,12,20) # for my VHS-C cassettes only

Last edited by hydra3333; 21st January 2014 at 13:30.
hydra3333 is offline   Reply With Quote
Old 22nd January 2014, 00:34   #12  |  Link
johnmeyer
Registered User
 
Join Date: Feb 2002
Location: California
Posts: 2,447
Foxy and others are correct: do the deblocking first. I don't know what I was thinking when I suggested doing it after the denoising because, as you see in the first two seconds of my "improved" version of the video, MDegrain sometimes alters or removes the block and sometimes doesn't, and trying to feed that into a deblocking script will not achieve good results. Sorry for providing a bad recommendation.
johnmeyer is offline   Reply With Quote
Old 22nd January 2014, 10:31   #13  |  Link
hydra3333
Registered User
 
Join Date: Oct 2009
Location: crow-land
Posts: 539
All good, all the IP in my script is yours.
Regards
hydra3333 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:14.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.