• Stars
    star
    127
  • Rank 282,790 (Top 6 %)
  • Language
    Python
  • License
    GNU General Publi...
  • Created about 7 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

video editing and compositing with python and melt

VidPy

A Python video editor and compositor based on the MLT Multimedia Framework.

VidPy is currently in alpha - there are probably a bunch of bugs, and the api will likely change. If you're interested in testing it out, please do, and leave comments/suggestions/issues in the issue tracker.

Read the full documentation here: https://antiboredom.github.io/vidpy

Installation/Dependencies

VidPy requires melt, which can be tricky to properly install on Mac and Windows. The easiest option is to install Shotcut (an open source video editor) which comes with a prebuilt melt binary.

Mac/Windows

  1. Install Shotcut (on a mac with brew: brew install --cask shotcut
  2. Install VidPy with: pip install vidpy

Ubuntu/Debian

  1. Install melt: sudo apt-get install melt
  2. Install VidPy: pip install vidpy

Setup

VidPy will attempt to locate the melt binary, searching first for a Shotcut installation on Mac/Windows. You can also point VidPy to a specific binary like so:

from vidpy import config
config.MELT_BINARY = '/path/to/melt'

Overview

Use the Clip class to create and manipulate video clips, and the Composition class to put clips together.

Composition() takes a list of clips as input, and then allows you to save an output video with save(), or to preview with preview().

By default a composition will treat each clip as a separate track, playing them all at the same time.

from vidpy import Clip, Composition

clip1 = Clip('video.mp4')
clip2 = Clip('anothervideo.mp4')

# play videos on top of each other
composition = Composition([clip1, clip2])
composition.save('output.mp4')

You can tell clips when to start playing with the offset parameter, or with set_offset() after instantiation. All time is in seconds.

# start playing clip one after 1.5 seconds
clip1 = Clip('video.mp4', offset=1.5)

clip2 = Clip('anothervideo.mp4')
clip2.set_offset(5) # start clip2 after 5 seconds

composition = Composition([clip1, clip2])
composition.save('output.mp4')

Trim clips with start and end parameters, or with the cut method.

# only use the first second of the clip
clip1 = Clip('video.mp4', start=0, end=1)

clip2 = Clip('anothervideo.mp4')
clip2.cut(start=2, end=4) # use clip2 from 2 to 4 seconds

You can also play clips one after the other (instead of all at the same time) by adding singletrack=True as a parameter to your composition.

composition = Composition([clip1, clip2], singletrack=True)
composition.save('output.mp4')

Composition also allows you to set dimensions, fps, and background color.

# create a 1280x720 composition at 30 fps with a red background
composition = Composition(clips, bgcolor="#ff0000", width=1280, height=720, fps=30)

# preview it
composition.preview()

Finally, you can convert compositions to clips to reuse.

comp = Composition([clip1, clip2, clip3], singletrack=True)
clip = Clip(comp)

# do stuff with the entire composition
clip.cut(0, 1)

Filters & Effects

There are a number of effects built into VidPy:

clip.fadein(1)      # fade the clip in over 1 second
clip.fadeout(0.5)   # fade the clip over 0.5 seconds
clip.glow()         # add a glow effect
clip.spin(2)        # make the clip spin around. (Why would you do this? I don't know!)
clip.chroma()       # attempt to automatically remove the background color
clip.volume(0)      # mute a video

# set clip's position
clip.position(x=100, y=20)

# resize a clip
clip.position(w='50%', h='20%'')

# start the clip scaled to 200% at coordinates (0, 0)
# then move it to (200, 200) and scale it to 90% over 5 seconds
clip.zoompan([0, 0, '200%', '200%'], [200, 200, '90%', '90%'], start=0, end=5)

For a full list see the filters documentation: (link to come)

You can also use any filter supported by mlt with the fx method. The first parameter should be the name of the filter, and the second a dictionary of options.

For example, to add a cartoon effect:

# use the full filter name as the first parameter
# and then a dictionary of options, based on the mlt documentation
clip.fx('frei0r.cartoon', {'0': 0.999})

Or, play with colors:

clip.fx('avfilter.colorchannelmixer', {'av.rr': 2, 'av.br': 2})

Remember to look at the mlt docs to figure out what parameters to pass in.

Text

Use the Text class to add text clips

from vidpy import Text

text_clip = Text("A spectre is haunting Europe.", font="Comic Sans Ms", size=100, color="#ff0000")

Some optional parameters for text clips are:

font any font name on your system

color color of text

weight between 100 and 1000

style normal or italic

olcolor outline color

outline outline size

halign horizontal alignment (left, center, right)

valign vertical alignment (top, middle, bottom)

bbox a bounding box to put the text in (x, y, width, height)

Credits

VidPy is by Sam Lavigne, and draws heavily from MoviePy by Zulko.

More Repositories

1

videogrep

automatic video supercuts with python
Python
3,186
star
2

audiogrep

Creates audio supercuts.
Python
962
star
3

ffmpeg-explorer

Create and render complex ffmpeg filtergraphs in the browser.
Svelte
415
star
4

patent-generator

Transforms literary/philosophical texts into patent applications
Python
352
star
5

p5.riso

A p5js library for risograph printing by Sam Lavigne and Tega Brain.
JavaScript
299
star
6

zoom-escaper

a simple tool to help you escape zoom meetings by making your presence unbearable to others
Vue
197
star
7

camera-motion-detector

Uses opencv to detect when a camera is panning or zooming.
Python
92
star
8

sfpc-scrapism

7-week class at SFPC, Fall 2018
Python
84
star
9

scrapism-spring-2022

Python
84
star
10

p5.gif.js

let's you play gifs in p5
JavaScript
83
star
11

scrapism

a work-in-progress guide to web scraping as an artistic and critical practice
Python
78
star
12

flickr-scrape

Python
63
star
13

automating-video-itp

A 6 week class at ITP NYU
61
star
14

p5.patgrad

a p5.js library for adding gradients and repeating patterns to your sketches
JavaScript
58
star
15

prison_fax

Python
57
star
16

p5.vscode

A VS Code extension to generate new p5.js project files.
TypeScript
53
star
17

detourning-the-web

Syllabus and example code for 7-week class at NYU/ITP
Python
47
star
18

zoom-deleter

deletes zoom and prevents you from reinstalling it
Go
44
star
19

detourning-the-web-2018

Python
39
star
20

infinite-video-fall-2023

Syllabus and materials for "Infinite Video" a 10-week course at the School for Poetic Computation
Python
38
star
21

servi.js

JavaScript
36
star
22

automating-video

Two-day workshop for SFPC
30
star
23

scrapism-fall-2022

Syllabus for Scrapism @ SFPC / Fall 2022
Python
27
star
24

internet-as-form

JavaScript
27
star
25

other-orders

experiments in sorting
Python
25
star
26

sfpc-scrapism-spring-2019

Python
22
star
27

enron-email-archive

The front end for http://archive.enron.email
CSS
18
star
28

autotv

Automatically generated television (draft)
Python
18
star
29

servi-ide

JavaScript
15
star
30

slow-hot-computer

makes your computer slow, and hot, so you can be less productive.
JavaScript
15
star
31

get-well-soon

code for "Get Well Soon"
Python
13
star
32

mask-generator

Generates masks you can print out, cut and wear from images of faces.
Python
13
star
33

youtubegrep

makes supercuts from youtube searches (alpha)
Python
12
star
34

interrogating-dating-pioneer-works

11
star
35

semantic-searcher

command line semantic text search tool
Python
11
star
36

stupidhackathon

stupid shit no one needs and terrible ideas hackathon
HTML
10
star
37

LazyCoin

A new currency that stores non-value.
TeX
10
star
38

websocket-p5

JavaScript
9
star
39

AynRandom

ayn random twitter bot
Python
9
star
40

portfolio-generator

Python
9
star
41

automating-video-lang

8
star
42

webscrape_tutorial

Python
8
star
43

new-york-apartment

Python
6
star
44

processing.riso

Java
6
star
45

videogrep-gui

Python
6
star
46

noflyzone

Python
5
star
47

code-poetry-2017

5
star
48

stocktalk

Generate video/gif messages using stock footage
JavaScript
5
star
49

dynamicweb-2017

HTML
5
star
50

p5-ide

an IDE for p5.js
JavaScript
4
star
51

supercut-sonic-acts-workshop

Supercut workshop for Sonic Acts, June 2022
4
star
52

videosonnet

Processing
4
star
53

creatures

JavaScript
4
star
54

p5-gif-example

A simple example showing how to save animated gifs from p5.js sketches
JavaScript
3
star
55

piplayer

A (relatively) simple utility for setting up a raspberry pi as a video player.
Python
3
star
56

inventories-lists-catalogs

2-day workshop at Pioneer Works
3
star
57

zuckify

zuckifies things
JavaScript
3
star
58

occupied-bnb

code and resources for https://lav.io/occupied_bnb
HTML
3
star
59

popcorn-exporter

python server that creates mp4s from popcorn js compositions
Python
3
star
60

p5_tutorial

processing to p5.js examples
JavaScript
3
star
61

streeteasy-scrape

scrape streeteasy with selenium
Python
3
star
62

contract_generator

transform literary texts into legal contracts
Python
3
star
63

yt-vid-grid

JavaScript
3
star
64

yale-vid-workshop-2024

Python
3
star
65

voice_puppet

Python
3
star
66

vidquery

Python
3
star
67

smelldating

HTML
2
star
68

darkgenius

text annotation
JavaScript
2
star
69

scenegraphhh

C++
2
star
70

the-capitalist-gene

HTML
2
star
71

carbon-offset-scraper

Python
2
star
72

onhell

HTML
2
star
73

synthetic-messenger-performance

CSS
2
star
74

climate-clock

Python
2
star
75

notes-on-police-funding

Jupyter Notebook
2
star
76

greetings

Greetings Fellow Alienated Subject of Late Capitalism
HTML
2
star
77

snail-chat-4

JavaScript
2
star
78

waves

JavaScript
2
star
79

offset-archive

An archive of carbon credit schemes and sales
Jupyter Notebook
1
star
80

creative-ml-fall-2024

1
star
81

webdev-2017

CSS
1
star
82

oddjobs

HTML
1
star
83

text-masher

Python
1
star
84

ffx9subs

Python
1
star
85

case-study

A tool for the military to analyze literary and philosophical texts
JavaScript
1
star
86

baabaa

JavaScript
1
star
87

interaction1-spring2020

HTML
1
star
88

goldstein-lit

analyzes literature using the goldstein scale
JavaScript
1
star
89

internet-as-form-2020

HTML
1
star
90

scraping-text-workshop

Python
1
star
91

suspicious-camera

A camera rig with personality
Processing
1
star
92

creepy-controller

a processing sketch to control axis cameras
Processing
1
star