Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from moviepy.editor import *
- # --- functions ---
- def move(x1, y1, x2, y2, time):
- step_x = (x2 - x1) / time
- step_y = (y2 - y1) / time
- return lambda t: (x1 + t*step_x, y1 + t*step_y)
- # --- main ---
- video_size = (600,600)
- # ---
- text_clip_1 = TextClip('Hello', color='red', font='Amiri-Bold', kerning=5, fontsize=60)
- txt_width = text_clip_1.size[0]
- txt_height = text_clip_1.size[1]
- y = (600-txt_height)//2
- right_x = 600-txt_width
- time = 1.5
- move_right = text_clip_1.set_position(move(0, y, right_x, y, time), 0).set_duration(time)
- move_left = text_clip_1.set_position(move(right_x, y, 0, y, time), 0).set_duration(time).set_start(time)
- # ---
- text_clip_2 = TextClip('World', color='red', font='Amiri-Bold', kerning=5, fontsize=60)
- txt_width = text_clip_2.size[0]
- txt_height = text_clip_2.size[1]
- x = (600-txt_width)//2
- bottom_y = 600-txt_height
- time = 1.5
- move_down = text_clip_2.set_position(move(x, 0, x, bottom_y, time), 0).set_duration(time)
- move_up = text_clip_2.set_position(move(x, bottom_y, x, 0, time), 0).set_duration(time).set_start(time)
- # ---
- output_clip = CompositeVideoClip([
- move_right, move_left,
- move_down, move_up
- ], video_size)
- output_clip.fps = 24
- output_clip.write_videofile('animation.avi', fps=24, codec='mpeg4')#, ffmpeg_params=['-s', '600x600'])
- # ffmpeg -i animation.avi -s 300x300 animation.gif
Add Comment
Please, Sign In to add comment