View Full Version : ApplyRange Bug?
mugz
17th August 2014, 20:11
Using an example for "Animate", I'm trying to create a scene that fades to black, but only over a certain range of frames. Im trying to figure out why this works:
Animate(4900,4950,"Levels", 0,1,255,0,255, 0,1,255,0,0)
but this doesn't:
ApplyRange(4900,4950,"Levels", 0,1,255,0,255, 0,1,255,0,0)
According to this it seems like it should work:
http://avisynth.org.ru/docs/english/corefilters/animate.htm
Am I doing something wrong?
Edit: I get "invalid arguments to function "ApplyRange" from AvsPmod.
poisondeathray
17th August 2014, 20:28
Error is expected, because you're changing the start and end arguments
ApplyRange is a special case of Animate where start_args = end_args
http://avisynth.nl/index.php/Animate
mugz
17th August 2014, 20:41
Error is expected, because you're changing the start and end arguments
http://avisynth.nl/index.php/Animate
Ok, now I get it. What I am trying to do is create a gradual fade to black over range of frames like can be done with animate, but not have it applied to any frames outside the range, do you know of a way to do that? I want to have several scenes fade from one to the other and it appears that fadein and fadeout only work at the beginning and end of clips. I don't want to cut the video into several pieces and then have to join them all back together, any suggestions?
poisondeathray
17th August 2014, 20:51
What I am trying to do is create a gradual fade to black over range of frames like can be done with animate, but not have it applied to any frames outside the range, do you know of a way to do that? I want to have several scenes fade from one to the other and it appears that fadein and fadeout only work at the beginning and end of clips. I don't want to cut the video into several pieces and then have to join them all back together, any suggestions?
"fade to black" isn't the same thing as a crossfade where "clip A" fades into "clip B"
Can you describe more specifically what you want to do ?
You can probably use animate() with overlay() and adjust the opacity parameter
Alternatively you can control using layer luma matte layer that controls the opacity (you're using a mask that controls the opacity of a layer. White = 100% visible, Black = 0 % visible, shades in between are intermediate)
mugz
17th August 2014, 21:01
"fade to black" isn't the same thing as a crossfade where "clip A" fades into "clip B"
Can you describe more specifically what you want to do ?
You can probably use animate() with overlay() and adjust the opacity parameter
Alternatively you can control using layer luma matte layer that controls the opacity (you're using a mask that controls the opacity of a layer. White = 100% visible, Black = 0 % visible, shades in between are intermediate)
Actually, at this first scene, I don't want to do a cross-fade, just fade out the first scene then go right into the second although I may want to do crossfades later - i'm just doing it as I go along and deciding as I go. I think if I could figure out how to do the fadeout, doing a fade in would use the same method in reverse.
I'd never messed with fadein / fadeout before - I never imagined doing it between scenes would be this complicated. I'll look into overlay.
EDIT: Actually, this convoluted mess seems to work :)
blah1=Animate(4900,4950,"Levels", 0,1,255,0,255, 0,1,255,0,0)
ReplaceFramesSimple(last, blah1, mappings="[4900 4950]")
poisondeathray
17th August 2014, 21:08
Actually, at this first scene, I don't want to do a cross-fade, just fade out the first scene then go right into the second although I may want to do crossfades later - i'm just doing it as I go along and deciding as I go. I think if I could figure out how to do the fadeout, doing a fade in would use the same method in reverse.
I'd never messed with fadein / fadeout before - I never imagined doing it between scenes would be this complicated. I'll look into overlay.
"Fade out and right into the second" - it's still not clear what you want to do. For example does it fade out to black, stay black for a while, then the 2nd scene abruptly starts ?
You don't have to "physically" cut the video. You can use Trim() in avisynth and append the segments using AlignedSplice(). ie. everything can be done in the script
If you describe more clearly what you want, I'm sure people here can give you several methods that would probably work
mugz
17th August 2014, 21:24
"Fade out and right into the second" - it's still not clear what you want to do. For example does it fade out to black, stay black for a while, then the 2nd scene abruptly starts ?
You don't have to "physically" cut the video. You can use Trim() in avisynth and append the segments using AlignedSplice(). ie. everything can be done in the script
If you describe more clearly what you want, I'm sure people here can give you several methods that would probably work
I was just trying to gradually fade to black over a range of frame numbers - and contain the modifications to that particular range of frames only - I finally found a solution that works... (see edit above).
I'm just surprised that there doesn't seem to be a plugin already that does that easily.
creaothceann
17th August 2014, 21:44
You can write a function that does the trimming.
...
Insert_FadeOut(1000)
function Insert_FadeOut(clip c, int i, int "NumberOfFrames") {
c
NumberOfFrames = default(NumberOfFrames, round(FrameRate * 2)) # ca. 2 seconds
p1 = Trim(0, -i).FadeOut(NumberOfFrames).Trim(0, -i) # FadeOut adds a blank frame
p2 = Trim(i, 0)
p1 + p2
# (c.HasAudio) ? last.AudioDub(c) : last # uncomment this line if you don't want the audio to fade
}
(note that i cannot be <= 0; this simple function has no error handling)
poisondeathray
17th August 2014, 21:57
Or if you want a helper function. I called it "FTB" but you can rename it whatever you want for easier use. FTB(start frame, number of frames)
eg.
WhateverSource()
FTB(4900,50) #this would replace frames 4900-4950 with a fade to black
FTB(6000,10) #this would replace frames 6000-6010 with a fade to black
.
.
.
#FadeToBlackWithin
#Replaces frames within a clip from Start Number, for a given number of frames
#eg. FTB(100,50) would fade gradually from frame number 100 to 150, where 150 would be 100% black
function FTB(clip Source, int start, int frames)
{
an=Animate(source, start, (start+frames), "Levels", 0,1,255,0,255, 0,1,255,0,0)
Source.trim(0,-start) ++ an.trim(start,start+frames) ++ Source.trim(start+frames+1,0)
}
mugz
17th August 2014, 23:26
Thanks!
Gavino
17th August 2014, 23:41
p1 = Trim(0, -i).FadeOut(NumberOfFrames).Trim(0, -i) # FadeOut adds a blank frame
FadeOut0 (http://avisynth.nl/index.php/FadeOut0)() is a variant that doesn't add any frames, allowing you to omit the second Trim().
@mugz: For crossfades, you might find Dissolve (http://avisynth.nl/index.php/Dissolve)() useful.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.