Just 做 IT

求知若饥 虚心若愚 안년하세요 (•‾̑⌣‾̑•)

Making GIFs From Video Files With Python

2 years ago 0

Sometimes producing a good animated GIF requires a few advanced tweaks, for which scripting can help. So I added a GIF export feature to MoviePy, a Python package originally written for video editing.
Converting a video excerpt into a GIF

In what follows we import MoviePy, we open the video file, we select the part between 1’22.65 (1 minute 22.65 seconds) and 1’23.2, reduce its size (to 30% of the original) and save it as a GIF:


from moviepy.editor import *

clip = (VideoFileClip("./frozen_trailer.mp4")
        .subclip((1,22.65),(1,23.2))
        .resize(0.3))
clip.write_gif("use_your_head.gif")

详细地址: http://zulko.github.io/blog/2014/01/23/making-animated-gifs-from-video-files-with-python/

Write a Comment