View Single Post
Old 7th January 2017, 00:08   #14  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
Quote:
Originally Posted by Seedmanc View Post
Code:
...

original=last 

last.BlankClip(width=last.framecount-1+last.width, color=$888888)

scriptclip("""
        for (i = original.framecount-1, current_frame, -1) {
            frozen = original.freezeframe(0, original.framecount - 1, i)   
            layer(frozen , x = i,level=128)               
        } 
 """)
crop(300,0,0,0)
...
If only there was a way to massively accelerate this processing, it would have became a very useful tool.
A variant of the trick from the 2009 thread "Sticking" overlay might help.
The idea is to reuse each partial stack in the construction of the next rather than building each one from scratch.
For this to work, you will have to generate the clip frames in reverse order, so run the following script, save the result and either play it backwards (if possible) or run another reverse script to generate the final result.

For the script, replace your scriptclip section with the following code: (warning - untested!)
Code:
original = original.Reverse()
stack = last # the blank clip
ScriptClip("""
  frozen = original.freezeframe(0, original.framecount - 1, current_frame)   
  stack = layer(stack.SelectEvery(-1), frozen, x=current_frame, level=128)               
  return stack
""")
The performance gain comes from the expectation that at each frame, the previously generated frame (obtained via SelectEvery(-1)) will be preserved in the Avisynth cache.

The frames have to be generated in strict linear order, so it probably needs to be run single-threaded.
__________________
GScript and GRunT - complex Avisynth scripting made easier

Last edited by Gavino; 7th January 2017 at 00:11.
Gavino is offline   Reply With Quote