from moviepy.editor import VideoFileClip
import os
zoom_ratio = 0.5 # 尺寸压缩
video_file = "1.mov"
fps = 10 # 帧率
speed = 8 # 倍速
clip = VideoFileClip(video_file)
clip = clip.resize((clip.size[0]* zoom_ratio, clip.size[1] * zoom_ratio))
clip = clip.speedx(speed)
clip.write_gif("g.gif", program='ffmpeg', fps=fps)
print("文件大小:{}M".format(round(os.path.getsize("g.gif") /1024/ 1024, 2)))
网友评论