Log in

View Full Version : ApplyRange2()


JohannesL
28th May 2009, 12:17
This function lets you apply one or more filters to a range of frames.
I made this since the internal ApplyRange() is rather limited.

function ApplyRange2(clip c, int first_frame, int last_frame, string "filter")
{
before = c.Trim(0,first_frame-1)
c.Trim(first_frame,last_frame)
current = Defined(filter) ? eval(filter) : last
after = c.Trim(last_frame+1,0)
AlignedSplice(before,current,after)
return (last)
}


Examples:

ApplyRange2(100,200,"Blur(1.58).Blur(1.58).Blur(1.58).FFT3DGPU(sharpen=7,sigma=8)")

ApplyRange2(50,500,"Crop(0,50,-0,-50).AddBorders(0,50,0,50)")

My first function. Enjoy :)

Gavino
28th May 2009, 12:40
You're on the right tracks, but a common pitfall with functions of this type is not allowing for the boundary cases at the start and end of the clip or for the behaviour of Trim with arguments of zero or negative. Your function does not work correctly if first_frame is 0 or 1, or if last_frame is the last frame in the clip.

stickboy's JDL_ApplyRange (http://avisynth.org/stickboy/jdl-range.avsi) function does the job correctly.

JohannesL
28th May 2009, 14:08
Oops, I should have done a little bit more research before posting this. There's actually already a thread about the problem you mentioned: http://forum.doom9.org/showthread.php?s=&threadid=58358