Log in

View Full Version : I need advice to speed things up.


videoFred
26th September 2006, 07:50
Hello everybody,

Finaly I have made a script that does everything I need.:p
But it is s-l-o-w :scared:

Maybe you can give me some hints to speed things up.

I start with my 1024x768 Huffyuv AVI files, 8mm film capturings.
I run the script in virtualDubMod, and save the resized 720x576 file again with Huffyuv.
I do the resizing at the beginnig, before all other filters.

The script does:

converttoYV12()
Lanczos4resize()
MVdenoise()
HDRAGC()
MVflowfps()
DepanStabilize()
Crop()
LimitedsharpenFaster()

It runs at 0-2fps (floating value)
The machine is a HP Pavillion, 3ghz, memory 512.
I always read from one harddisk, write to another.

I have tried setmemorymax(512) but this has no effect.

Maybe you have some tips for me?

Computer settings,
VirtualDubMod settings, maybe?
Splitting the script?
Running it on a network with my laptop, maybe?

Every time saver tip is welcome.

Thank you all in advance,

Fred.

Didée
26th September 2006, 08:17
Post the script. Perhaps there are some ressources to spare, in the MVDenoise <--> MVFlowFPS part.
BTW, shouldn't DepanStabilize better be located before MVFlowFPS? (Dunno, never used such a combo ...)

Usually, when "lots" of MVTools-stuff is involved, the trick with SetMemoryMax is to set is it as low as possible, in contrary to the usual advice "set as high as possible".
(MVTools need extra ressources, and not exactly little. If Avisynth grabs too much due to SetMemMax, then there's not enough left over for MVTools. My rule of thumb, here, is SetMemoryMax( 0.25~0.33 of available RAM) )

videoFred
26th September 2006, 08:28
BTW, shouldn't DepanStabilize better be located before MVFlowFPS? (Dunno, never used such a combo ...)

I post the script as soon as possible.
I must clean it up a little.
I use wierd names for my variables:o

About DepanStabilize: my originals are 16-18fps.
I use MVFlowFPS to convert to 25fps.
Stabilizing is much better if I have 25 frames/sec to work with.

Good hint about setmemorymax() !!
I try it this evening.

Fred.

videoFred
26th September 2006, 09:06
Here is my script:

I always put important parameters in variables, at the top of the script.
This makes it very easy to tweak the parameters in VirtualDubMod.
I use the 'trim' to go fast forwards, when needed.
To see the effect from HDRAGC on other scenes for example.

I never use the plugins directory from Avisynth.
I place everything in the same directory where the script is.
Works fine... never have any problems.
No need for long path names etc...

As you see the script is analyzing motion three times.
Once for denoising, once for frame rate converting and once for stabilizing.

I wonder if I could use the same vectors for this?

Also, I am confused about the build in Depan function in MVTools.
Do I still need the external Depan plugin?
Would it go faster if I would do the Depan motion estimation with MVTools?

Oh yes... 'bron' means 'source' in my langue.


trimo=6 trousta=2 cuto=0.5 asum=16
sharp=250 radi=2 over=30 modus=1 noiseA=10 noiseB=250

gana=0.9 sata=0.6 blue=0 red=0 black=-2
#shift_u #shift_v

#parameters for subtle white balance correction,
#shift_u < 0 - removes blue tint, shift_u > 0 - removes yellow tint,
#shift_v < 0 - removes red tint, shift_v > 0 - removes green tint (default 0)




film="F:\Eric_Dod_003.avi"




SetMemoryMax(128)

W=760 H=616 CL=20 CT=20 CR=-20 CB=-20



Loadplugin("MVToolsOld.dll")
Loadplugin("Depan.dll")
LoadPlugIn("LimitedSupport_09Jan06B.dll")
LoadPlugIn("MaskTools.dll")
Loadplugin("mt_masktools.dll")
Loadplugin("warpsharp.dll")
LoadPlugIn("RemoveGrain.dll")
LoadPlugin("AGC.dll")
Import("LimitedSharpenFaster.avs")



bron2=avisource(film).assumefps(asum).trim(trimo,0).converttoYV12().Lanczos4Resize(W,H)

bron=HDRAGC(bron2,coef_gain=gana,shift=black,shift_u=blue,
\shift_v=red,coef_sat=sata,max_gain=16,min_gain=1.5)

backward_vec2 = bron.MVAnalyse(isb = true, lambda = 1000, delta = 2, pel = 2, idx = 1)
backward_vec1 = bron.MVAnalyse(isb = true, lambda = 1000, delta = 1, pel = 2, idx = 1)
forward_vec1 = bron.MVAnalyse(isb = false, lambda = 1000, delta = 1, pel = 2, idx = 1)
forward_vec2 = bron.MVAnalyse(isb = false, lambda = 1000, delta = 2, pel = 2, idx = 1)

noiceclip= bron.MVDenoise(backward_vec2,backward_vec1,
\forward_vec1,forward_vec2,tht=noiseA,thSAD=noiseB)


backward_vectors = noiceclip.MVAnalyse(isb = true,truemotion=true,idx=2)
forward_vectors = noiceclip.MVAnalyse(isb = false,truemotion=true,idx=2)
frameclip=MVFlowFps(noiceclip,backward_vectors, forward_vectors, num=25, den=1, ml=100)





mdata=DePanEstimate(frameclip,trust=trousta)
stab=DePanStabilize(frameclip,data=mdata,cutoff=cuto,dxmax=5).crop(CL,CT,CR,CB)


clipS=limitedSharpenFaster(stab,smode=modus,strength=sharp,overshoot=over,radius=radi)



#stacko= stackhorizontal(crop(bron2,CL,CT,CR,CB),clipS)

clipS

And of cource 'stacko' is for comparing before/after. Very usefull!

Fred.

Didée
26th September 2006, 10:25
First thing I noticed: assuming you're actually upsizing the input, better set

[old:] bron2= ... .converttoYV12().Lanczos4Resize(W,H)

[new:] bron2= ... .Lanczos4Resize(W,H).converttoYV12()

to keep a (little) bit more chroma resolution.


Regarding speed, there isn't much to optimize. Only thing is that "idx" should be set in MVFlowFPS, too, to avoid calculating an interpolation that already exists:

frameclip=MVFlowFps(noiceclip, ... , ml=100, idx=2)

Apart from that, everything is like it basically should be. Straightforward.

If the source's noiselevel is not too serious, you could indeed re-use the motion vectors (from denoising) for the motion interpolation. Simply replace the vectors (and you *must* put idx=2, then) :

frameclip=MVFlowFps(noiceclip, backward_vec1, forward_vec1, num=25, den=1, ml=100, idx=2)


Lastly ... if DepanStabilize would be done before MVFlowFPS, it should be possible to re-use already calculated motion vectors once more, through MVDepan(). (Never tried that, though.)
But if DepanStabilize has to be done after MVFlowFPS, then there's nothing more to do.


One more thing to try: you could use the latest MVTools v1.4.12, and try MVDegrain/MVDeGrain2 instead of MVDenoise. Could be it deals better for your purpose ... at least the method of MVDegrain is more smart than MVDenoise.

videoFred
26th September 2006, 15:24
Thank you Didée!:cool:

I did some tests here on my old 633Mhz 256MB machine.
It is possible indeed to use the same vectors.

But this does not change speed, and I can not use the benefit of "truemotion" anymore.
Actualy, Depan on his own is faster then MVDepan.
Must be memory usage.....

But SetMemoryMax(64) (on this machine) realy helps!
It was set to 128 as you can see above.
This means 128 -or even less- is a good value for my other 512mb computer at home.


And MVDegrain2 is very very good, too.

I do not upsize the input, but downsize it.
However, my intuition tells me it is better to resize first, then change color space, right?
Or do I have to take a look at my intuition:D

Fred.