Created
February 12, 2015 11:45
-
-
Save luser/0dc0f03637b6b30f4bb2 to your computer and use it in GitHub Desktop.
moviepy gif loop finder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Taken from http://zulko.github.io/blog/2015/02/01/extracting-perfectly-looping-gifs-from-videos-with-python-and-moviepy/ | |
import os | |
import sys | |
import moviepy.editor as mp | |
from moviepy.video.tools.cuts import FramesMatches | |
if len(sys.argv) != 2: | |
print "makegifs.py <video file>" | |
sys.exit(1) | |
clip = mp.VideoFileClip(sys.argv[1]) | |
name = os.path.splitext(os.path.basename(sys.argv[1]))[0] | |
scenes = FramesMatches.from_clip(clip.resize(width=120), 5, 2) | |
selected_scenes = scenes.select_scenes(2, 0.5, 4, 0.5) | |
os.mkdir(name) | |
selected_scenes.write_gifs(clip.resize(width=270), name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
some comments in the code