Log in

View Full Version : Ken Burns Effect or panand scan


themichael
6th March 2003, 21:37
After seeing a reveiw of of one of the laptops from Apple and the video editing software included, on of the effect mentioned was the Ken Burns effect. Basically it allowed you to pan or scan across a still image. Interesting, but limited in appeal until it was included in with another effect. Put the pan behind a green screen window....

So I whipped out my copy of premiere and went looking for a similar effect, nothing. After searching the Adobe forums and several websites, I found a workaround. Had to redo everytime I wanted the effect, not good.

The I thought Avisynth! After much typing and many errors I created the Ken Burns Filter!

The filter is actually a collection of variables and funtions to scan up/down and pan left/right with the picture centered on the no moving axis. You set your duration, picture name and path, and your video size. The script then checks to see if the dimensions are OK and adds borders if they aren't.

If you use a picture the same or smaller than the video size, the picture doesn't move and may have borders added.

Sorry for the long post, no coffee today.
Here's the script:

###############################################
# #
# Pan and Scan Stills or #
# The Ken Burns Effect #
# #
###############################################




###############################################
# #
# Load Plugins #
# #
###############################################

LoadPlugin("ImageSequence.dll")


###############################################
# #
# Variables #
# #
###############################################

#Pick frame rate needed
FrmRate=30 #NTSC imagesequence doesn't like 29.97
#FrmRate=25 #PAL
#FrmRate=24 #Film
#FrmRate=24 #NTSC Film imagesequence doesn't like 23.97
#FrmRate= #Custom rate

#pan/scan time in seconds
Time=20

#video size
v_width=704 #352 352 480 704 704
v_height=480 #240 288 480 480 576

picpath=""

t_frames=FrmRate*Time


##############################################
# #
# build clip and add borders if needed #
# to keep 'crop' happy #
# #
##############################################

#using built-in variable 'last'

ImageSequence(picpath, 1, 1, FrmRate)
i_width=Width
i_height=Height
(i_width>v_width) ? last:AddBorders(round((v_width-i_width)/2+1),0,round((v_width-i_width)/2+1),0)
(i_height>v_height) ? last:AddBorders(0,round((v_height-i_height)/2+1),0,round((v_height-i_height)/2+1))

#reset image variable to new size
i_width=Width
i_height=Height

clip=loop(t_frames)


##############################################
# #
# THE FUNCTIONS #
# #
##############################################

function scanup (clip clip, int V_width, int V_height, int i_width, int i_height, int t_frames)
{
top_start=i_height-v_height
left_start=Round((i_width-v_width)/2)
top_end=0
left_end=left_start
Return Animate(clip,1,t_frames,
\ "crop",
\ left_start,top_start,v_width,v_height,
\ left_end,top_end,v_width,v_height)

}

function scandown (clip clip, int V_width, int V_height, int i_width, int i_height, int t_frames)
{
top_start=0
left_start=Round((i_width-v_width)/2)
top_end=i_height-v_height
left_end=left_start
Return Animate(clip,1,t_frames,
\ "crop",
\ left_start,top_start,v_width,v_height,
\ left_end,top_end,v_width,v_height)

}

function panright (clip clip, int V_width, int V_height, int i_width, int i_height, int t_frames)
{
top_start=Round((i_height-v_height)/2)
left_start=0
top_end=top_start
left_end=i_width-v_width
Return Animate(clip,1,t_frames,
\ "crop",
\ left_start,top_start,v_width,v_height,
\ left_end,top_end,v_width,v_height)
}

function panleft (clip clip, int V_width, int V_height, int i_width, int i_height, int t_frames)
{
top_start=Round((i_height-v_height)/2)
left_start=i_width-v_width
top_end=top_start
left_end=0
Return Animate(clip,1,t_frames,
\ "crop",
\ left_start,top_start,v_width,v_height,
\ left_end,top_end,v_width,v_height)

}



5/16/03
forgot to mention this:
the simplest way to make a video clip is to use the command 'return scanup [or scandown/panright/panleft] (clip,V_width,V_height,i_width,i_height,t_frames)'
sorry...:rolleyes:
any thoughts?

Guest
7th March 2003, 01:00
I have a Pan filter for VirtualDub at my site.

DDogg
7th March 2003, 02:17
Also, check out Canopus Imaginate. All types of complex 2d and 3d motion from stills. A great piece of software.

WarpEnterprises
7th March 2003, 13:59
:) You point us to the fact that a native pan&scan (and a zoom-in/out) filter is missing.

Cool script!

Btw, you can use AssumeFPS after ImageSequence to set the framerate. You correctly found that the FPS in IS is (incorrectly) an int.