View Single Post
Old 14th March 2008, 01:45   #4  |  Link
mikeytown2
Resize Abuser
 
mikeytown2's Avatar
 
Join Date: Apr 2005
Location: Seattle, WA
Posts: 623
Ken Burns Effect Part 2

Future Ideas:
  • Add a cubic option(s) to allow a circle as a path.
  • Make Negative ZoomFactor work correctly in all cases.
This is a RFC (Request For Comments) any input is greatly appreciated!

Footnotes:
Older Concept Scripts
http://forum.doom9.org/showthread.php?t=47974
http://forum.doom9.org/showthread.php?t=32884
ZoomInFramesAnimate()

Here are some images i used for testing



This function is semi similar to:

Edit:
May 27th, 2009: added bool KeepState: If using start/end Frame, it keeps the clip at the start & end zoom level. Default = true
May 10th, 2008: Completely redid the speed logic. because zoom.dll's resize function is point resize, set speed to 0.25 for high quality results. The Cubic option now works at all times, and you can select it for x only or y only if wanted (will make an arc then). The use of ZoomBox for static parts is now optional, default: it doesn't use it. Fixed a minor bug with the total frame count. (Thanks Gavino). Fixed small error in the error code, now displays the correct info. Small change to the inputs of ZoomBox. Can now only use ZoomBox(). ZoomBox's sub pixel accuracy is set with the speed option here. subpixel = 1/speed.
May 11th, 2008: Fixed a simple, but semi major bug with useZoomBox.
May 12th, 2008: Small changes that take into account ZoomBox() changes. ResizeKAR() no longer needed. Fixed some bugs. Updated Example. Fixed a color space bug. Slight Speed Increase.
May 13th, 2008: Take Crop Like Input (negative x2 or y2). If (+-1 or 0),0,0,0 then assume clip is to be centered; -1 add borders, 0 or 1 zoom in.
May 15th, 2008: Can set OutputAR. Useful for clips that use DAR.
May 23rd, 2008: Fixed Most Aspect Ratio Errors. Use of 0,0,0,0 and -1,0,0,0 work correctly now. Finding the 4th point when given 3 isn't exact.
May 24th, 2008: No AR calculation errors! (thanks Gavino). Changed some internals so input into ZoomBox works.
June 1st, 2008: Added Align, Pan(XY), zoomFactor. Split function up. Inputs are reordered!
June 6th, 2008: DisplayAR was incorrectly labeled, and is being replaced by SourceDAR and TargetDAR.
June 7th, 2008: Added startAngle and endAngle. Can only be used when useZoomBox=0. Split off the spline code into its own function. Added cubicA to do cubic style angle rotations. Changed Pan(XY) to act correctly.
June 12th, 2008: Any 3 out of 4 points can null, not just x2 or y2. Cubic option is now an int with multiple presets (0-5 currently). Set CubicX different from CubicY for fun results! Reminder that Cubic can only be used when useZoomBox=0.


ZoomBox Examples
Resize 6 different sources (example, pictures) so they all fit in a single clip.
Code:
Width=640
Height=480
Resize="BlackmanResize"
Align=-5

a=ColorBars(320,480, "YV12").Trim(0,-1).ZoomBox(Width,Height,Resize, Align=Align)
b=ColorBars(480,480, "YV12").Trim(0,-1).ZoomBox(Width,Height,Resize, Align=Align)
c=ColorBars(640,480, "YV12").Trim(0,-1).ZoomBox(Width,Height,Resize, Align=Align)
d=ColorBars(720,480, "YV12").Trim(0,-1).ZoomBox(Width,Height,Resize, Align=Align)
e=ColorBars(854,480, "YV12").Trim(0,-1).ZoomBox(Width,Height,Resize, Align=Align)
f=ColorBars(960,480, "YV12").Trim(0,-1).ZoomBox(Width,Height,Resize, Align=Align)

a+b+c+d+e+f

Convert an anamorphic (16/9) DVD to square pixels
Code:
Width=854
Height=480
Resize="Lanczos4Resize"

MPEG2Source("AnamorphicDVD.d2v")
ZoomBox(Width,Height,Resize, SourceDAR=16.0/9.0)

Convert a square pixel source to anamorphic (16/9) DVD
Code:
Width=720
Height=480

ColorBars()
ZoomBox(Width, Height, TargetDAR=16.0/9.0)
Convert a anamorphic (16/9) DVD source to (4/3) DVD
Code:
Width=720
Height=480

MPEG2Source("AnamorphicDVD.d2v")
ZoomBox(Width, Height, SourceDAR=16.0/9.0, TargetDAR=4.0/3.0)

Convert DV Cam Pixels to Square Pixels
Code:
Width=640
Height=480
Align=5

ColorBars(720,480)
ZoomBox(Width, Height, SourcePAR=10.0/11.0, Align=Align)

Resize interlaced material, keeping the interlacing after resize.
Code:
AVISource("interlaced.avi")
AssumeTFF() #set order
bob()
ZoomBox(1280,720)
separatefields()
selectevery(4,0,3)
weave()
Replace bob() with your favorite bobber for higher quality results.


KenBurnsEffect Examples
Zoom out a clip 50%, move clip around the 4 corners of the screen, then zoom back to 100%.
Code:
a = ColorBars().Trim(0,99)

KenBurnsEffect(a, startAlign=5, endAlign=5, endZoomFactor=50)
last + KenBurnsEffect(a, startZoomFactor=50, startAlign=5, endAlign=1, endZoomFactor=50)
last + KenBurnsEffect(a, startZoomFactor=50, startAlign=1, endAlign=3, endZoomFactor=50)
last + KenBurnsEffect(a, startZoomFactor=50, startAlign=3, endAlign=9, endZoomFactor=50)
last + KenBurnsEffect(a, startZoomFactor=50, startAlign=9, endAlign=7, endZoomFactor=50)
last + KenBurnsEffect(a, startZoomFactor=50, startAlign=7, endAlign=1, endZoomFactor=50)
last + KenBurnsEffect(a, startZoomFactor=50, startAlign=1, endAlign=5)

Pan a clip left to right, the right to left, then zoom out
Code:
Width=640
Height=480

a=ColorBars(2000,480).Trim(0,99)
a.KenBurnsEffect(StartAlign=4,EndAlign=6, Width=Width, Height=Height)
last+ a.KenBurnsEffect(StartAlign=6,EndAlign=4, Width=Width, Height=Height)
last+ a.KenBurnsEffect(StartAlign=4,EndAlign=-5, Width=Width, Height=Height)

KenBurnsEffect & ZoomBox AvsP Function Definitions
Go to your AvsP dir
Open up filterdb.dat with notepad
At the end of the file is a section called [USERFUNCTIONS]
Add this to the end of that section and save
Code:
KenBurnsEffect(
clip c,
int "startAlign"=-5 (-9 to 9),
float "startX1",
float "startY1",
float "startX2",
float "startY2",
float "startZoomFactor=100",
float "startPanX",
float "startPanY",
float "startAngle",
int "endAlign=-5 (-9 to 9)", 
float "endX1", 
float "endY1",
float "endX2",
float "endY2",
float "endZoomFactor=100",
float "endPanX",
float "endPanY",
float  "endAngle",
int "width",
int "height",
int "StartFrame",
int "EndFrame",
string "ResizeMethod"="BilinearResize" ("PointResize"/"BilinearResize"/"BilinearResize"/"LanczosResize"/"Lanczos4Resize"/"BlackmanResize"/"Spline16Resize"/"Spline36Resize"/"Spline64Resize"),
float "SourcePAR",
float "SourceDAR",
float "TargetPAR",
float "TargetDAR",
int "useZoomBox",
float "speed",
int "cubic",
int "cubicX",
int "cubicY",
int "cubicA",
int "cubicZ",
int "color"
)

ZoomBox(
clip c,
int "width",
int "height",
string "ResizeMethod"="BilinearResize" ("PointResize"/"BilinearResize"/"BilinearResize"/"LanczosResize"/"Lanczos4Resize"/"BlackmanResize"/"Spline16Resize"/"Spline36Resize"/"Spline64Resize"),
float "SourcePAR",
float "SourceDAR",
float "TargetPAR",
float "TargetDAR",
int "Align"=-5 (-9 to 9),
float "x1",
float "y1",
float "x2",
float "y2",
float "zoomFactor"=100,
float "panX",
float "panY", 
int "color"
)

Last edited by mikeytown2; 20th December 2009 at 20:06.
mikeytown2 is offline   Reply With Quote