-
-
Save BAXTER001/cf6de6929d93c1051638 to your computer and use it in GitHub Desktop.
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
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