DESCRIPTION:
- Range() is an avisynth function that allows you to make modifications to a range of frames in your video... while leaving the rest untouched.
- Includes Fadein/Fadeout (v2.0), Clip Replacement, Filter Presets, and Boundary Checking for special cases (v3.0).
- Similar to ApplyRange() but with a number of advantages.
- Somewhat in response to this thread: http://www.animemusicvideos.org/forum/v ... 5&t=101930
- 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!
Code: Select all
range( startframe,endframe, mod, fadein,fadeout, mod_extra, head,tail, length ) or rg( head, startframe, endframe, tail, mod, mod_extra )
- Lets imagine you did what Range() does within an editing GUI:
- The mod parameter stands for "modification"
- 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)
1. FILTERS & FILTERCHAINS (TYPICAL USAGE):USING MULTIPLE FILTERS & ARGUMENTS:Code: Select all
range( 1200,1300, "filter()" ) # 1.applies filter() from frames 1200 to 1300 range( 1200,1300, "filter" ) # 2.same as last example (using default arguments) range( 1200,1300, "filter(args)" ) # 3.same as last example using declared arguments range( 0,1300, "filter()" ) # 4.applies filter() from frame 0 to 1300 range( 1200, 0, "filter()" ) # 5.applies filter() from frame 1200 until the end range( 0, 0, "filter()" ) # 6.all frames range( 0, 0, "null" ) # 7.no frames range( 1200, "filter()" ) # 8.single-frame filtering range( 1200, "filter()",length=24 ) # 9.using a specific range length
USING FADEIN/FADEOUT & rg():Code: Select all
range( 1200,1300, "filter1().filter2().filter3()" ) #10.how to use multiple filters (filterchain) range( 1200,1300, "filter4(arg1,arg2,param3=arg3)" ) #11.include any arguments range( 1200,1300, """filter1().filter2().filter3()...filter4(arg1, param2="arg2")""" ) #12.triple quotes are needed here because of the single quotes around "arg2"
2. PRESETS & PRESET_NUMBERS:Code: Select all
range( 1200,1300, "filter()", 5,5 ) #13.fading in/out for 5 frames before/after range range( 1200,1300, "filter()", head=1192, tail=1315 ) #14.specific start/end points for fadein/fadeout rg( 1192,1200,1300,1315, "filter()" ) #14a.same as last example
3. REPLACEMENT_CLIPS & IMAGES: Using Range() to compensate for over-filteringCode: Select all
range( 1200,1300, "nuke", 0,0 ) #15.using a preset via Preset_Name (see Full Documentation for all presets) range( 1200,1300, 4 , 0,0 ) #16.using a preset via Preset_Number range( 1200,1300, mod=4 , 0,0 ) #17.same as last (all parameters can be called like this) range( 1200,1300, f1 , 0,0 ) #18.Using a Temporary preset (FilterChain, f1, must be set *first*. See below.) # 19. To Save a preset, open range.avsi, go to the Presets Section, and follow the pattern you see... # Just give it a new Name & Number, and you can always call it from within range()
Code: Select all
range( 1200,1300, c1, 0,0 ) #20.Replace frames using c1 (Clip, c1, must be set *first*. See below.) range( 1200,1300, c1, 0,0, "filter2()" ) #21.Extra Filtering (method 1) range( 1200,1300, c1.filter2(), 0,0 ) #22.Extra Filtering (method 2) range( 1200,1300, c2, 0,0 ) #23.Extra Filtering (method 3) range( 1200,1300, c3, 0,0 ) #24.using pre-filtered clip range( 1200,1300, i1, 0,0 ) #25.Imag Replacement using i1 (Image, i1, must be set *first*. See below.)
- SETTING FILTERCHAIN VARIABLES:
Code: Select all
f1 = """filter1().filter2().filter3()""" # f1 is "filterchain 1" f2 = """filter1().filter4().filter5()""" f3 = """filter6().filter7""" f4 = f1+".filter8()"
- SETTING CLIP VARIABLES:
Code: Select all
c1 = avisource("YOURORIGINALCLIP.avi") # c1 is "clip 1" c2 = avisource("YOURORIGINALCLIP.avi").filter1().filter2() c3 = avisource("PRE-FILTEREDCLIP.avi") c4 = clip1.filter3().filter4()
- SETTING IMAGE VARIABLES:
Code: Select all
c1 = avisource("YOURORIGINALCLIP.avi") all= c1.framecount() fps= c1.framerate() # i1 is "image 1" i1 = imagesource("YOURIMAGE.png", start=0, end=all, fps=fps) # you may need to change colorspace/framesize/audio etc...
FULL DOCUMENTATION (long version with example scenarios):
SCRIPT:
- v3.2 ( with Fadein/Fadeout, Clip-Replacement, Presets, Boundary-Checking, and rg() ):v1.0 (basic trim method):Spoiler :Spoiler :
INSTALLATION: [the usual]
- copy/paste the script into a .txt file,
- [make sure you have file extensions showing on your computer]
- rename to something like "Range().avsi"
- put it in your avisynth plugins folder, usually:
C:\Program Files\AviSynth 2.5\plugins or
C:\Program Files (x86)\AviSynth 2.5\plugins
##############################
CHANGELOG:
Code: Select all
CHANGELOG:
v3.2 - Included rg() function with conveniently rearranged variables: rg( head,startframe,endframe,tail,mod )
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.
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
Code: Select all
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...)
Code: Select all
KNOWN BUGS:
v3.0 - No known bugs ATM.
Hopefully I have addressed all the special cases from v2.0.
Please report any bugs :)
v2.0 - Special cases when:
* start == 0
* start == 1
* start == c.FrameCount() - 1
* start == c.FrameCount()
* start > c.FrameCount()
* end < 0
* end == 0
* end == c.FrameCount() - 1
* end == c.FrameCount()
* end > c.FrameCount()
v1.0 - No known bugs ATM. Please report any ;)
http://forum.doom9.org/showthread.php?p ... ost1453670
##############################
Enjoy,
~Phan