python 视频转gif

2021-06-26  本文已影响0人  dairoot

在线体验

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)))
上一篇下一篇

猜你喜欢

热点阅读