Created
February 17, 2015 01:54
-
-
Save anonymous/2300c6def290c2ff85aa to your computer and use it in GitHub Desktop.
random cut thingy
This file contains hidden or 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) | |
parts = fn.split('/') | |
thread = parts[-2].split('_')[0] | |
tc = TextClip(thread+' '+parts[-1].split('_')[0],size=(None,30),color='black',stroke_color='white') | |
tc = tc.set_pos(('left','bottom')).set_duration(vo.duration) | |
slices.append( CompositeVideoClip( [vo, tc] )) | |
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