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 8th November 2006, 15:25   #1  |  Link
Livesms
Registered User
 
Livesms's Avatar
 
Join Date: Mar 2006
Posts: 184
Fade/Dissolve (like Womble MPEG Wizard)

Is there any plugins for makeing transitions like in Womble MPEG Video Wizard.
Simple Dissolve if not so good as Womble's Fade (Left to Right / Right to Left)

For example - this was made by WMVW.

I want such things in with AviSynth.
Livesms is offline   Reply With Quote
Old 9th November 2006, 02:20   #2  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
Avisynth provides FadeIn, FadeOut, FadeIO and Disolve native filters.

Many other effects can be created using Animate with layer or overlay.
Code:
...
Global GlobClip=Last
...
Animate(1000, 1100, "DoIt", 0, 100)
...
# Slide GlobClip in from bottom right corner
Function DoIt(Clip clip, Int I) {
  clip
  Fx=Round(Width() * (100-I)/100.0)
  Fy=Round(Height() * (100-I)/100.0)
  Layer(GlobClip, "Add", X=Fx, Y=Fy)
  Return Last
}
IanB is offline   Reply With Quote
Old 9th November 2006, 07:12   #3  |  Link
Livesms
Registered User
 
Livesms's Avatar
 
Join Date: Mar 2006
Posts: 184
Quote:
Originally Posted by IanB View Post
Avisynth provides FadeIn, FadeOut, FadeIO and Disolve native filters.

Many other effects can be created using Animate with layer or overlay.
Code:
...
Global GlobClip=Last
...
Animate(1000, 1100, "DoIt", 0, 100)
...
# Slide GlobClip in from bottom right corner
Function DoIt(Clip clip, Int I) {
  clip
  Fx=Round(Width() * (100-I)/100.0)
  Fy=Round(Height() * (100-I)/100.0)
  Layer(GlobClip, "Add", X=Fx, Y=Fy)
  Return Last
}
Thank you, but it is not really what I want

I want filter for such transition
Livesms is offline   Reply With Quote
Old 9th November 2006, 08:05   #4  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
Okay, so effectivly you want to slide an alpha channel mask across the images, but the images don't move. They slide blend across.

1st you need a mask image 3 times wider than your image, left is all black (full transparent), center ramps from black to white, right is all white (full opaque). Starting with a 5 pixel wide image (2 black, 1 grey, 2 white) BilinearResize it up to the right size should give the right effect. Use a variant of the Animate code above to make a clip that has the slide effect.
Code:
        ___    white
       /
      /
  ___/           black
   |   | -> slide
Using the 3 clip form of Overlay should then be a no brainer.

I'll knock up a suitable script when I get home if you like the sound of this.
IanB is offline   Reply With Quote
Old 9th November 2006, 08:08   #5  |  Link
Livesms
Registered User
 
Livesms's Avatar
 
Join Date: Mar 2006
Posts: 184
Quote:
Originally Posted by IanB View Post
Okay, so effectivly you want to slide an alpha channel mask across the images, but the images don't move. They slide blend across.

1st you need a mask image 3 times wider than your image, left is all black (full transparent), center ramps from black to white, right is all white (full opaque). Starting with a 5 pixel wide image (2 black, 1 grey, 2 white) BilinearResize it up to the right size should give the right effect. Use a variant of the Animate code above to make a clip that has the slide effect.
Code:
        ___    white
       /
      /
  ___/           black
   |   | -> slide
Using the 3 clip form of Overlay should then be a no brainer.

I'll knock up a suitable script when I get home if you like the sound of this.
I'm not a good avs script writer - so I'll be waiting for your script
Livesms is offline   Reply With Quote
Old 9th November 2006, 16:28   #6  |  Link
Wilbert
Moderator
 
Join Date: Nov 2001
Location: Netherlands
Posts: 6,364
For example:

Code:
# move mask from left to right and use it for c1/c2
Function DoIt(clip clip1, clip clip2, clip maskc, int I) {
  # I runs from 0 to 2*384
  maskc2 = maskc.Crop(I, 0, 384, 288)
  Overlay(clip1, clip2, mask=maskc2, X=0, Y=0, mode="blend", opacity=1)
}

c1 = ImageSource("D:\Captures\Slider\DanielaPestova.jpg").Loop(0, 400) # 384x288
c2 = ImageSource("D:\Captures\Slider\AngelicaBridges.jpg").BicubicResize(384, 288).Loop(0, 400)

b1 = BlankClip(width=2, height=288, color=$000000)
b2 = BlankClip(width=1, height=288, color=$808080)
b3 = BlankClip(width=2, height=288, color=$FFFFFF)
#maskc = StackHorizontal(b1, b2, b3).BicubicResize(384, 288)
maskc = StackHorizontal(b1, b2, b3).BicubicResize(3*384, 288)

# I runs from 0 to 2*384
# I = 384
# DoIt(c1, c2, maskc, I)
Animate(100, 300, "DoIt", c1, c2, maskc, 0, c1, c2, maskc, 2*c1.width)
Make sure that c1 and c2 are of the same size, and maskc should be of the same height as c1 and c2.

Nice example for the docs, thx very much!

Last edited by Wilbert; 9th November 2006 at 16:31.
Wilbert is offline   Reply With Quote
Old 9th November 2006, 20:09   #7  |  Link
Livesms
Registered User
 
Livesms's Avatar
 
Join Date: Mar 2006
Posts: 184
Quote:
Originally Posted by Wilbert View Post
For example:

Code:
# move mask from left to right and use it for c1/c2
Function DoIt(clip clip1, clip clip2, clip maskc, int I) {
  # I runs from 0 to 2*384
  maskc2 = maskc.Crop(I, 0, 384, 288)
  Overlay(clip1, clip2, mask=maskc2, X=0, Y=0, mode="blend", opacity=1)
}

c1 = ImageSource("D:\Captures\Slider\DanielaPestova.jpg").Loop(0, 400) # 384x288
c2 = ImageSource("D:\Captures\Slider\AngelicaBridges.jpg").BicubicResize(384, 288).Loop(0, 400)

b1 = BlankClip(width=2, height=288, color=$000000)
b2 = BlankClip(width=1, height=288, color=$808080)
b3 = BlankClip(width=2, height=288, color=$FFFFFF)
#maskc = StackHorizontal(b1, b2, b3).BicubicResize(384, 288)
maskc = StackHorizontal(b1, b2, b3).BicubicResize(3*384, 288)

# I runs from 0 to 2*384
# I = 384
# DoIt(c1, c2, maskc, I)
Animate(100, 300, "DoIt", c1, c2, maskc, 0, c1, c2, maskc, 2*c1.width)
Make sure that c1 and c2 are of the same size, and maskc should be of the same height as c1 and c2.

Nice example for the docs, thx very much!
Ok! It is much closer to what I want

Is it possible to make script more general - it has srtaight width/height (384/288).

Is it possible to make the only function with 2 input clips and maybe overlap and get result of 2 clip crossfaded.

PS: And what about audio - Is it possible to use simple Dissolve to crassfade audio only?
Livesms is offline   Reply With Quote
Old 9th November 2006, 23:04   #8  |  Link
foxyshadis
ангел смерти
 
foxyshadis's Avatar
 
Join Date: Nov 2004
Location: Lost
Posts: 9,556
Replace all references to 384 by width(), and all to 288 be height(), and you're pretty much there. (You may need to qualify it if you have no implicit last.) Then replace the 100 and 300 in animate by startframe and endframe, make them parameters to a function, and you're done.
foxyshadis is offline   Reply With Quote
Old 10th November 2006, 00:07   #9  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
@Livesms, Learning AVS script is easy, just start with some rough house script thats does something a bit like what you want and start changing it. Start by changing the numbers that effect shape and size, then as confidence grows change the structure. After a while you realise hard code numbers are gross and you parameterise your scripts for quick adaption next time.

And yes dissolve will do the audio crossfade very nicely. Just do an AudioDub(Dissolve(.....)) to graft in the tweaked audio track.

@Wilbert, nice throw together from a very rough idea.

@All, Here's my rendering from half an hours tinkering.

Points of interest :-
  • Using crop to slide the mask was not granular enough, so I used the subpixel element of the resizers.
  • I needed some extra width for the higher order resizers. So I upped it to an 8 pixel prototype, then used a 2 pixel scan window. (Gunna have to fix up this for 2.6 Grrr)
  • I dropped the center grey pixel, it causes an unpleasant ledge in the middle of the slope.
  • I tried all the resizers. As an aside it is interesting to see the various ringing and artifacts with such a hugh upscale when you stack them together for relative viewing.
  • Changing the 2.0 scan window on the resizers has some interesting effects.
  • I found the Gauss resizer gave the nicest ramp for the effect. Adjusting P together with the scan window (2.0) gives many nice variations to the apperance of the effect.
  • For some reason the bilinear resizer generated mask sometimes gots a bright bump in the trailing plataue.
Code:
Global Hi=480
Global Wi=720

Global T=25

A=BlankClip(T+1, 4, Hi, pixel_type="RGB32", color=$000000)
C=BlankClip(T+1, 4, Hi, pixel_type="RGB32", color=$ffffff)

StackHorizontal(A, C)

Animate(0, T, "TryIt", 1.5, 4.5) # Dodge the edge conditions

Function TryIt(clip C, Float X) {
# A = C.PointResize(Wi, Hi, X, 0, 2.0, 0)
# B = C.BiLinearResize(Wi, Hi, X, 0, 1.0, 0)
# D = C.BiCubicResize(Wi, Hi, 1./3, 1./3, X, 0, 2.0, 0)
# E = C.Spline16Resize(Wi, Hi, X, 0, 2.0, 0)
# F = C.LanczosResize(Wi, Hi, X, 0, 2.0, 0)
# G = C.Spline36Resize(Wi, Hi, X, 0, 2.0, 0)
# H = C.Lanczos4Resize(Wi, Hi, X, 0, 2.0, 0)
# I = C.GaussResize(Wi, Hi, X, 0, 2.0, 0, P=10)
# J = C.GaussResize(Wi, Hi, X, 0, 2.0, 0, P=30)

  K = C.GaussResize(Wi, Hi, X, 0, 2.0, 0, P=50)
  Return K

# Return StackVertical(A, B, D, E, F, G, H, I, J, K)
}


X=BlankClip(300, Wi, Hi, pixel_type="RGB32", color=$E02020).\
  Subtitle("< < < Red. > > >", align=5, size=90, text_color=$00DF00)

Y=BlankClip(300, Wi, Hi, pixel_type="RGB32", color=$2020E0).\
  Subtitle("< < < Blue > > >", align=5, size=90, text_color=$DF00DF)

Fx=FrameCount(X)
Fy=FrameCount(Y)


Trim(X, 0, Fx-T-2) + \
Overlay(Trim(X, Fx-T-1, 0), Trim(Y, 0, T), mask=last, pc_range=True)
\ + Trim(Y, T+1, 0)
IanB is offline   Reply With Quote
Old 13th November 2006, 18:31   #10  |  Link
Livesms
Registered User
 
Livesms's Avatar
 
Join Date: Mar 2006
Posts: 184
Quote:
Originally Posted by IanB View Post
Code:
Global Hi=480
Global Wi=720
....
And what about left to right one?

Is it possible to combine all code to one compact function without global width/height and other stuff. Input clips and time for transition will be declared for function and 2 clips merged with transition will be returned.
Livesms is offline   Reply With Quote
Old 14th November 2006, 01:31   #11  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
Left to right, easy swap the black and white prototype clips (A & C) and animate the other way i.e. 4.5 -> 1.5! Up and down is just as easy, use a StackVertical and buzz the vertical crop parameters of the resizer instead of the horizontal .

Compact function, with parameters, very do-able. The structure of the script reflects how I wrote it. I first threw together the sliding mask clip without any reference to a supplied clip, hence the Hi and Wi. In a practicle script I would have used Height(clip) and Width(clip) and the X and Y would have been real loaded from real files not coloured BlankClips with text.

As I said hack the rough scripts Wilbert and I composed and build them into something more flexible and polished. You can't break anything, worst that happens is you get a script that doesn't quite do what you want. So you modify it some more.

If you make a genuine effort to put together and polish a general script I will help you.
IanB is offline   Reply With Quote
Old 14th November 2006, 07:22   #12  |  Link
Livesms
Registered User
 
Livesms's Avatar
 
Join Date: Mar 2006
Posts: 184
Quote:
Originally Posted by IanB View Post
Left to right, easy swap the black and white prototype clips (A & C) and animate the other way i.e. 4.5 -> 1.5! Up and down is just as easy, use a StackVertical and buzz the vertical crop parameters of the resizer instead of the horizontal .

Compact function, with parameters, very do-able. The structure of the script reflects how I wrote it. I first threw together the sliding mask clip without any reference to a supplied clip, hence the Hi and Wi. In a practicle script I would have used Height(clip) and Width(clip) and the X and Y would have been real loaded from real files not coloured BlankClips with text.

As I said hack the rough scripts Wilbert and I composed and build them into something more flexible and polished. You can't break anything, worst that happens is you get a script that doesn't quite do what you want. So you modify it some more.

If you make a genuine effort to put together and polish a general script I will help you.
OK - I'll try
Livesms is offline   Reply With Quote
Old 15th November 2006, 16:48   #13  |  Link
zemog
Registered User
 
Join Date: Sep 2006
Location: Madrid (Spain)
Posts: 20
Livesms

I use AviSynth from some time ago to edit and improve my domestic videos but I never made any function (I am only a software advanced user). Reading this threat and thinking these kind of dissolves would be also useful for me , I guessed it’d be a good exercise to make my first function trying to do something as IamB suggests you.

From the IamB code in his post of 10th November 2006 and using the fantastic qwerpoi AviSynth editor AvsP and after working for some hours, here is the result:

Quote:
# DissolveAGG(clip A, clip B, Int "TFrames", String "Mode")
# Tframes define the number of overlapped frames
# Four modes are possible: LeftToRight, RightToLeft, TopToBotoom and
# BotoomToTop depending where the overlapping stars and ends.

Function DissolveAGG(clip A, clip B, Int "TFrames", String "Mode") {
Global Hi = Height(A)
Global Wi = Width(A)
Global FS = Framerate(A)
Global Fa=FrameCount(A)
Global Fb=FrameCount(B)
Global TFrames = Default(TFrames, 25)
Mode = Default(Mode, "LeftToRight")
(Mode=="LeftToRight") ? LToR(A, B) :\
(Mode=="RightToLeft") ? RToL(A, B) :\
(Mode=="TopToBottom") ? TToB(A, B) :\
BToT(A, B)

Function H(clip C, Float X) {
K = C.GaussResize(Wi, Hi, X, 0, 2.0, 0, P=50)
Return K
}
Function V(clip C, Float X) {
K = C.GaussResize(Wi, Hi, 0, X, 0, 2.0, P=40)
Return K
}
Function LToR(clip A, clip B) {
AA=BlankClip(TFrames+1, 4, Hi, pixel_type="RGB32", fps=FS, color=$000000)
BB=BlankClip(TFrames+1, 4, Hi, pixel_type="RGB32", fps=FS, color=$ffffff)
D=StackHorizontal(AA, BB)
Xi=4.5
Xf=1.5
E=D.Animate(0, TFrames, "H", Xi, Xf)
Return Trim(A, 0, Fa-TFrames-2) + Overlay( Trim(B, 0, TFrames), Trim(A, Fa-TFrames-1, \
0),mask=E, pc_range=True) + Trim(B, TFrames+1, 0)
}
Function RToL(clip A, clip B) {
AA=BlankClip(TFrames+1, 4, Hi, pixel_type="RGB32", fps=FS, color=$000000)
BB=BlankClip(TFrames+1, 4, Hi, pixel_type="RGB32", fps=FS, color=$ffffff)
D=StackHorizontal(AA, BB)
Xi=1.5
Xf=4.5
E=D.Animate(0, TFrames, "H", Xi, Xf)
Return Trim(A, 0, Fa-TFrames-2) + Overlay(Trim(A, Fa-TFrames-1, 0), Trim(B, 0, TFrames), \
mask=E, pc_range=True) + Trim(B, TFrames+1, 0)
}
Function TToB(clip A, clip B) {
AA=BlankClip(TFrames+1, Wi, 6, pixel_type="RGB32", fps=FS, color=$000000)
BB=BlankClip(TFrames+1, Wi, 6, pixel_type="RGB32", fps=FS, color=$ffffff)
D=StackVertical(AA, BB)
Xi=6.5
Xf=3.5
E=D.Animate(0, TFrames, "V", Xi, Xf)
Return Trim(A, 0, Fa-TFrames-2) + Overlay( Trim(B, 0, TFrames), Trim(A, Fa-TFrames-1, \
0),mask=E, pc_range=True) + Trim(B, TFrames+1, 0)
}
Function BToT(clip A, clip B) {
AA=BlankClip(TFrames+1, Wi, 6, pixel_type="RGB32", fps=FS, color=$000000)
BB=BlankClip(TFrames+1, Wi, 6, pixel_type="RGB32", fps=FS, color=$ffffff)
D=StackVertical(AA, BB)
Xi=3.5
Xf=6.5
E=D.Animate(0, TFrames, "V", Xi, Xf)
Return Trim(A, 0, Fa-TFrames-2) + Overlay(Trim(A, Fa-TFrames-1, 0), Trim(B, 0, TFrames), \
mask=E, pc_range=True) + Trim(B, TFrames+1, 0)
}
}
It works fine for me except I didn’t be capable to validate Mode parameter. Try it and let me know your opinion or your alternative if you have done one.

At any rate I am sure the syntax of my function could be improve a lot. So perhaps somebody here can post constructive criticism or some suggestion that can help us to do these better.
zemog is offline   Reply With Quote
Old 15th November 2006, 17:05   #14  |  Link
Livesms
Registered User
 
Livesms's Avatar
 
Join Date: Mar 2006
Posts: 184
Quote:
Originally Posted by zemog View Post
It works fine for me except I didn’t be capable to validate Mode parameter. Try it and let me know your opinion or your alternative if you have done one.

At any rate I am sure the syntax of my function could be improve a lot. So perhaps somebody here can post constructive criticism or some suggestion that can help us to do these better.
You have done a great job

FrSp, I have no time to do this....
Now I have no willing to do the same job myself

I just add audio processing - Dissolve for each of function (lToR, RToL, BToT, TToB) and left LToR by default even when I set " " for method , cause you leave BToT as default for error input string I prefer LToR

Code:
Function DissolveAGG(clip A, clip B, Int "TFrames", String "Mode") {
Global Aaudio = A
Global Baudio = B
Global Hi = Height(A)
Global Wi = Width(A)
Global FS = Framerate(A)
Global Fa=FrameCount(A)
Global Fb=FrameCount(B)
Global TFrames = Default(TFrames, 25)
Mode = Default(Mode, "LeftToRight")
(Mode=="LeftToRight") ? LToR(A, B) :\
(Mode=="RightToLeft") ? RToL(A, B) :\
(Mode=="TopToBottom") ? TToB(A, B) :\
(Mode=="BottomToTop") ? BToT(A, B) :\
LToR(A, B)

Function H(clip C, Float X) {
K = C.GaussResize(Wi, Hi, X, 0, 2.0, 0, P=50)
Return K
}
Function V(clip C, Float X) {
K = C.GaussResize(Wi, Hi, 0, X, 0, 2.0, P=40)
Return K
}
Function LToR(clip A, clip B) {
AA=BlankClip(TFrames+1, 4, Hi, pixel_type="RGB32", fps=FS, color=$000000)
BB=BlankClip(TFrames+1, 4, Hi, pixel_type="RGB32", fps=FS, color=$ffffff)
D=StackHorizontal(AA, BB)
Xi=4.5
Xf=1.5
E=D.Animate(0, TFrames, "H", Xi, Xf)
Return AudioDub(Trim(A, 0, Fa-TFrames-2) + Overlay( Trim(B, 0, TFrames), Trim(A, Fa-TFrames-1, \
0),mask=E, pc_range=True) + Trim(B, TFrames+1, 0), Dissolve(Aaudio, Baudio, TFrames))
}
Function RToL(clip A, clip B) {
AA=BlankClip(TFrames+1, 4, Hi, pixel_type="RGB32", fps=FS, color=$000000)
BB=BlankClip(TFrames+1, 4, Hi, pixel_type="RGB32", fps=FS, color=$ffffff)
D=StackHorizontal(AA, BB)
Xi=1.5
Xf=4.5
E=D.Animate(0, TFrames, "H", Xi, Xf)
Return AudioDub(Trim(A, 0, Fa-TFrames-2) + Overlay(Trim(A, Fa-TFrames-1, 0), Trim(B, 0, TFrames), \
mask=E, pc_range=True) + Trim(B, TFrames+1, 0), Dissolve(Aaudio, Baudio, TFrames))
}
Function TToB(clip A, clip B) {
AA=BlankClip(TFrames+1, Wi, 6, pixel_type="RGB32", fps=FS, color=$000000)
BB=BlankClip(TFrames+1, Wi, 6, pixel_type="RGB32", fps=FS, color=$ffffff)
D=StackVertical(AA, BB)
Xi=6.5
Xf=3.5
E=D.Animate(0, TFrames, "V", Xi, Xf)
Return AudioDub(Trim(A, 0, Fa-TFrames-2) + Overlay( Trim(B, 0, TFrames), Trim(A, Fa-TFrames-1, \
0),mask=E, pc_range=True) + Trim(B, TFrames+1, 0), Dissolve(Aaudio, Baudio, TFrames))
}
Function BToT(clip A, clip B) {
AA=BlankClip(TFrames+1, Wi, 6, pixel_type="RGB32", fps=FS, color=$000000)
BB=BlankClip(TFrames+1, Wi, 6, pixel_type="RGB32", fps=FS, color=$ffffff)
D=StackVertical(AA, BB)
Xi=3.5
Xf=6.5
E=D.Animate(0, TFrames, "V", Xi, Xf)
Return AudioDub(Trim(A, 0, Fa-TFrames-2) + Overlay(Trim(A, Fa-TFrames-1, 0), Trim(B, 0, TFrames), \
mask=E, pc_range=True) + Trim(B, TFrames+1, 0), Dissolve(Aaudio, Baudio, TFrames))
}
}
Livesms is offline   Reply With Quote
Old 15th November 2006, 21:18   #15  |  Link
Fizick
AviSynth plugger
 
Fizick's Avatar
 
Join Date: Nov 2003
Location: Russia
Posts: 2,183
zemog,
IamB is really IanB
Fizick is offline   Reply With Quote
Old 15th November 2006, 22:15   #16  |  Link
zemog
Registered User
 
Join Date: Sep 2006
Location: Madrid (Spain)
Posts: 20
Quote:
Originally Posted by Fizick View Post
zemog,
IamB is really IanB
Thanks Fizick
IanB, I'm sorry and... : :
zemog is offline   Reply With Quote
Old 16th November 2006, 03:00   #17  |  Link
IanB
Avisynth Developer
 
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
Pretty good implementation.

Hint : When making a BlankClip that mostly needs to match an existing clip, explicitly provide that template clip as the 1st argument (this is currently the only filter that doesn't auto inherit Last as its input clip). Then just override the parameter that you want to be different. i.e
Code:
AA=BlankClip(clip=A, length=TFrames+1, width=4, pixel_type="RGB32", color=$000000)
Also using globals can bite when you want to use more than one instance of the function. Pass them down as arguments.
IanB is offline   Reply With Quote
Old 16th November 2006, 21:23   #18  |  Link
zemog
Registered User
 
Join Date: Sep 2006
Location: Madrid (Spain)
Posts: 20
Quote:
Originally Posted by IanB View Post
Hint : When making a BlankClip that mostly needs to match an existing clip, explicitly provide that template clip as the 1st argument (this is currently the only filter that doesn't auto inherit Last as its input clip). Then just override the parameter that you want to be different. i.e
Code:
AA=BlankClip(clip=A, length=TFrames+1, width=4, pixel_type="RGB32", color=$000000)
Also using globals can bite when you want to use more than one instance of the function. Pass them down as arguments.
Thanks a lot. I’ll follow your tips.
zemog is offline   Reply With Quote
Old 25th June 2008, 06:38   #19  |  Link
mikeytown2
Resize Abuser
 
mikeytown2's Avatar
 
Join Date: Apr 2005
Location: Seattle, WA
Posts: 623
Updated the DissolveAGG function, it's now one function with no globals. Changed TFrames to Duration

Code:
# DissolveAGG() June 25th, 2008
#  Dissolve with a Wipe. Wipe has alpha channel mask for nice effect.
#
# Inputs
#  clip a - starting clip 
#  clip b - ending clip
#  int "Duration" - Number of overlapped frames
#  string "Mode" - Four modes are possible: LeftToRight, RightToLeft, TopToBottom, BottomToTop.
#  float "WindowSize" - 2.0 is default. larger: more sharp.
#  float "MaskSharpnessStart" - 1: Big Blur; 100: Sharpest. Default 50.
#  float "MaskSharpnessEnd" - 1: Big Blur; 100: Sharpest. Default 50.


Function DissolveAGG(clip a, clip b, int "Duration", string "Mode", float "WindowSize", float "MaskSharpnessStart", float "MaskSharpnessEnd")
{
	#Set Defaults
	Duration=Default(Duration,30)
	width=a.width()
	height=a.height()
	Mode=Default(Mode, "LeftToRight")
	MaskSharpnessStart=Default(MaskSharpnessStart, 50.0)
	MaskSharpnessEnd=Default(MaskSharpnessEnd, 50.0)
	WindowSize=Default(WindowSize, 2.0)
	AudioMix=Dissolve(a, b, Duration).KillVideo()
	a = a.KillAudio()
	b = b.KillAudio()
	
	#Duration=Int(Duration/2.0*((2.0-WindowSize)*0.1+2.0))
	
	#Check Input
	Assert(Mode=="LeftToRight" || Mode=="RightToLeft" || Mode=="TopToBottom" || Mode=="BottomToTop", 
	\"DissolveAGG: Only Four Modes are possible: LeftToRight, RightToLeft, TopToBotoom BottomToTop. Mode=" + Mode)
	
	#Set Parameters
	EvalString = Mode=="LeftToRight"? "BlankWidth=Int(4/2*WindowSize)
	BlankHeight=height
	startX1=BlankWidth + 0.5
	endX1=1.5
	startY1=0
	endY1=0
	x2=WindowSize*2-2
	y2=0
	ClipLeft=b
	ClipRight=a" : Mode=="RightToLeft"? "BlankWidth=Int(4/2*WindowSize)
	BlankHeight=height
	startX1=1.5
	endX1=BlankWidth + 0.5
	startY1=0
	endY1=0
	x2=WindowSize*2-2
	y2=0
	ClipLeft=a
	ClipRight=b" : Mode=="TopToBottom"? "BlankWidth=height
	BlankHeight=Int(6/2*WindowSize)
	startX1=0
	endX1=0
	startY1=BlankHeight + 0.5
	endY1=3.5
	x2=0
	y2=WindowSize*2-2
	ClipLeft=b
	ClipRight=a" : Mode=="BottomToTop"? "BlankWidth=height
	BlankHeight=Int(6/2*WindowSize)
	startX1=0
	endX1=0
	startY1=3.5
	endY1=BlankHeight + 0.5
	x2=0
	y2=WindowSize*3-4
	ClipLeft=a
	ClipRight=b" : ""
	Eval(EvalString)

	#Make Mask
	BlackBar = BlankClip(a, length=Duration+1, width=BlankWidth, height=BlankHeight, pixel_type="RGB32", fps=a.Framerate())
	WhiteBar = BlankClip(BlackBar, color=$FFFFFF)
	BWmask = Mode=="LeftToRight" || Mode=="RightToLeft" ? StackHorizontal(BlackBar,WhiteBar) : StackVertical(BlackBar,WhiteBar) 
	BWmask = BWmask.Animate(0,Duration,"GaussResize",
	\ width, height, startX1, startY1, x2, y2, MaskSharpnessStart,
	\ width, height, endX1, endY1, x2, y2, MaskSharpnessEnd)
	
	#Glue it together
	Trim(a, 0, FrameCount(a)-Duration-2)
	last + Overlay(Trim(ClipLeft, 0, Duration), Trim(ClipRight, FrameCount(ClipRight)-Duration-1, 0), mask=BWmask, pc_range=True) 
	last + Trim(b, Duration+1, 0)
	AudioDub(last,AudioMix)
}

Example:
Code:
a = ColorBars().Trim(0,29)
b = a.invert()

DissolveAGG(a,b, 20, "LeftToRight", 2.0)
last + DissolveAGG(a,b, 20, "RightToLeft", 3.0)
last + DissolveAGG(a,b, 20, "TopToBottom", 4.0)
last + DissolveAGG(a,b, 20, "BottomToTop", 5.0)
last + DissolveAGG(a.Loop(2),b.Loop(2), 50, "BottomToTop", 10.0,100.0, 50.0)

BTW what does AGG stand for?

Last edited by mikeytown2; 25th June 2008 at 10:36.
mikeytown2 is offline   Reply With Quote
Old 25th June 2008, 14:26   #20  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
@mikeytown2: I like the way you've done this, but the R2L and B2T modes are broken because the wrong frames are used during the transition in these cases (ie when ClipLeft is 'a').

[EDIT: I bet you tested it with static clips, eg ColorBars ]

I think you need to set a LeftStart and RightStart in the parameter setup for each mode and do something like:
Code:
... Overlay(Trim(ClipLeft, LeftStart, -Duration), Trim(ClipRight, RightStart, -Duration), ...)
Also:
- your actual duration is Duration+1
- maybe add check for Duration against clip lengths?
- why do you use pc_range=true?

Last edited by Gavino; 25th June 2008 at 17:01.
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 07:37.


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