Log in

View Full Version : How to turn on/off a filter after a certain frame?


phlogiston
19th July 2003, 05:52
Hi!

I've got a weird avisynth problem. I have an anime video with a perfectly good opening sequence, but after that sequence, the animators must have slacked off and the quality of the video starts to turn bad. It can be fixed by tweaking the levels argument, but it then craps up the perfectly good opening sequence.

Now I do know the lazy way out of it: cut the sequences, use levels appropriately, then splice them up together later. What bugs me is that it is not exactly the solution I had in mind. I reading the avisynth documentation and trying to get a sort of IF-THEN thing going on. Yes, I am a programming newb and can't figure it out. :(

Say I note that the crappy video starts coming at frame 100, and I am trying to create a function that starts the levels filter after that 100th frame. How do I do that?

My current AVS has this function (which doesn't work :mad: )

function FIXIT()
{
return mpeg2source("kknjda.d2v")
clip.framecount>=100
levels(45,55,200,0,160)
}

What I'm trying to do is something that goes like this :
return mpeg2source("kknjda.d2v")
if clip.framecount>=100,
then levels(45,55,200,0,160)

HomiE FR
19th July 2003, 10:22
Ok the answer is really simple. You could also have read the Avisynth documentation or used the "search" function to get the answer.

ApplyRange(100,Framecount(),"Levels",0,1.0,255,0,255)

With this one I don't change anything, just tweak it like you want, even though your parameters, especially the gamma at 55, seems weird to me.

phlogiston
19th July 2003, 11:06
Ugh.... I'll try that now. I think i will go pound my head on the wall for a bit now :(

And the values for the levels are just some numbers I threw together. I just need to tweak the real values slightly to get a better image.

DoW
19th July 2003, 19:14
Also, if the filter doesnt have any args, applyrange wont work I think, so you'll have to use trim (thank god the extra frame bug is nuked)

stickboy
20th July 2003, 19:10
You can still use ApplyRange; you just need to create a wrapper for the filter you want to apply.

See my earlier post (http://forum.doom9.org/showthread.php?s=&threadid=56536#post336896) about it.

Richard Berg
20th July 2003, 21:07
Missed that the first time, stickboy. Good stuff -- added (http://www.avisynth.org/index.php?page=Wrapper).