View Single Post
Old 8th July 2008, 07:03   #30  |  Link
mikeytown2
Resize Abuser
 
mikeytown2's Avatar
 
Join Date: Apr 2005
Location: Seattle, WA
Posts: 623
Starting to get somewhere... I'm using Fizick's Rotation Plugin (1.31) to rotate the mask.
http://avisynth.org.ru/rotate/rotate.html

Code:
# DissolveAGG() July 7th, 2008
#  Dissolve with a Wipe. Wipe has alpha channel mask and selectable angle for nice effect.
#
# Inputs
#  clip a - starting clip 
#  clip b - ending clip
#  int "Duration" - Number of overlapped frames
#  float "Angle" - Angle of the wipe
#  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", float "Angle", float "EndAngle", string "Mode", float "WindowSize", float "MaskSharpnessStart", float "MaskSharpnessEnd")
{
#Set Defaults
Duration=Default(Duration,Round(Framerate(a)))
Angle=Default(Angle,0)
EndAngle=Default(EndAngle,Angle)
width=a.width()
height=a.height()
Diagonal = Ceil(sqrt(pow(width(a),2)+pow(height(a),2)))

Mode=Default(Mode, "LeftToRight")
MaskSharpnessStart=Default(MaskSharpnessStart, 50.0)
MaskSharpnessEnd=Default(MaskSharpnessEnd, MaskSharpnessStart)
WindowSize=Default(WindowSize, 2.0)
AudioMix=Dissolve(a, b, Duration).KillVideo()
a = a.KillAudio()
b = b.KillAudio()

#Check Input
Assert(Mode=="LeftToRight" || Mode=="RightToLeft" || Mode=="TopToBottom" || Mode=="BottomToTop", 
\"DissolveAGG: Only Four Modes are possible: LeftToRight, RightToLeft, TopToBottom, BottomToTop. Mode=" + Mode)
Assert(Duration >= 0, "DissolveAGG: Duration [" + String(Duration) + "] must not be a negative value")
Assert(Duration < a.Framecount(), "DissolveAGG: Duration[" + String(Duration) + "] must be less than " + Chr(10) + "clip A length[" + String(a.Framecount()) + "]")
Assert(Duration < b.Framecount(), "DissolveAGG: Duration[" + String(Duration) + "] must be less than " + Chr(10) + "clip B length[" + String(b.Framecount()) + "]")



#Set Parameters
aMid = Trim(a, FrameCount(a)-Duration, 0)
bMid = Trim(b, 0, -Duration)
EvalString = Mode=="LeftToRight"? "BlankWidth=Int(4/2*WindowSize)
BlankHeight=Diagonal
startX1=BlankWidth + 0.5
endX1=1.5
startY1=0
endY1=0
x2=WindowSize*2-2
y2=0
ClipLeft=bMid
ClipRight=aMid" : Mode=="RightToLeft"? "BlankWidth=Int(4/2*WindowSize)
BlankHeight=Diagonal
startX1=1.5
endX1=BlankWidth + 0.5
startY1=0
endY1=0
x2=WindowSize*2-2
y2=0
ClipLeft=aMid
ClipRight=bMid" : Mode=="TopToBottom"? "BlankWidth=Diagonal
BlankHeight=Int(6/2*WindowSize)
startX1=0
endX1=0
startY1=BlankHeight + 0.5
endY1=3.5
x2=0
y2=WindowSize*3-4
ClipLeft=bMid
ClipRight=aMid" : Mode=="BottomToTop"? "BlankWidth=Diagonal
BlankHeight=Int(6/2*WindowSize)
startX1=0
endX1=0
startY1=3.5
endY1=BlankHeight + 0.5
x2=0
y2=WindowSize*3-4
ClipLeft=aMid
ClipRight=bMid" : ""
Eval(EvalString)

#Make Mask
BlackBar = BlankClip(a, length=Duration+2, width=BlankWidth, height=BlankHeight, pixel_type="RGB32")
WhiteBar = BlankClip(BlackBar, color=$FFFFFF)
BWmask = Mode=="LeftToRight" || Mode=="RightToLeft" ? StackHorizontal(BlackBar,WhiteBar) : StackVertical(BlackBar,WhiteBar) 
BWmask = BWmask.Animate(0,Duration+1,"GaussResize",
\ Diagonal, Diagonal, startX1, startY1, x2, y2, MaskSharpnessStart,
\ Diagonal, Diagonal, endX1, endY1, x2, y2, MaskSharpnessEnd)
BWmask = BWmask.Trim(1, Duration).Animate(0, framecount(BWmask)-1, "Rotate", Angle, $000000, 0, -1, Angle, width, height,  EndAngle, $000000, 0, -1, EndAngle, width, height)

#Glue it together
Trim(a, 0, FrameCount(a)-Duration-1)
last = (Duration > 0 ? last + Overlay(ClipLeft, ClipRight, mask=BWmask, pc_range=True) : last)
last + Trim(b, Duration, 0)
HasAudio(AudioMix) ? AudioDub(last,AudioMix) : last
}
Example
Code:
a = ColorBars(320,320).Trim(0,99)
b = a.invert()

DissolveAGG(a,b, 80, angle=-15.0, endangle=105.0, WindowSize=10)
It's not "perfect" because it uses the clip's Diagonal to calc the mask, thus the start and end is a little off. thats what the -15 and 105 is for. Ideally it would be 0 and 90. It falls apart if its not square like it is for the example.


Edit: I think if i where to use EffectRotation i could make this behave better, because i can select the center of rotation. I could do it with zoom as well now that i think about it. Doing that i should be able to keep the arc in the corner, and that should get rid of the -15 and 105 oddness. it will be hard to make this a smart function...

Last edited by mikeytown2; 10th July 2008 at 09:03.
mikeytown2 is offline   Reply With Quote