-
-
Save Zulko/c2c5c207bc64dd84085f to your computer and use it in GitHub Desktop.
Just indications on what you could do, @luser
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] | |
# Comment after first use | |
scenes = FramesMatches.from_clip(clip.resize(width=120), 5, 3) # I increase 2 to 3 to get more gifs | |
scenes.save("matches") | |
# load the scenes from a previous time to avoid recomputing them | |
scenes.load("matches") | |
""" | |
That's the hard part that you must tweak. Not that the whole method is | |
very sloppy so maybe you can just redefine/customize this function if | |
you have the time | |
The last number "0.5" says that you want at least 0.5 second between the start of each clip. | |
If you really want to avoid having multiple times the same scene with just a few different frames, | |
increase this to e.g. 1.5 | |
""" | |
selected_scenes = scenes.select_scenes(2, 0.5, 4, 0.5) | |
os.mkdir(name) # <- well done, otherwise you get a Seg Fault (this is going to be fixed) | |
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
I tried to change
Into
An error happen:
Expectation: write the scenes as video (muted is ok) instead gif.
What should I do?
Dec, 2022 update:
I managed to accomplish my objection. The customization can be found on fork by me.