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. |
1st August 2003, 22:00 | #3 | Link |
Theora and Mkv fan! :)
Join Date: Jun 2002
Location: Sydney
Posts: 347
|
yes i would be interested to see flters like these.
not demanding anything though; we are busy ppl.
__________________
Can't we all just get along? Opty 146 @ 2.5Ghz || nForce3 ||1x330 + 3x120gig || CX23881 Capture Card OCAU || My blog Proud to be an Aussie! |
2nd August 2003, 04:39 | #4 | Link |
AviSynth Enthusiast
Join Date: Jul 2002
Location: California, U.S.
Posts: 1,267
|
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. Code:
# 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))) } Last edited by stickboy; 2nd August 2003 at 04:42. |
3rd August 2003, 07:52 | #5 | Link |
developer wannabe
Join Date: Nov 2001
Location: Brooklyn, NY
Posts: 1,211
|
Stickboy, would you mind adding your functions to the Wiki? http://www.avisynth.org/index.php?page=ShareFunctions
|
10th August 2003, 04:30 | #7 | Link |
Registered User
Join Date: Aug 2003
Posts: 6
|
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^2003 A+ |
10th August 2003, 07:59 | #8 | Link |
Registered User
Join Date: Aug 2003
Posts: 6
|
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 )
Code:
#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 )) }
__________________
DataCable^2003 A+ |
10th August 2003, 08:08 | #9 | Link |
Theora and Mkv fan! :)
Join Date: Jun 2002
Location: Sydney
Posts: 347
|
definately share your ideas when you finalise them.
Sounds like it has loads of potential.
__________________
Can't we all just get along? Opty 146 @ 2.5Ghz || nForce3 ||1x330 + 3x120gig || CX23881 Capture Card OCAU || My blog Proud to be an Aussie! |
10th August 2003, 23:46 | #11 | Link |
Registered User
Join Date: Aug 2003
Posts: 6
|
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):
Code:
# 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 ) }
__________________
DataCable^2003 A+ |
Thread Tools | Search this Thread |
Display Modes | |
|
|