Log in

View Full Version : How would I optimize this script? (deinterlace+deshake+degrain)


shoopdabloop
31st May 2009, 07:48
loadcplugin("c:\program files\avisynth 2.5\plugins\yadif.dll")
AviSource("tape 5 - clip 007.avi").AssumeBFF().converttoYV12(interlaced=true)
MT("removegrain()",0,splitvertical=true)
MT("Yadif()",0,splitvertical=true)
Trim(1,last.framecount)
Spline36Resize(748,496)
mdata = DePanEstimate(trust=0,pixaspect=0.9091)
DePanStabilize(data=mdata,dxmax=12,dymax=14,mirror=12,pixaspect=0.9091)
Crop2(720,356)
MT("DeGrainMedian(mode=0)",0)
fft3dgpu()
MT("removegrain()",0)
MT("warpsharp(54)",0)
AddBorders(0,62,0,62)

source is moderately shaky NTSC DV footage (16:9 letterboxed to 720x480) from a PANASONIC PV-DV102 camcorder (consumer, circa 2002)
final avisynth output is 720x480 with letterboxing.

Crop2 is a simple script I wrote that calculates the appropriate cropping for each side of the image from a WxH input.

function Crop2(clip clp, int "wid", int "hei", bool "alg")
{
dw = clp.width - wid
dh = clp.height - hei
hw = dw/2
hh = dh/2
return clp.Crop(hw,hh,-hw,-hh,alg)
}

the destination project is 654x354 (~1.85:1), hence the "Crop2(720,356)" (720x0.9091 is almost 654, 354 isn't div/4 but the video editing apps i use support it)

i am by no means an experienced avisynther, so feel free to tell me where i ****ed up.

shoopdabloop
1st June 2009, 06:08
i don't mean to sound pushy, but it would be nice for someone to correct at least one thing in the script before tomorrow.

shoopdabloop
2nd June 2009, 07:23
no? okay then....

Didée
2nd June 2009, 07:35
Glancing over the script, nothing particular springs out that would be wrong or would need correction. The script seems fine.

For alternativ methods of deshaking, find ideas here (http://forum.doom9.org/showthread.php?t=147132), in particular the "stab()" script function.

shoopdabloop
2nd June 2009, 21:55
thanks!

sorry for breaking rule 11, by the way.
i was just hoping there would be a way i could get more than 8fps out of my script.

Guest
2nd June 2009, 21:59
You have three denoisers and a sharpener. Are they really needed?

shoopdabloop
2nd June 2009, 22:33
the sharpener is, but all 3 denoisers, probably not. i'll see what i can do.

Sagekilla
3rd June 2009, 00:52
You could probably stick with only FFT3DGPU, which might provide a small speed boost (IIRC RemoveGrain and DeGrainMedian are pretty fast).

shoopdabloop
3rd June 2009, 04:24
here is the revised script:

(i decided to use an MT'd fft3dfilter instead of fft3dgpu because it's faster)

loadcplugin("c:\program files\avisynth 2.5\plugins\yadif.dll")
AviSource("tape 5 - clip 007.avi").AssumeBFF()
MT("removegrain()",0,splitvertical=true)
MT("separatefields().selecteven().EEDI2()",0,splitvertical=true)
Trim(1,last.framecount)
Spline36Resize(748,496)
mdata = DePanEstimate(trust=0,pixaspect=0.9091)
DePanStabilize(data=mdata,dxmax=14,dymax=14,mirror=12,pixaspect=0.9091)
Crop2(720,356)
MT("fft3dfilter(sigma=3)",0,splitvertical=true,overlap=2)
MT("warpsharp(58)",0)
AddBorders(0,62,0,62)

If I swap EEDI2 out for Yadif it's even faster, so I guess depending on the noticeability of the artifacts per scene I can use the appropriate one.