def make_hands(): clips = [] backgrounds = glob.glob('images/*.jpg') background_clip = Clip(random.choice(backgrounds)) clips.append(background_clip) hands = glob.glob('hands/*.mp4') hand = random.choice(hands) x = random.randint(-400, -200) distance = 100 duration = 0 for i in range(0, 6): clip = Clip(hand) clip.chroma() clip.fadein(0.1) clip.fadeout(0.1) clip.set_offset(i * 0.5) clip.position(x=x) clips.append(clip) x += distance duration = clip.duration + i * 0.5 composition = Composition(clips, width=1280, height=720, duration=duration) composition.preview()
import time from vidpy import Clip, Composition hands = glob.glob('hands/*.mp4') hand = random.choice(hands) print hand clips = [] x = -400 start = 0 backgrounds = ['#2cffff', '#fc282a', '#fcdb2a', '#2452d8'] for i in range(0, 6): # same as for i in [0, 1, 2, 3, 4] clip = Clip(hand) clip.chroma() clip.set_offset(start) clip.position(x=x) clip.fadein(0.2) clip.fadeout(0.2) clips.append(clip) start += 0.5 x += 150 composition = Composition(clips, bgcolor=random.choice(backgrounds)) outname = 'coolhands_{}.mp4'.format(int(time.time())) composition.save(outname)
from vidpy import Clip, Composition video = 'videos/hand1.mp4' clips = [] for i in range(0, 5): clip = Clip(video) # attempt to automatically remove background color # you can also specify a color with color='#00ff00' clip.chroma(amount=0.2) # start the clips 1/2 second after last clip clip.set_offset(i * 0.5) # change the clips x coordinate clip.position(x=(i * 100) - 300) # loop the clip 3 times clip.repeat(3) clips.append(clip) comp = Composition(clips, bgcolor='#ff4dff', duration=4) comp.save('chroma_overlay.mp4')
# add random offsets to each variable randomX = x + random.uniform(-delta, delta) randomY = y + random.uniform(-delta, delta) randomWidth = vidWidth + random.uniform(-delta, delta) randomHeight = vidHeight + random.uniform(-delta, delta) clip.position(x=randomX, y=randomY, w=randomWidth, h=randomHeight) # fade in for 0.1 second clip.fadein(0.1) # repeat the clip three times clip.repeat(3) # start the clip based on existing clips # add a random offset clip.set_offset(len(clips)*random.random()) # add clip to list of clips clips.append(clip) # increment the x and y position x += vidWidth # if x is outside of canvas if x > canvasWidth: # update y y += vidHeight # reset x x = 0 grid = Composition(clips, width=canvasWidth, height=canvasHeight)
y = 0 clips = [] while y < canvas_height: # create a clip clip = Clip(video) # set clip position clip.position(x=x, y=y, w=vid_width, h=vid_height) # fade in for 1/2 second clip.fadein(0.5) # repeat the clip three times clip.repeat(3) # start the clip based on existing clips clip.set_offset(len(clips)*.1) clips.append(clip) # increment the x and y position x += vid_width if x > canvas_width: y += vid_height x = 0 grid = Composition(clips, width=canvas_width, height=canvas_height) grid.save('grid.mp4')
# create a clip clip = Clip(video) # set clip position clip.position(x=x, y=y, w=vidWidth, h=vidHeight) # fade in for 1/2 second clip.fadein(0.5) # repeat the clip three times clip.repeat(3) # start the clip based on existing clips # add an offset of 10% clip.set_offset(len(clips) * 0.10) # add clip to list of clips clips.append(clip) # increment the x and y position x += vidWidth # if x is outside of canvas if x > canvasWidth: # update y y += vidHeight # reset x x = 0 grid = Composition(clips, width=canvasWidth, height=canvasHeight) # save to hard disk