Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions autozoom.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,24 @@

arguments_strIn = './images/doublestrike.jpg'
arguments_strOut = './autozoom.mp4'
boomerang_clip = True
zoom_duration = 3.0
frame_rate = 25

for strOption, strArgument in getopt.getopt(sys.argv[1:], '', [ strParameter[2:] + '=' for strParameter in sys.argv[1::2] ])[0]:
if strOption == '--in' and strArgument != '': arguments_strIn = strArgument # path to the input image
if strOption == '--out' and strArgument != '': arguments_strOut = strArgument # path to where the output should be stored
if strOption == '--boomerang' and strArgument != '': boomerang_clip = int(strArgument) # 0 or 1 if 1 the clip will zoom in then out, if 0 it will just zoom in
if strOption == '--duration' and strArgument != '': zoom_duration = float(strArgument) # duration of the zoom of the clip in seconds
if strOption == '--fps' and strArgument != '': frame_rate = int(strArgument) # frame rate of the clip
# end

##########################################################

if __name__ == '__main__':
npyImage = cv2.imread(filename=arguments_strIn, flags=cv2.IMREAD_COLOR)

zoom_steps = int(zoom_duration * frame_rate)
intWidth = npyImage.shape[1]
intHeight = npyImage.shape[0]

Expand All @@ -88,11 +95,15 @@
})

npyResult = process_kenburns({
'fltSteps': numpy.linspace(0.0, 1.0, 75).tolist(),
'fltSteps': numpy.linspace(0.0, 1.0, zoom_steps).tolist(),
'objFrom': objFrom,
'objTo': objTo,
'boolInpaint': True
})

moviepy.editor.ImageSequenceClip(sequence=[ npyFrame[:, :, ::-1] for npyFrame in npyResult + list(reversed(npyResult))[1:] ], fps=25).write_videofile(arguments_strOut)

if boomerang_clip:
frames = [ npyFrame[:, :, ::-1] for npyFrame in npyResult + list(reversed(npyResult))[1:] ]
else:
frames = [ npyFrame[:, :, ::-1] for npyFrame in npyResult ]
moviepy.editor.ImageSequenceClip(sequence = frames, fps=frame_rate).write_videofile(arguments_strOut)
# end