Package: vidpy
A Python video editor and compositor based on theMLT 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 theissue
tracker.Read the full documentation here:https://antiboredom.github.io/vidpyInstallation/DependenciesVidPy 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/WindowsInstall Shotcut(on a mac with brew:brew install--caskshotcutInstall VidPy with:pip install vidpyUbuntu/DebianInstall melt:sudoapt-getinstall meltInstall VidPy:pip install vidpySetupVidPy 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:fromvidpyimportconfigconfig.MELT_BINARY='/path/to/melt'OverviewUse theClipclass to create and manipulate video clips, and theCompositionclass to put clips together.Composition()takes a list of clips as input, and then allows you to
save an output video withsave(), or to preview withpreview().By default a composition will treat each clip as a separate track,
playing them all at the same time.fromvidpyimportClip,Compositionclip1=Clip('video.mp4')clip2=Clip('anothervideo.mp4')# play videos on top of each othercomposition=Composition([clip1,clip2])composition.save('output.mp4')You can tell clips when to start playing with theoffsetparameter,
or withset_offset()after instantiation. All time is in seconds.# start playing clip one after 1.5 secondsclip1=Clip('video.mp4',offset=1.5)clip2=Clip('anothervideo.mp4')clip2.set_offset(5)# start clip2 after 5 secondscomposition=Composition([clip1,clip2])composition.save('output.mp4')Trim clips withstartandendparameters, or with thecutmethod.# only use the first second of the clipclip1=Clip('video.mp4',start=0,end=1)clip2=Clip('anothervideo.mp4')clip2.cut(start=2,end=4)# use clip2 from 2 to 4 secondsYou can also play clips one after the other (instead of all at the same
time) by addingsingletrack=Trueas a parameter to your composition.composition=Composition([clip1,clip2],singletrack=True)composition.save('output.mp4')Compositionalso allows you to set dimensions, fps, and background
color.# create a 1280x720 composition at 30 fps with a red backgroundcomposition=Composition(clips,bgcolor="#ff0000",width=1280,height=720,fps=30)# preview itcomposition.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 compositionclip.cut(0,1)Filters & EffectsThere are a number of effects built into VidPy:clip.fadein(1)# fade the clip in over 1 secondclip.fadeout(0.5)# fade the clip over 0.5 secondsclip.glow()# add a glow effectclip.spin(2)# make the clip spin around. (Why would you do this? I don't know!)clip.chroma()# attempt to automatically remove the background colorclip.volume(0)# mute a video# set clip's positionclip.position(x=100,y=20)# resize a clipclip.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 secondsclip.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 useany filter supported by
mltwith thefxmethod. The first parameter should be the name of the filter, and
the second a dictionary of options.For example, to add acartoon
effect:# use the full filter name as the first parameter# and then a dictionary of options, based on the mlt documentationclip.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.TextUse theTextclass to add text clipsfromvidpyimportTexttext_clip=Text("A spectre is haunting Europe.",font="Comic Sans Ms",size=100,color="#ff0000")Some optional parameters for text clips are:fontany font name on your systemcolorcolor of textweightbetween 100 and 1000stylenormal or italicolcoloroutline coloroutlineoutline sizehalignhorizontal alignment (left, center, right)valignvertical alignment (top, middle, bottom)bboxa bounding box to put the text in (x, y, width, height)CreditsVidPy is bySam Lavigne, and draws heavily fromMoviePy by Zulko.