Skip to content

Instantly share code, notes, and snippets.

@BAXTER001
Forked from anonymous/supercut.py
Last active August 29, 2015 14:15
Show Gist options
  • Save BAXTER001/cf6de6929d93c1051638 to your computer and use it in GitHub Desktop.
Save BAXTER001/cf6de6929d93c1051638 to your computer and use it in GitHub Desktop.
import glob
import random
import datetime
from moviepy.editor import *
fl = [fn for fn in glob.glob('/path/to/the/vids/*/*')]
while 1:
slices = []
while len(slices) < 75:
try:
fn = random.choice(fl)
v = VideoFileClip(fn)
ar = v.size[0]/(v.size[1]+0.1)
if abs(ar-1.77) < 0.1:
print len(slices),fn
s = random.randint(1,int(v.duration)-1)
vo = v.subclip(s,s+0.7)
vo = vo.resize(width=500)
slices.append( vo)
except:
pass
concatenate_videoclips(slices,method='compose').write_videofile(datetime.datetime.now().strftime('%y%m%d_%H%M%S_gifcut.webm') ,bitrate='0.5M',fps=24)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment