View Full Version : Apply Filter to Specific Frames Only
WildCelt
18th August 2003, 20:37
IS there a way to apply a filter to a specific range of frames? I have several filters in my script that I want to work on the entire encode, but I want one of them to filter in a specific range of frames only. Is this possible?
Wilbert
18th August 2003, 21:04
applyrange (http://www.avisynth.org/index.php?page=Animate)
BoNz1
18th August 2003, 22:05
source=("c:\movie.avi")
a=trim(source,0,100) #trim first 100 frames
b=trim(source,101,0) #trim frames 101 to end
a1=BicubicResize(a,640,480,0,0.5)
a2=c3d(a1)
done1=a2
b1=BilinearResize(b,640,480)
b2=LumaFilter(b1)
done2=b2
alldone=done1+done2
return alldone
Thats how I do this kind of thing anyway. I find it is useful for credits when I use it with xvid's credits treatment.
WildCelt
19th August 2003, 16:17
@both
Thanks for the replies. I have been messing with this particular encode for months, and was really close to just scrapping it!
@Wilbert
Thanks, I saw that when I was looking up how to do this before I posted. The problem with most of the avisynth manual is it is not easily decoded into a real language. No offense to the author(s), but I just don't know what "ApplyRange(clip clip, int start_frame, int end_frame, string filtername, args)" means. Usually there are several examples in an explanation that helps me decipher, but in this case there were none.
@BoNz1
I am only partially following your example. How about this: I want to use Undot and Convolution3D on the whole thing, but I want to use ReverseFieldDominance on just part, say frames 2000-25000. How would that script look? TIA for indulging my script illiteracy.
BoNz1
19th August 2003, 17:50
If you want to use Convolution3D and UnDot on the whole thing and just ReverseFieldDominance on frames 2000-25000, it would look like this:
LoadPlugin("c:\Convolution3D.dll")
LoadPlugin("c:\UnDot.dll")
source=("c:\movie.avi")
a=Trim(source,0,1999)
b=Trim(source,2000,25000)
c=Trim(source,25001,0)
a1=Convolution3D(a,Preset="MovieHQ")
a2=UnDot(a1)
done1=a2
b1=Convolution3D(b,Preset="MovieHQ")
b2=UnDot(b1)
b3=ReverseFieldDominance(b2)
done2=b3
c1=Convolution3D(c,Preset="MovieHQ")
c2=UnDot(c1)
done3=c2
alldone=done1+done2+done3
return alldone
There should be a faster way to do this, ie put c3d and undot in before you trim but for some reason I couldn't make it work when I was debugging it, but it should probably work.
Acaila
19th August 2003, 18:02
LoadPlugin("c:\Convolution3D.dll")
LoadPlugin("c:\UnDot.dll")
Source=AVISource("c:\movie.avi").Convolution3D(Preset="MovieHQ").UnDot()
part1=Trim(Source,0,1999)
part2=Trim(Source,2000,25000).ReverseFieldDominance()
part3=Trim(Source,25001,0)
Return part1+part2+part3
As you can see there's really no need to store every single operation into an intermediate variable. It only makes things more difficult to read.
BoNz1
19th August 2003, 18:30
Sorry, Acaila. I seem to have a tendency to make things way harder than they need to be. Thanks, that is much simpler.
WildCelt
19th August 2003, 19:21
Thanks much, you guys, I really appreciate it. I can finally finish this encode!
@ Acaila
One thing I have always wondered (that your post bought up) is, what is the difference between putting each command on a separate line vs on one line separated by a "." like you have shown?
Acaila
19th August 2003, 19:42
what is the difference between putting each command on a separate line vs on one line separated by a "." like you have shown?As far as the effect on the output is concerned, absolutely nothing. Although the syntax is a little different based on what method you use.
e.g.
If you use everything on a separate line you need to supply the 'clip' parameter for each function like BoNz1 did:
source=("c:\movie.avi")
part1=UnDot(source)
If you use multiple filters on one line you need to start the line with a video to apply them to and then the 'clip' parameter is defaulted to that video:
source=("c:\movie.avi")
part1=source.UnDot()
It's easier to see what filters belong to one 'group' (meaning a frame range usually) if you place them on one line separated by a ".". But just use whatever is most easily readable/understandable to you.
WildCelt
19th August 2003, 19:51
I think I've got it. Thank you for your assistance!
WildCelt
21st August 2003, 01:12
I got around to trying this, and I keep getting this script error in VirtualDubMod (1.5.4.1): Invalid arguments to function "Convolution3D"
Here's my script:
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\Convolution3D.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\UnDot.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\ReverseFieldDominance.dll")
Source=("e:\capture.avi").Convolution3D(0,8,12,10,16,2,0).UnDot()
part1=Trim(Source,0,8290)
part2=Trim(Source,8291,84470).ReverseFieldDominance()
part3=Trim(Source,84471,0)
Return part1+part2+part3
I am using AVISynth 2.52
What am I doing wrong?
FredThompson
21st August 2003, 04:07
Originally posted by WildCelt
The problem with most of the avisynth manual is it is not easily decoded into a real language. No offense to the author(s), but I just don't know what "ApplyRange(clip clip, int start_frame, int end_frame, string filtername, args)" means. Usually there are several examples in an explanation that helps me decipher, but in this case there were none.Yup, I've been toying with the idea of a complete re-write using a proper grammatical documentation like you see for programming languages. It's a lot of work, though, and I've got other things that are more important right now.
The community would sure benefit from it, however.
BoNz1
21st August 2003, 05:56
Originally posted by WildCelt
I got around to trying this, and I keep getting this script error in VirtualDubMod (1.5.4.1): Invalid arguments to function "Convolution3D"
Here's my script:
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\Convolution3D.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\UnDot.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\ReverseFieldDominance.dll")
Source=("e:\capture.avi").Convolution3D(0,8,12,10,16,2,0).UnDot()
part1=Trim(Source,0,8290)
part2=Trim(Source,8291,84470).ReverseFieldDominance()
part3=Trim(Source,84471,0)
Return part1+part2+part3
I am using AVISynth 2.52
What am I doing wrong?
Yup, initially, I was going to post a script like this similar to Acaila's method however I got the same error when I was debugging it. Now I know why something like this will work:
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\Convolution3D.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\UnDot.dll")
LoadPlugin("C:\Program Files\AviSynth 2.5\plugins\ReverseFieldDominance.dll")
avisource("e:\capture.avi").Convolution3D(0,8,12,10,16,2,0).UnDot()
part1=Trim(0,8290)
part2=Trim(8291,84470).ReverseFieldDominance()
part3=Trim(84471,0)
Return part1+part2+part3
I think you forgot to write avisource infront of the movie path, sorry about this, that is my fault since when I posted this I forgot about that too.
Acaila
21st August 2003, 10:30
sorry about this, that is my fault since when I posted this I forgot about that too.And I forgot about it too, I just copied your initial stuff and modified it in my script :).
Fixed my script in the post above.
WildCelt
21st August 2003, 13:04
What can I say, you guys are great! Before I posted the last time, I did try putting "AVI" before each "Source," but it still wouldn't work. Then I put it just before the first "Source" and it gave me an error that "Source is not a known command." Omitting the other Sources (the ones in the trim portion of the script) seems to have done the trick.
Thanks again.
Acaila
21st August 2003, 14:40
Uhm, you seem to be confusing a few things. "Avisource" is a filter name, just like Convolution3D, "source" (as we've used it) is a variable name which means we could have just as well called it swdfgwgwrg and it would have done the same thing.
e.g.
source=("c:\movie.avi")
part1=Trim(source,0,500)
doesn't work because the movie.avi doesn't get imported correctly (our mistake, sorry)
avisource=("c:\movie.avi")
part1=Trim(source,0,500)
doesn't work because you're using two different variable names (avisource and source) and so Avisynth can't find the video to apply Trim to and so gives you an error
source=Avisource("c:\movie.avi")
part1=Trim(0,500)
happens to work because Avisynth is build to remember the last clip that was used
source=Avisource("c:\movie.avi")
part1=Trim(source,0,500)
is in my opinion the most correct solution because you explicitly tell Avisynth what to use Trim on.
WildCelt
21st August 2003, 15:13
Ah ha, that makes perfect sense.
WildCelt
25th August 2003, 19:12
Just wanted to let you know the script worked great! The encode's finally done. Thanks to everyone for the help.
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.