Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage

Reply
 
Thread Tools Search this Thread Display Modes
Old 17th August 2014, 20:11   #1  |  Link
mugz
Registered User
 
Join Date: Nov 2013
Posts: 16
ApplyRange Bug?

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/...rs/animate.htm

Am I doing something wrong?

Edit: I get "invalid arguments to function "ApplyRange" from AvsPmod.
mugz is offline   Reply With Quote
Old 17th August 2014, 20:28   #2  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 4,384
Error is expected, because you're changing the start and end arguments

Quote:
ApplyRange is a special case of Animate where start_args = end_args
http://avisynth.nl/index.php/Animate
poisondeathray is offline   Reply With Quote
Old 17th August 2014, 20:41   #3  |  Link
mugz
Registered User
 
Join Date: Nov 2013
Posts: 16
Quote:
Originally Posted by poisondeathray View Post
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?
mugz is offline   Reply With Quote
Old 17th August 2014, 20:51   #4  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 4,384
Quote:
Originally Posted by mugz View Post
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)
poisondeathray is offline   Reply With Quote
Old 17th August 2014, 21:01   #5  |  Link
mugz
Registered User
 
Join Date: Nov 2013
Posts: 16
Quote:
Originally Posted by poisondeathray View Post
"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]")

Last edited by mugz; 17th August 2014 at 21:08.
mugz is offline   Reply With Quote
Old 17th August 2014, 21:08   #6  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 4,384
Quote:
Originally Posted by mugz View Post
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
poisondeathray is offline   Reply With Quote
Old 17th August 2014, 21:24   #7  |  Link
mugz
Registered User
 
Join Date: Nov 2013
Posts: 16
Quote:
Originally Posted by poisondeathray View Post
"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.

Last edited by mugz; 17th August 2014 at 21:30.
mugz is offline   Reply With Quote
Old 17th August 2014, 21:44   #8  |  Link
creaothceann
Registered User
 
Join Date: Jul 2010
Location: Germany
Posts: 360
You can write a function that does the trimming.

Code:
...
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)

Last edited by creaothceann; 17th August 2014 at 22:41.
creaothceann is offline   Reply With Quote
Old 17th August 2014, 21:57   #9  |  Link
poisondeathray
Registered User
 
Join Date: Sep 2007
Posts: 4,384
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
.
.
.


Code:

#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)
}

Last edited by poisondeathray; 17th August 2014 at 22:01.
poisondeathray is offline   Reply With Quote
Old 17th August 2014, 23:26   #10  |  Link
mugz
Registered User
 
Join Date: Nov 2013
Posts: 16
Thanks!
mugz is offline   Reply With Quote
Old 17th August 2014, 23:41   #11  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,407
Quote:
Originally Posted by creaothceann View Post
Code:
        p1 = Trim(0, -i).FadeOut(NumberOfFrames).Trim(0, -i)              # FadeOut adds a blank frame
FadeOut0() is a variant that doesn't add any frames, allowing you to omit the second Trim().

@mugz: For crossfades, you might find Dissolve() useful.
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:08.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.