Log in

View Full Version : More memory efficient script?


tin3tin
21st December 2006, 10:51
I'm working on DVD slideshow GUI, which is generating avisynth scripts to preview/render slideshows, but it's eating up the ram(+virtual) very fast.

I'm a bit stuck on how to make the generated scripts more memory friendly, so if any of you have some idears, then let me know.

Here's an example script: DVDsGUIoutput.avs (http://download.videohelp.com/tin2tin/DVDsGUIoutput.avs)

foxyshadis
21st December 2006, 15:54
Just add SetMemoryMax(1024) (=1 gig) or whatever's good for you to the top. Certain filters keep their own cache so you have to watch for that, but can always adjust if it's still too high. Not sure if there's a way to edit the boilerplate in that GUI to always have it inserted.

tin3tin
21st December 2006, 17:09
Just add SetMemoryMax(1024) (=1 gig) or whatever's good for you to the top.

I've tried, but it isn't respected, even though I set a limit like that, it goes way past it.

The 3 plugins I'm using are vsfilter, zoom and transall - do you think that they are the reason that it is breaking that max limit?

Not sure if there's a way to edit the boilerplate in that GUI to always have it inserted.

I don't understand what you mean?

IanB
22nd December 2006, 00:46
SetMemoryMax() only sets the size of the AviSynth VideoFrameBuffer cache, i.e only objects created by env->NewVideoFrame(). Filters that specify CACHE_RANGE can override this limit, i.e. the range + a bit more becomes the new limit. You can safely set it quite low, like 4, worst case the scripts run slow.

Other things like filter objects and any buffers they create are outside this control.

Perhaps if you post an example script we can offer some specific hints.

Tritical has a custom experimental 2.5.7 release with some pretty aggressive cache managment, maybe this can help.

tin3tin
22nd December 2006, 08:17
@ IanB

Thanks for sharing your thoughts. I'm gonna try tritical's 25. nov build and see what happens.

I've posted an example script in the first post. I'm looking forward to hear if you can find something which will make it use less ram.

IanB
24th December 2006, 02:10
Your script is suffering from object bloat!

Applying the same filter chain to lots of seperate clips causes this. If possible it is far better to join all the clips first then process the single resultant clip once. Filters like Overlay and Resize are significant objects.

Functions are evaluated as macros so Plugh(a)+Plugh(b) will have twice as many objects as Plugh(a+b).

Routines like your SafeSize possibly end up with 2 resizers. Do all the arithmetic first then use it once!.function SafeSize(image, int SafeW, int SafeH, int fps)
{
a = image
w = Width(a)
h = Height(a)
# If to wide
h = (w > SafeW) ? multifour(h * SafeW/float(w)) : h
w = (w > SafeW) ? SafeW : w
# If to high
w = (h > SafeH) ? multifour(w * SafeH/float(h)) : w
h = (h > SafeH) ? SafeH : h

return ((Width(a) != w) || (Height(a) != h)) ? a.LanczosResize(w, h) : a
}All the arithmetic is resolved at compile time. Only things that return a Clip result in objects.

Hello! Only resize 1 clip to match the other.function MaskTransition(clip c1, clip c2, imgpath , int dur)
{
c2=c2.Lanczos4Resize(c1.Width(),c1.Height())
c1=c1.Lanczos4Resize(c2.Width(),c2.Height())
...Error: IanB overload: script to complicated!

tin3tin
29th December 2006, 00:21
@ IanB,

Thanks for your comments. Since its for slideshows I think i'll have do it chain-wise, but I'll try to look into that.

What you're explaining here, might be a really big memory solver for me:

http://forum.doom9.org/showthread.php?p=922210#post922210

Could you write me a script example on how to use frameevaluate to do that?

c2=c2.Lanczos4Resize(c1.Width(),c1.Height())
c1=c1.Lanczos4Resize(c2.Width(),c2.Height())

Phew:thanks:

IanB
29th December 2006, 01:06
c2=c2.Lanczos4Resize(c1.Width(),c1.Height())
c1=c1.Lanczos4Resize(c2.Width(),c2.Height()) <- Why do this C1 is the same size as C2 already, you just made it so. Doh!

tin3tin
29th December 2006, 08:37
c2=c2.Lanczos4Resize(c1.Width(),c1.Height())
c1=c1.Lanczos4Resize(c2.Width(),c2.Height()) <- Why do this C1 is the same size as C2 already, you just made it so. Doh!

You're absolutely right - this is very stupid! :o

Thanks for finding it.

This is another thing:

What you're explaining here, might be a really big memory solver for me:

http://forum.doom9.org/showthread.ph...210#post922210

Could you write me a script example on how to use frameevaluate to do that?