Created
November 28, 2016 03:46
-
-
Save pansapiens/0ad80a23f0e673dce8af0252dc8aba91 to your computer and use it in GitHub Desktop.
Generate a composite tiled video from multiple input videos
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
#!/usr/bin/env python | |
""" | |
Given a list of video files, creates a tiled output video with each | |
input video playing simulutaneously with mixed audio. | |
The result is something like a composite security camera feed, or the | |
"Brady Bunch" opening credits. | |
DISCLAIMER: The author holds no responsibility for your actions if you | |
become criminally insane from watching all nine Puppet Master films | |
simultaneously. You have been warned. | |
""" | |
import os | |
from moviepy.editor import * | |
from moviepy.audio.fx import * | |
W, H = (1920, 1080) | |
base_dir = "/junk/torrents/puppet master 1-9 avi dvdrip horror movie pack" | |
video_files = \ | |
["Puppet Master.avi", | |
"Puppet Master 2 - His Unholy Creations.avi", | |
"Puppet Master 3 - Toulon's Revenge.avi", | |
"Puppet Master 4 - The Demon.avi", | |
"Puppet Master 5 - The Final Chapter.avi", | |
"Puppet Master 6 - Curse of the Puppet Master- " + | |
"The Human Experiment.avi", | |
"Puppet Master 7 - Retro Puppet Master.avi", | |
"Puppet Master 8 - The Legacy.avi", | |
"Puppet Master 9 - Puppet Master vs Demonic Toys.avi", | |
] | |
#subclip = (360, 362) | |
subclip = None | |
columns = 3 | |
video_clips = [] | |
for vf in video_files: | |
#print "Adding " + vf | |
vf_fullpath = os.path.join(base_dir, vf) | |
clip = VideoFileClip(vf_fullpath) | |
if (subclip): | |
clip = clip.subclip(subclip[0], subclip[1]) | |
video_clips.append(clip) | |
rows = len(video_clips) / columns | |
print "Rows %i, Columns %i" % (rows, columns) | |
thumbnail_clips = [] | |
for r in range(rows): | |
for c in range(columns): | |
i = c + (r*columns) | |
offset = (W * float(c) / columns, H * float(r) / rows) | |
print i, c, r, offset | |
thumbnail_clips.append((video_clips[i]. | |
resize((W/rows, H/columns)). | |
set_pos(offset)) | |
) | |
""" | |
transparent_clips = [] | |
for v in video_clips: | |
transparent_clips.append( | |
v.set_opacity(1.0/len(video_clips)). | |
resize(width=W, height=H) | |
) | |
""" | |
video = CompositeVideoClip(thumbnail_clips, size=(W, H)) | |
#video = CompositeVideoClip(transparent_clips, size=(W, H)) | |
video.to_videofile("thepuppetmasters.mp4", fps=24, codec='libx264') | |
#'libvpx' | |
#'mpeg1video' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you, very helpful for me.
it seems that there is a bug^
resize((W/rows, H/columns))
For me, correct works if change to this:
resize((W/columns, H/rows))