Log in

View Full Version : How to use Avisynth for large number of layers?


pancserzso
14th July 2011, 19:30
I am trying to compose about 100 layers on top of each other using the Layer command. My script looks like this:

clip1 = ImageSource(...).ConvertToRGB32.FadeIn(72).loop(100)
blank = BlankClip(clip1, length=24)
long = BlankClip(clip1, length=7500)
clip1d = clip1
clip1m = Layer(long, clip1, "lighten")

clip2 = ImageSource(...).ConvertToRGB32.FadeIn(72).loop(100)
clip2d = blank.loop(1) + clip2 + blank
clip2m = Layer(clip1m, clip2d, "lighten")

clip3 = ImageSource(...).ConvertToRGB32.FadeIn(72).loop(100)
clip3d = blank.loop(2) + clip3 + blank
clip3m = Layer(clip2m, clip3d, "lighten")

...

clip97 = ImageSource(...).ConvertToRGB32.FadeIn(72).loop(100)
clip97d = blank.loop(96) + clip97 + blank
clip97m = Layer(clip96m, clip97d, "lighten")

return clip97m.Trim(2800,0).ConvertToYV12()


I know its not an everyday task to compose 100 layers in Avisynth, but I found that it works perfectly, so why change.

My only problem is that it is extremely slow. I mean on a 3.6 Ghz quad core machine, I get 0.62 fps for a 640x360 ultra low res clip. Better not imagine what happens in 1080p.

My question is that I have never used Avisynth MT, or 2.60 Alphas or any tweaks, I am just using the latest official 2.58 non-MT. Could someone recommend me some tweaks or ideas to make Avisynth faster in this situation? All the sources are ImageSources linking to images that are PNGs. I will try converting them to TIFFs, but it would explode the file sizes.

Any other idea how to do things like this?

Gavino
14th July 2011, 22:36
If I understand your script, each successive clip has 24 more blank frames added at the start (clip2 has 24, clip3 has 48, etc), but you are applying all 97 layer operations to the entire clip. So for the first 24 frames you are layering 96 blank clips and so on, which is a waste of time.

At each stage you could use Trim to layer only the frames that are not blank.