View Full Version : Is there an alternative to ApplyRange?
rig_veda
31st January 2006, 14:00
Is there an alternative to ApplyRange that allows for applying filters and functions only to certain frames? I need a way to apply a quite complex function to a given list of frames. I've been trying to do that via
...
ApplyRange(142159,142159,"GFSmooth")
ApplyRange(161396,161396,"GFSmooth")
ApplyRange(161401,161401,"GFSmooth")
ApplyRange(161408,161408,"GFSmooth")
ApplyRange(161412,161412,"GFSmooth")
ApplyRange(161424,161426,"GFSmooth")
...
in a row, but I'm running into memory problems when going over 30-40 calls. :(
I don't really need the ability to stuff the output of one ApplyRange into the next, since only one filter is to be used, and never more than one time on the same frame. Ideally, I'd only like to hand over a list of frames to a single function that, in case one of them frames specified is to be processed, calls that function "GFSmooth" for the source clip instead of "last" or whatever is the default atm. Is there a way to do this? Sorry, I'm new to scripting. I hope my question isn't too idiotic. :D
Didée
31st January 2006, 14:38
Hmh-mhm, this sounds as if it should have been already discussed, somewhen ... but I can't remember.
I've been trying to do that via
...
...
in a row, but I'm running into memory problems when going over 30-40 calls. :(
The memory problems come from the fact that this way, your "GFSmooth" function is executed many, many times, where it's only needed to be done one time.
Could be the solution is already there, somewhere in stickboy's avisynth stuff (http://www.avisynth.org/stickboy/), but I don't really see it ATM, either.
A simple, still manual, way would be to make a basic splicer function like
function ReplaceRange(clip clp1, clip clp2, int start, int end)
{
return( clp1.trim(0,start-1) ++ clp2.trim(start,end) ++ clp1.trim(start+1,0) )
}
Then your script would become s-th like
a = source
b = a.GFSmooth()
...
ReplaceRange(a,b, 142159,142159)
ReplaceRange(a,b, 161396,161396)
ReplaceRange(a,b, 161401,161401)
ReplaceRange(a,b, 161408,161408)
ReplaceRange(a,b, 161412,161412)
ReplaceRange(a,b, 161424,161426)
...
It's in no way elegant, and not fool-proof, too (e.g. you must not use the frames [0] , [1] , [last_soure_frame - 1] and [last_source_frame] as arguments, etc. ...)
But at least the memory problem should be circumvented.
The task of thinking about reading-in text files & evaluating them, I leave up to the others :p
Revgen
31st January 2006, 19:12
There is Stickboy's JDL_ApplyRange filter. You need the jdl-util.avsi and the jdl-range.avsi in your plugin directory in order to use it.
Go to http://www.avisynth.org/stickboy/ for the avs scripts.
foxyshadis
31st January 2006, 21:08
function ReplaceRange(clip clp1, clip clp2, int start, int end)
{
return( clp1.trim2(0,end=start) ++ clp2.trim2(start,end=end+1) ++ clp1.trim2(start+1,end=-1) )
}
Removes restrictions on frame #s. Requires Stickboy's jdl_util avsi. (Trim2 has the odd behavior that the last frame is end-1, at least that's been my experience. If I'm wrong, change the ends. But it couldn't care less if you give it bad frame #s, it'll give you a 0 frame clip.)
global tosmooth = false
global gfs = gfsmooth()
global normal = last
ScriptClip("tosmooth ? gfs : normal")
ConditionalReader("dude.txt","tosmooth")
For the format of the text file see ConditionalReader (http://www.avisynth.org/ConditionalReader). There are certain subtleties to conditional environments (like backwards execution) you need to remember in case you want to encapsulate this or use variables.
Pookie
1st February 2006, 02:56
Saw this one (a function ?), but have never tried it.
http://nullinfo.s21.xrea.com/#IT_YV12
"FilterRange" (scroll up the page)
rig_veda
1st February 2006, 07:56
Thanks for all your feedback. I settled on using JDL_ApplyFrame, since it was the first i got working. :D With the other ApplyFrame I probably made some stupid mistake either with the variables or the general construction of the rest of the script and couldn't get it to work. The JDL one still has got slightly high memory demands, but oh well.. as long as the thing encodes at the end.
Thank you. ^^
Didée
1st February 2006, 09:30
There is Stickboy's JDL_ApplyRange filter. You need the jdl-util.avsi and the jdl-range.avsi in your plugin directory in order to use it.
Go to http://www.avisynth.org/stickboy/ for the avs scripts.
For the record - this one does >not< help for the memory problem, because it is just a wrapper for "trim + trim.filter + trim".
So, when putting a long series of JDL_ApplyRange(start,end,"AnyFilter()"), then "AnyFilter()" still will be computed seperately for every single instance of JDL_ApplyRange. That's why I didn't mention it in this context.
stickboy
2nd February 2006, 10:48
Trim2 has the odd behavior that the last frame is end-1, at least that's been my experience. If I'm wrong, change the ends. But it couldn't care less if you give it bad frame #s, it'll give you a 0 frame clip.I wouldn't call it odd. :) It is, after all, designed especially for that purpose (http://forum.doom9.org/showthread.php?s=&threadid=58358), since [start, end) ranges are easier to deal with programmatically. If you care about bad frame numbers, my Trim3 function does strict bounds checking and won't generate 0 frame clips.
Anyway, to answer rig_veda's original question, this situation is exactly what my RemapFrames plugin (http://www.avisynth.org/stickboy/) is for. The documentation even provides an example demonstrating how to use it to replace a sequence of ApplyRange calls.
Didée
2nd February 2006, 11:24
Aah yes, RemapFrames was the one on my mind. Seems I got somewhat confused by the short description
RemapFrames
(v0.3.1) Remaps the frame indices in a clip as specified by an input text file or by an input string.
which may sound like it would work on just one clip. Perhaps something like "Remaps the frame indices within one clip, or from a second clip, as specified by ..." would be clearer?
stickboy
3rd February 2006, 14:43
Yeah, the description needs work.
Really I should list all the individual functions supplied by that plug-in and provide brief descriptions for each (which is what I do for my others one; I'm not sure why I was inconsistent here, maybe just laziness).
rig_veda
4th February 2006, 11:03
Thanks, I'll look into how to use the RemapFrames plugin now. :)
Btw, JDL_ApplyFrame did actually solve some memory problems: At least the script loads now, even though it reserves like more than 1 gb ram.
rig_veda
26th February 2006, 03:47
Well, I got to admit, RemapFrames works marvellously. I finished doing a whole movie with custom filters, scene by scene, and ReplaceFramesSimple() worked without trouble, with hundreds and hundreds of interval definitions. Well, that's what it's supposed to do, i guess. ^^;
In my actual script, i used like 4-5 calls of ReplaceFramesSimple, which didn't seem to be a problem. Great!
I wished there had been a comment or link in the ApplyRange part of the official AviSynth documentation to it, saying, for that and that case, you might want to try RemapFrames instead. :)
Maybe the the only thing that i would have added, if i had made the function (due to my necessity to manually create and work with intervals for scenes in a whole movie and to apply different filters with different settings to them) would have been a mode or function that works just like ReplaceFramesSimple() but uses only one text file and takes gets the definition of which filters to apply to a discrete frame or a frame interval also from the text file, like going
...
119065 .FFT3DFilter()
[121276 121423] .TTempSmooth(maxr=7,lthresh=10,cthresh=15,strength=5)
[122093 122146] .DeGrainMedian(limitY=10,limitUV=12,mode=0)
123157 .TTempSmooth(maxr=7,lthresh=4,cthresh=6)
[126445 126492] .SangNom(order=1,aa=32).FFT3DFilter()
[126840 127584] .WhateverElseYouComeUpWith()
...
because then in case of many different filters and filter settings used, it wouldn't need a large amount of text files. The one used would show everything in one go, without having to look for which specific text file actually contains the interval or frame one wants to change something at later on...
Thank you for pointing out RemapFrames to me! :D
mla0
9th April 2006, 21:34
how does this work?
lets say i want frame 10-15 filtered() & 18 filtered(). do i ahve to have that in a txt file which il create myself or i'll call it in the avs scripts that i have?
can this work like this in a .txt file:
ReplaceFramesSimple(10 15, "filter()")
ReplaceFramesSimple(18, "filter()")
what im trying to do is simple just apply a filter on a certain frame only. does this work exactly as what the JDL_Applyframe or range is altho w/ this u can have it in a txt file, w/o having to call in on the avs script numerous times.
stickboy
9th April 2006, 21:47
how does this work?
lets say i want frame 10-15 filtered() & 18 filtered(). do i ahve to have that in a txt file which il create myself or i'll call it in the avs scripts that i have?
can this work like this in a .txt file:
ReplaceFramesSimple(10 15, "filter()")
ReplaceFramesSimple(18, "filter()")
what im trying to do is simple just apply a filter on a certain frame only. does this work exactly as what the JDL_Applyframe or range is altho w/ this u can have it in a txt file, w/o having to call in on the avs script numerous times.You don't need a text file. Read the documentation that comes with the plug-in.
If you need to filter only a handful of frames, you might as well use ApplyRange (or JDL_ApplyRange/JDL_ApplyFrame/etc.).
stickboy
9th April 2006, 21:55
Maybe the the only thing that i would have added, if i had made the function (due to my necessity to manually create and work with intervals for scenes in a whole movie and to apply different filters with different settings to them) would have been a mode or function that works just like ReplaceFramesSimple() but uses only one text file and takes gets the definition of which filters to apply to a discrete frame or a frame interval also from the text fileHmm... I'll think about it. It's an interesting idea, but if I did that, then I'd feel like I was making my own scripting language. :)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.