Skip to content

Instantly share code, notes, and snippets.

@bryanjhsu
Created November 2, 2017 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bryanjhsu/de6a5b10933873aa986d3f2575dd2679 to your computer and use it in GitHub Desktop.
Save bryanjhsu/de6a5b10933873aa986d3f2575dd2679 to your computer and use it in GitHub Desktop.
import moviepy.editor as mp
from moviepy.editor import *
import random
video = mp.VideoFileClip("clip1.mp4")
video2= mp.VideoFileClip("clip2.mp4")
audioclip = AudioFileClip("tattoo.m4a").cutout(0,7)
clips = []
duration = 0.435
for i in range(0,90):
start = random.uniform(0, video.duration-1)
end = start + duration
clip1 = video.subclip(start, end)
start = random.uniform(0, video2.duration-1)
end = start + duration
clip2 = video2.subclip(start, end)
clips.append(clip1)
clips.append(clip2)
random.shuffle(clips)
composition = mp.concatenate(clips)
compositionMusic = composition.set_audio(audioclip)
compositionMusic.write_videofile("juxtapose.mp4", fps=30)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment