View Full Version : Transition effect filter
bigplac
1st August 2003, 16:18
Hello. How can i conbine clips with overlap and some nice transition effects like dissolve does but with blind,checkerboard,diagonal, gradient, stretch, ...?
Thanks.
E-Male
1st August 2003, 17:41
i thought about trying to do some of these, but atm i donīt have the time, sorry
DaveQB
1st August 2003, 22:00
yes i would be interested to see flters like these.
not demanding anything though; we are busy ppl.
:)
stickboy
2nd August 2003, 04:39
Last month, just for kicks, I wrote a user-defined function to perform wipes.
I haven't actually used it in practice, though, so I'm not sure how well it works.
# Wipe
#
# Combines two clips using a wipe transition. The audio tracks will be
# blended during the transition.
#
# PARAMETERS:
# c1 - the first clip
# c2 - the second clip
# overlap - the desired number of transitional frames
# direction - the wipe direction;
# { "right", "left", "up", "down" }
# (default: "right")
#
function Wipe(clip c1, clip c2, int overlap, string "direction")
{
assert( c1.Width() == c2.Width()
\ && c1.Height() == c2.Height()
\ && c1.Framerate() == c2.Framerate(),
\ "Wipe: clips must have identical attributes ")
assert(c1.FrameCount() > overlap && c2.FrameCount() > overlap,
\ "Wipe: each clip must have at least <overlap> frames")
direction = default(direction, "right")
directionIndex = (direction == "right")
\ ? 0
\ : ((direction == "left")
\ ? 1
\ : ((direction == "down")
\ ? 2
\ : ((direction == "up")
\ ? 3
\ : -1)))
assert(directionIndex >= 0 && directionIndex < 4,
\ "Wipe: invalid direction")
seg1 = c1.Trim3(0, length=(c1.FrameCount() - overlap))
seg2 = c2.Trim3(overlap)
trans1 = c1.Trim3(c1.FrameCount() - overlap)
trans2 = c2.Trim3(0, length=overlap)
trans = Select(directionIndex,
\ Animate(0, overlap, "SpliceHorizontal", trans1, trans2, 0,
\ trans1, trans2, c1.Width()),
\ Animate(0, overlap, "SpliceHorizontal", trans2, trans1, c1.Width(),
\ trans2, trans1, 0),
\ Animate(0, overlap, "SpliceVertical", trans1, trans2, 0,
\ trans1, trans2, c1.Height()),
\ Animate(0, overlap, "SpliceVertical", trans2, trans1, c1.Height(),
\ trans2, trans1, 0))
AudioDub(seg1 + trans + seg2, Dissolve(c1, c2, overlap))
}
function SpliceHorizontal(clip c1, clip c2, int x)
{
# in case we're dealing with YUY2 or YV12 video, crop only on even
# boundaries
x = (x % 2 == 0) ? x : (x - 1)
return (x == 0)
\ ? c1
\ : ((x == c1.Width())
\ ? c2
\ : StackHorizontal(c2.Crop(0, 0, x, 0),
\ c1.Crop(x, 0, c1.Width() - x, 0)))
}
function SpliceVertical(clip c1, clip c2, int y)
{
# in case we're dealing with YUY2 or YV12 video, crop only on even
# boundaries
y = (y % 2 == 0) ? y : (y - 1)
return (y == 0)
\ ? c1
\ : ((y == c1.Height())
\ ? c2
\ : StackVertical(c2.Crop(0, 0, 0, y),
\ c1.Crop(0, y, 0, c1.Height() - y)))
}
(see my thread about Trim (http://forum.doom9.org/showthread.php?s=&threadid=58358) for my Trim3 function)
Richard Berg
3rd August 2003, 07:52
Stickboy, would you mind adding your functions to the Wiki? http://www.avisynth.org/index.php?page=ShareFunctions
stickboy
3rd August 2003, 10:33
I'm planning to do it; I just haven't gotten around to figuring out the Wiki system just yet.
DataCable
10th August 2003, 04:30
You can also make more complex transitions using the Layer filter, with an appropriate transparency mask. i.e., To do a wipe, you'd need a simple B/W animation of a white frame wiping across a black frame. You could even generate a mask using stickboy's functions on all-black and all-white frames, then run a Blur on the mask to create a slight fuzzy edge on the transition (ala the numerous "Star Wars" wipes) rather than a hard-cropped edge.
I've toyed with these ideas in my head since discovering AviSynth last week, but haven't actually applied them, so I haven't written any code for them yet.
DataCable
10th August 2003, 07:59
Ok, that got my thought process cranking, so I just threw this together. Instead of Blurring the generated mask, I decided to Resize it down, then Resize it back up to original input clip size, which performs the blur. I found Blur didn't have nearly as much effect as I wanted on a single pass, and left a fuzzy light stripe on the right edge of the mask, which I found distracting. (I borrowed a few lines of code from Wipe, I hope you don't mind, stickboy ;) )
#FuzzyWipe
#
#Perform a "fuzzy" wipe from one clip to another. Uses stickboy's "wipe" function to generate the mask.
#
#Parameters:
# C1 - First clip
# C2 - Second clip
# Overlap - Number of transitional frames
# FuzzWidth - Width (in pixels, approximate) of the blended boundary. 0 = sharp boundary
# Direction - Diretion of wipe
function FuzzyWipe( clip C1, clip C2, int overlap, int Fuzzwidth, string "Direction")
{
# Generate the Black and White clips used to create the Wipe Mask
BlackFrame = BlankClip( overlap+1, C1.Width, C1.Height, fps=C1.framerate, Color=$000000 )
WhiteFrame = BlankClip( overlap+1, C1.Width, C1.Height, fps=C1.framerate, Color=$FFFFFF )
# Define how small to rezise the mask
WipeWidth = C1.Width / ( Fuzzwidth + 1 )
WipeHeight = C1.Height / ( Fuzzwidth + 1 )
# Generate the Wipe Mask
WipeMask = Wipe( BlackFrame, WhiteFrame, overlap, Direction )
WipeMask = Trim3( WipeMask, 1 ).BilinearResize( WipeWidth, WipeHeight ).Bicubicresize( C1.Width, C1.Height )
seg1 = c1.Trim3( 0, length=( c1.FrameCount() - overlap ) )
seg2 = c2.Trim3( overlap )
trans1 = c1.Trim3( c1.FrameCount() - overlap )
trans2 = c2.Trim3( 0, length=overlap ).Mask( WipeMask )
# Overlap the layers
trans = Layer( trans1, trans2 )
# Stitch it all together
AudioDub(seg1 + trans + seg2, Dissolve(c1, c2, overlap ))
}
DaveQB
10th August 2003, 08:08
definately share your ideas when you finalise them.
Sounds like it has loads of potential.
:D
WarpEnterprises
10th August 2003, 22:23
(without wanting to make too much promotion)
you can try Zoom(), it really works good for problems as discussed above (using the pan and rotate functionality)
DataCable
10th August 2003, 23:46
Funny you should mention that, WE, as the first script function I wrote was PanZoom (didn't know there was already a plugin to do this):
# PanZoom - Pan, Tilt and Zoom a small frame across a clip, with edge detection
# Parameters:
# Output_W, Output_H Output frame width/height
# Start_Frame, End_Frame Frame numbers to start/end the operation
# Start_Focus_X, Start_Focus_Y Starting center coordinates
# End_Focus_X, int End_Focus_Y Ending center coordinates
# Start_Zoom, End_Zoom Start/End zoom levels, 1 = Original size, 2 = 2x zoom, etc.
function PanZoom( clip Input, int Output_W, int Output_H,\
int Start_Frame, int End_Frame,\
int Start_Focus_X, int Start_Focus_Y,\
int End_Focus_X, int End_Focus_Y,\
float Start_Zoom, float End_Zoom )
{
Start_W = Output_W / Start_Zoom
Start_H = Output_H / Start_Zoom
Assert( Start_W <= Input.Width,\
"Start frame Width exceeds input clip dimensions. Reduce output frame size or increase Start_Zoom" )
Assert( Start_H <= Input.Height,\
"Start frame height exceeds input clip dimensions. Reduce output frame size or increase Start_Zoom" )
Start_HW = Start_W / 2
Start_HH = Start_H / 2
Start_Origin_X = Start_Focus_X - Start_HW
Start_Origin_X = Start_Origin_X < 0 ? 0 : Start_Origin_X
Start_Origin_X = Start_Origin_X + Start_W > Input.Width ? Input.Width - Start_W : Start_Origin_X
Start_Origin_Y = Start_Focus_Y - Start_HH
Start_Origin_Y = Start_Origin_Y < 0 ? 0 : Start_Origin_Y
Start_Origin_Y = Start_Origin_Y + Start_H > Input.Height ? Input.Height - Start_H : Start_Origin_Y
End_W = Output_W / End_Zoom
End_H = Output_H / End_Zoom
Assert( End_W <= Input.Width,\
"End frame Width exceeds input clip dimensions. Reduce output frame size or increase End_Zoom" )
Assert( End_H <= Input.Height,\
"End frame height exceeds input clip dimensions. Reduce output frame size or increase End_Zoom" )
End_HW = End_W / 2
End_HH = End_H / 2
End_Origin_X = End_Focus_X - End_HW
End_Origin_X = End_Origin_X < 0 ? 0 : End_Origin_X
End_Origin_X = End_Origin_X + End_W > Input.Width ? Input.Width - End_W : End_Origin_X
End_Origin_Y = End_Focus_Y - End_HH
End_Origin_Y = End_Origin_Y < 0 ? 0 : End_Origin_Y
End_Origin_Y = End_Origin_Y + End_H > Input.Height ? Input.Height - End_H : End_Origin_Y
Animate( Input, Start_Frame, End_Frame, "BicubicResize",\
Output_W, Output_H, 0, 0.5, Start_Origin_X, Start_Origin_Y, Start_W, Start_H,\
Output_W, Output_H, 0, 0.5, End_Origin_X, End_Origin_Y, End_W, End_H )
}
Pretty crude code, doesn't have as many features as yours, but for what it is, it works.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.