Examples

Stitch Videos

from vidpy import Clip, Composition

clip1 = Clip('videos/hand1.mp4')
clip2 = Clip('videos/hand2.mp4')
clip3 = Clip('videos/hand3.mp4')

clips = [clip1, clip2, clip3]


# stitch all clips together
stiched = Composition(clips, singletrack=True)
stiched.save('allvids.mp4')

# stitch the first second of all clips
for clip in clips:
    clip.cut(start=0, end=1)

stiched = Composition(clips, singletrack=True)
stiched.save('firstsecond.mp4')

Video Grid

from vidpy import Clip, Composition

video = 'videos/hand1.mp4'

canvas_width = 1280
canvas_height = 720
vid_width = canvas_width/3
vid_height = (vid_width/canvas_width) * canvas_height

x = 0
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')

Masks

from vidpy import Clip, Composition

background_clip = Clip('videos/hand1.mp4')
clip = Clip('videos/hand2.mp4')

# create a clip to use a as a mask
# you can use use a video,text clip or an image
mask = Clip('videos/mask.png')

# you can also add effects to the mask
mask.glow('0=0;200=.9')

# make sure that the duration of the mask is the same as the clip
# (or don't, if you only want the mask to affect part of the clip)
mask.set_duration(clip.duration)

# set the mask on the clip
clip.set_mask(mask)

comp = Composition([background_clip, clip])
comp.preview()

Auto Chroma Key

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')

Text

import random
from vidpy import Text, Clip, Composition

lines = '''A spectre is haunting Europe -
the spectre of communism.
All the powers of old Europe
have entered into a holy alliance
to exorcise this spectre:
Pope and Tsar,
Metternich and Guizot,
French Radicals and German police-spies.
Where is the party in opposition that
has not been decried as communistic by its opponents in power?
Where is the opposition
that has not hurled back
the branding reproach of communism,
against the more advanced opposition parties,
as well as against its reactionary adversaries?
Two things result from this fact:
I. Communism is already acknowledged
by all European powers to be itself a power.
II. It is high time that Communists should openly,
in the face of the whole world,
publish their views,
their aims,
their tendencies,
and meet this nursery tale
of the Spectre of Communism
with a manifesto of the party itself.'''.split('\n')

# some random style choices
fonts = ['Helvetica', 'Comic Sans MS', 'Andale Mono']
styles = ['normal', 'italic']
colors = ['#ff5179', '#43f8ff', '#a0ff5f', '#ffed00']

clips = []

for line in lines:
    # select random attributes
    font = random.choice(fonts)
    color = random.choice(colors)
    outline_color = random.choice(colors)
    outline_size = random.randint(3, 8)
    weight = random.randint(100, 1000)
    style = random.choice(styles)

    # put the text in a bounding box that fills 90% of the screen
    # (x, y, width, height)
    boundingbox = ('10%', '10%', '80%', '80%')

    # create a one second text clip with random parameters
    text = Text(line, end=1, color=color, font=font, style=style, weight=weight, olcolor=outline_color, outline=outline_size, size=200, bbox=boundingbox, pad=50)

    # add a glow for some reason!
    text.glow(1)

    clips.append(text)

comp = Composition(clips, singletrack=True, width=1280, height=720, fps=30)
comp.save('manifesto.mp4')

Camera

from vidpy import Composition, Camera

clip = Camera(width=1280, height=720, start=0, end=5)
clip.spin(2)
Composition([clip]).save('camera.mp4')