Range() v3.2 Now with rg()

This forum is for questions and discussion of all the aspects of handling and cleaning up your footage with Avisynth.
Mister Hatt
Joined: Tue Dec 25, 2007 8:26 am
Status: better than you
Contact:
Org Profile

Re: Range() and Selective Filtering

Post by Mister Hatt » Sat Oct 30, 2010 11:19 pm

Phantasmagoriat wrote:Don't be so pessimistic, they'll have 64bit, mt, cross-platform in no time 8-)
As an avs developer, lolololololol.

User avatar
Phantasmagoriat
Joined: Mon Feb 06, 2006 11:26 pm
Status: ☁SteamPunked≈☂
Contact:
Org Profile

Re: Range() and Selective Filtering [now with fadein/fadeout!]

Post by Phantasmagoriat » Tue Nov 02, 2010 8:32 pm

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

Code: Select all

CHANGELOG:
v3.0 - Changed [mod]/[mod_extra] into Val Types to allow four different inputs using the same variables:
          A. Filter_Chains (String)
          B. Preset_Names (String)
          C. Preset_Numbers (Integer)
          D. Replacement_Clips (Clip)
v2.9 - Changed default value for [mod] to "null" because of Clip Replacement
v2.8 - Added Preset_Numbers (as Integers)
     - Added more Presets:
          "freeze", "nothing", "black", "white", "invert", "noise", "blur"
v2.7 - Changed [filterchain] parameter to [mod]
     - Added [mod_extra] parameter
v2.6 - Implemented Clip Replacement
v2.5 - Implemented Filter Presets:
          "light", "medium", "heavy", "nuke"
v2.4 - Added special ranges:
          range(20,0 "filter()") filters frames 20 until the end.
          range( 0,0 "filter()") filters all frames
v2.3 - Added Boundary checking for those pesky special cases :P
v2.2 - Added Single-frame filtering
v2.1 - Added [Length] parameter
v2.0 - Implemented dissolve method to allow:
          [fadein]/[fadeout]/[head]/[tail] parameters
v1.0 - Range() made public
Enjoy,

[and yes, let me know if you find any bugs too :P ]
Image
Org Profile | AMVGuide | Phan Picks! | THE424SHOW | YouTube | "Painkiller"

"Effort to Understand; Effort to be Understood; to See through Different Eyes."

User avatar
Zarxrax
Joined: Sun Apr 01, 2001 6:37 pm
Location: North Cackalacky
Contact:
Org Profile

Re: Range() v3.0 [Now with Clip Replacement and Presets!]

Post by Zarxrax » Tue Nov 02, 2010 10:44 pm

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.

User avatar
Phantasmagoriat
Joined: Mon Feb 06, 2006 11:26 pm
Status: ☁SteamPunked≈☂
Contact:
Org Profile

Re: Range() v3.0 [Now with Clip Replacement and Presets!]

Post by Phantasmagoriat » Tue Nov 02, 2010 11:41 pm

Well, no the presets aren't really necessary, but they do add convenience.

I mean, if I want a section to fade to solid black, I can just type:

Code: Select all

range(1200,1300, "black", 24,24)

instead of remembering what values are required for levels, and in what order:

Code: Select all

range(1200,1300, "levels(255, 1, 255, 0, 0)", 24,24)
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.
Image
Org Profile | AMVGuide | Phan Picks! | THE424SHOW | YouTube | "Painkiller"

"Effort to Understand; Effort to be Understood; to See through Different Eyes."

User avatar
Phantasmagoriat
Joined: Mon Feb 06, 2006 11:26 pm
Status: ☁SteamPunked≈☂
Contact:
Org Profile

Re: Range() v3.1 [Now with Clip Replacement and Presets!]

Post by Phantasmagoriat » Wed Nov 03, 2010 2:59 pm

Yet another update:

Code: Select all

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.
Image
Org Profile | AMVGuide | Phan Picks! | THE424SHOW | YouTube | "Painkiller"

"Effort to Understand; Effort to be Understood; to See through Different Eyes."

User avatar
Corran
Joined: Mon Oct 14, 2002 7:40 pm
Contact:
Org Profile

Re: Range() and Selective Filtering

Post by Corran » Wed Nov 03, 2010 6:39 pm

Phantasmagoriat wrote:I suppose the syntax is the same, but mine's still better :nose: because:
-The code is easier to read
-It doesn't use unnecessary if/then statements
-It has a default filter chain
-It will eventually have fadein/fadeout parameters
The if/then statements were necessary for avoiding issues when using trim() in certain situations. (though it looks like you've made some changes to address trim's issues in your script now so you probably know that...) But yeah, it could have been written better.

User avatar
Phantasmagoriat
Joined: Mon Feb 06, 2006 11:26 pm
Status: ☁SteamPunked≈☂
Contact:
Org Profile

Re: Range() v3.1 [Now with Clip Replacement and Presets!]

Post by Phantasmagoriat » Wed Nov 03, 2010 7:18 pm

Corran wrote:
Phantasmagoriat wrote:I suppose the syntax is the same, but mine's still better :nose: because:
-The code is easier to read
-It doesn't use unnecessary if/then statements
-It has a default filter chain
-It will eventually have fadein/fadeout parameters
The if/then statements were necessary for avoiding issues when using trim() in certain situations. (though it looks like you've made some changes to address trim's issues in your script now so you probably know that...) But yeah, it could have been written better.
lol, I guess I put my foot in my own mouth.
It actually required more if/then statements than you used to cover the really annoying special cases like:
sceneadjust(0,all-1, "invert()") # see what happens to the last frame
sceneadjust(0,0, "invert()") # splits the video in two
sceneadjust(1,all, "invert()") # misses the first frame

The special cases were such a pain, and I wouldn't be surprised if I missed any,
so I take that back. :beer:
Image
Org Profile | AMVGuide | Phan Picks! | THE424SHOW | YouTube | "Painkiller"

"Effort to Understand; Effort to be Understood; to See through Different Eyes."

User avatar
Phantasmagoriat
Joined: Mon Feb 06, 2006 11:26 pm
Status: ☁SteamPunked≈☂
Contact:
Org Profile

Re: Range() v3.2 Now with rg()

Post by Phantasmagoriat » Sun Nov 07, 2010 5:07 pm

Minor update:

Code: Select all

CHANGELOG:
v3.2 - Included rg() function with conveniently rearranged variables: rg( head,startframe,endframe,tail,mod )
Generally range() is used by specifying the startframe, endframe, modification, and some generic fadein/fadeout frames.
However, in some cases it would be more convenient to use all four frame positions *in sequencial order*
That is what rg() is for. It is literally the same as range() but with rearranged variables as shown above.
This is useful for adding effects, or when you need to be precise all the time. Here is an example of one of my recent uses:

Code: Select all

c0=as("UNCOMPRESSED.avi").yv().Levels(0, 1.00, 270, 0, 300)
c1=c0.Levels(0, 1.00, 290, 0, 300)
c2=c0.Levels(0, 1.00, 280, 0, 300)
c3=c0.Levels(0, 1.00, 270, 0, 300)
c4=c0.Levels(0, 1.00, 250, 0, 300)
credits = as("CREDITS_NEW.avi").yv()

c0
rg( 116, 138, 138, 182,c1)
rg( 182, 212, 212, 239,c1)
rg( 212, 260, 294, 356,last.Levels(0, 1.00, 260, 0, 300) )
rg( 322, 386, 394, 430,c2)
rg( 435, 445, 493, 537,c3)
rg( 547, 570, 756, 801,c4)
rg( 756, 801, 826, 826,last.Levels(0, 1.00, 270, 0, 300))
rg(1255,1274,1322,1366,c4)
rg(1408,1408,1772,1796,c3)
rg(1796,1811,1900,1960,c2)
rg(1960,2014,2014,2045,c2)
rg(2412,2469,2618,2657,c2)
rg(2657,2676,2726,2775,c2)
rg(2775,2799,2824,2851,c3)
rg(3715,3787,4169,4193,c2)
gradfun2db
trim(0,5443)++credits
In this case I wanted to make select scenes in my AMV glow a bit by boosting their luma. I knew exactly when I wanted the levels to start changing, so it would have been annoying and confusing to type something like the following for each segment:

Code: Select all

range(1811,1900,c2, head=1796, tail=1960)
Image
Org Profile | AMVGuide | Phan Picks! | THE424SHOW | YouTube | "Painkiller"

"Effort to Understand; Effort to be Understood; to See through Different Eyes."

Locked

Return to “AviSynth Help”