This is useful because some filtering methods are great for a few scenes, but are terrible for other scenes... usually destroying a lot of detail in the process. See the above thread for traditional ways around this problem. In response, my own solution was to create a function that does everything I want!

mod is a Val Type, so it can be input a number of different ways:1. FILTERS & FILTERCHAINS (String)2. PRESETS & PRESET_NUMBERS (String for Preset_Names, Integer for Preset_Numbers)3. REPLACEMENT_CLIPS & IMAGES (Clip)

- The first two parameters are where you specify the range of frames you wish to modify- [length] is the parameter specifying the duration of your range when [endframe] is not specified.startframe - The framenumber where you want your video to be modifiedendframe - The framenumber where you want your video to stop being modifiedlength - The number of frames you want your range to last for. Cannot be used with [endframe].

2. [mod](String/String/Integer/Clip)

- The third parameter, previously known as [filterchain] is now called [mod], which stands for "modification."- This lets you control how you want to modify your range of frames.- As of v3.0, [mod] can be input in 4 ways:

- The fourth & fifth parameters are the number of frames before/after range that you wish to fade-in/fade-outfadein - The number of frames you want to fade in before [startframe]fadeout - The number of frames you want to fadeout after [endframe]

4. [mod_extra](String/String/Integer)

- [mod_extra] can only be used if [mod] is a clip.- works just like [mod], but is applied to your replacement clip- [mod_extra] itself cannot be a clip (you can filter a clip... but you cannot clip a clip! lol

5. [head]/[tail](Integer)

- The seventh & eighth parameters can fine-tune [fadein]/[fadeout] if you have particular start/end points in mind.head - The framenumber you want to begin [fadein]tail - The framenumber you want to end [fadeout]

*USING MOD & MOD_EXTRA - Since [mod] and [mod_extra] are Val Types, they can be input a number of different ways:

A. FILTER_CHAINS(String)- To input mod as a filter chain, simply type the sequence of filters (within quotes " ") that you want to apply to your range of frames.- Include any arguments and parameters you desire. - Multiple filters can be chained together via a period (.)- if you just want to use the default parameters of a filter, the () is not necessary- if your filter chain contains quotes, enclose everything using triple quotes (""" """)

- None of these filters are required for range() to work normally, however,- to use a preset, you may need to install the corresponding filters. For instance, the "blur" preset needs BlurMod()

- External Filters on AviSynth.org would be a good place to start for some ideas- Maybe check out my last post in this thread for some useful filters as well.- Feel free to change the presets yourself within the code - I'll take suggestions for presets as well

C. PRESET_NUMBERS(Integer)- Instead of calling a Preset by name, you can call it by number.- The following all do the same thing:

D. CLIP_REPLACEMENT(Clip)- Instead of modifying your range with a filter or preset, you can replace the frames with another clip entirely.- (realistically, you would probably use a different/better version of the same clip)- It is usually best to declare your clips as variables first, then call them later on in the script (whenever needed):

-This basically returns clip2 (filtered), but frames 1200-1300 are replaced with the original non-filtered clip- if you want to apply additional filters on top of your replacement clip, use [mod_extra], or consult the Examples Section below.

##############################EXAMPLE SCENARIOS:

1.Applying a FilterChain (Typical Usage):- Say you want to apply some filters like ttempsmooth() and gradfunkmirror() to only frames 1200-1300 and leave the rest untouched, you can go:

- Triple quotes are only necessary when single quotes are contained within your filterchain string ie.) range(1200,1300, """filter("arg1", "arg2")""" -But it doesn't hurt to use them for clarity either...

The "nuke" preset implements a combination of deblock(), dfttest(), and blur(1.58) to be used as a "quickfix." This is a pretty heavy filter chain and should only be used in severe cases. Another method is to use the "freeze" preset. See the Presets Section above for a list of other presets.

11.Clip Replacement: Replace overfiltered frames with original frames- Let's say you want to sharpen your entire video with limitedsharpen(strength=200).- Suppose this worked for the majority of the video, but oversharpened a few scenes.- In previous versions of range() you would be stuck; extra filtering won't fix this - But as of v3.0 you can replace those scenes with the original non-filtered clip

- the whole clip is filtered, but frames 1200-1300 are replaced with the original non-filtered clip- In this case, you also fadein/fadeout for 24 frames so the contrast isn't so great between filtered and non-filtered frames

12.Clip Replacement with additional filtering ( method 1 - using [mod_extra] ):- let's say your clip replacement over-compensated- now it's not sharp enough, and you think some sharpening is still needed, just not using 200 strength:

- Just like the last example, the whole clip is filtered, and frames 1200-1300 are replaced with the original clip.- But this time, the [mod_extra] parameter is used to apply limitedsharpen(strength=50) to the replaced clip.

-You'll need to make sure your image matches your video specifications-If they don't match you may need to convert colorspaces and/or change frame sizes-Crop/Resize/Addborders if necessary. BestFit() may be useful for that

TODO:- Test Everything (The provided examples were tested and worked fine though...)- Possibly work with Animate() for even smoother transitions...- Allow [mod] and [mod_extra] to be independent of one another- Create still-image-replacement preset- Possibly add/change presets?... I'll take suggestions :)- Make an editing GUI using range() as a base function (never gonna happen... but I can dream...)

I suppose the syntax is the same, but mine's still better because:-The code is easier to read-It doesn't use unnecessary if/then statements EDIT: They are necessary for special cases-It has a default filter chain-It will eventually have fadein/fadeout parameters-It will eventually include clip replacement

Zarxrax wrote:Hmmm. I wonder why ApplyRange has such weird syntax to begin with. The best solution would be to get applyrange fixed in the avisynth source.

I suppose, but the developers are probably working on more important stuff -_-

Last edited by Phantasmagoriat on Thu Nov 04, 2010 12:28 pm, edited 1 time in total.

Alrighty, I've made a *TON* of changes to range() over the last couple days ^__^The major ones being:- The old parameter [filterchain] is now called [mod] which stands for "modification" because it accepts other Types of input now.- Clip Replacement- A place in the code for Presets- Boundary Checking (for the special cases brought up on doom9)

So:- Code updated to v3.0 - Documentation updated to reflect all the new features- (Now, the first post is HUGE because of all the extra functionality!)- see the Changelog and new Docs for full details

Are the presets really necessary?I think they add unnecessary complexity to the function.Also, every single preset is quite simple. There's really no advantage to using the preset than just writing the function directly, except you have to memorize what all the presets are, when people probably already know how to use the original filters anyways.

Using the preset number 6, is optional, so you don't have to memorize anything as long as you can remember a name like "black"

But what I really wanted to do was create a block of code in the script where you can put your own presets. Particularly with "light", "medium", and "heavy" which you can change to whatever you want. The defaults are just suggestions. I want to encourage people to add/change presets in the main script with their favorite filtering methods, so they just have to add them once using an easily-to-remember name, save the script, and then call them any time they want later. You are right, most of the presets are simple enough to be called regularly, but since there is a dedicated block of code for presets (labeled ## PRESET RECOGNITION ##), it's really easy to set your own ones for more complicated filterchains.

It's basically a way to put all your favorite filterchains in one place.

CHANGELOG:v3.1 - Presets are now in a completely isolated code block. - This makes it much easier to Save your own presets. Instructions are in the Docs. - Conversely, you can delete the entire Presets Section in the code, and it won't affect range()'s functionality.

-amongst some extra code cleaning, I also condensed the docs. It's still not as brief as I want it, but I can't see it getting any shorter than that.