Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
moviepy gif loop finder
#!/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)
@Zulko

This comment has been minimized.

Copy link

@Zulko Zulko commented Feb 12, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment