Documentation¶
Clip¶
-
class
vidpy.
Clip
(resource=None, service=None, start=0, end=None, offset=0, **kwargs)[source]¶ A VidPy clip
Parameters: - resource (str) – Path to a video file, audio file, image, or melt xml document
- service (str) – Optional melt service
- start (float) – The in-point of the clip in seconds (optional). Setting this will trim from the start of the clip
- end (float) – The out-point of the clip in seconds (optional). Setting this will trim from the end of the clip
- offset (float) – Time in seconds before the clip is played.
- **kwargs – Option parameters that will get sent to melt
-
alpha_op
(operation='shave', thresh=0.5, amount=0.333344, invert=False, display='image', input_as_alpha=0)[source]¶ Display and manipulate the alpha channel
Parameters: - display – Display: what to display. Choices are image, alpha_as_gray, gray+red, black, gray, white and checkers.
- input_as_alpha – use input alpha for the display function above.
- operation (str) – select the operation to be done on the alpha channel. Options are: shave, shrink_hard, shrink_soft, grow_hard, grow_soft, thresh
- thresh (float) – threshold (only used if you’ve selected the thresh operation)
- amount (float) – grow/shrink amount
- invert (bool) – invert the alpha channel
-
blink
(interval)[source]¶ Blinks the clip at an interval
Parameters: interval (float) – time in seconds for on/off cycle
-
brightness
(brightness=0.5)[source]¶ Adjusts the brightness of the clip
Parameters: brightness (float) – brightness between 0.0 and 1.0
-
cartoon
(triplevel=0.99, diffspace=0.003)[source]¶ Cartoonify video, with a form of edge detectection
Parameters:
-
chroma
(amount=0.15, color=None, blend=None)[source]¶ Removes a color from the clip, making it transparent
Parameters:
-
contrast
(amount=0.5)[source]¶ Adjusts the contrast of the clip
Parameters: contrast (float) – The amount of contrast (between 0 and 1)
-
dither
(amount=0.104167)[source]¶ Dithers the clip and reduces the number of available colors
Parameters: amount (float) – Number of values per channel
-
duration
¶ Duration of the clip
-
extract_color
(color='r')[source]¶ Extracts either red, green, or blue from clip
Parameters: color (str) – Either ‘r’, ‘g’ or ‘b’
-
fadein
(duration)[source]¶ Fades the clip in
Parameters: duration (float) – Time to fade in, in seconds
-
fadeout
(duration)[source]¶ Fades the clip out
Parameters: duration (float) – Time to fade out, in seconds
-
flip
(axis)[source]¶ Flip the clip over an axis
Parameters: axis (str) – The axis to flip over, either “horizontal” or “vertical”
-
fx
(name, params=None)[source]¶ Adds any melt filter to a clip
For a full list, see: https://www.mltframework.org/plugins/PluginsFilters/
Parameters:
-
gradient
(start_color='#ffffff', end_color='#000000', pattern='linear', start_opacity=0.5, end_opacity=0.5, start_x=0.5, start_y=0, end_x=0.5, end_y=1, offset=0, blend='normal')[source]¶ Draws a gradient on top of the clip.
Parameters: - start_color (str) – First color of the gradient
- end_color (str) – Second color of the gradient
- pattern (str) – “linear” or “radial” gradient
- start_opacity (float) – Opacity of the first color of the gradient
- end_opacity (float) – Opacity of the second color of the gradient
- start_x (float) – X position of the start point of the gradient
- start_y (float) – Y position of the start point of the gradient
- end_x (float) – X position of the end point of the gradient
- end_y (float) – Y position of the end point of the gradient
- offset – Position of first color in the line connecting gradient ends, really useful only for radial gradient
- blend (str) – Blend mode. Values can be: ‘normal’, ‘add’, ‘saturate’, ‘multiply’, ‘screen’, ‘overlay’, ‘darken’, ‘lighten’, ‘colordodge’, ‘colorburn’, ‘hardlight’, ‘softlight’, ‘difference’, ‘exclusion’, ‘hslhue’, ‘hslsaturation’, ‘hslcolor’, or ‘hslluminosity’
-
height
¶ Height of the original clip
-
hue
(shift=0)[source]¶ Adjusts the hue of the clip
Parameters: shift (float) – The amount to shift the hue by (between 0 and 1)
-
mirror
(axis='horizontal', reverse=False)[source]¶ Provides various mirror and image reversing effects.
Parameters:
-
move
(sequence, repeat=False, cycle=0, mirror=False)[source]¶ Moves the clip around.
Takes a list of (keyframe, x, y, w, h) params At each target frame, the clip will be moved and optionally resized to the supplied x,y,w,h params.
You can use pixels or percentages (in quotes)
Parameters: sequence (list) – a sequence of (keyframe, x, w, w, h) params
-
opacity
(amount)[source]¶ Sets the clip’s opacity
Parameters: amount (float) – Opacity, between 0.0 and 1.0
-
original_duration
¶ Duration of the original clip
-
original_fps
¶ FPS of the original clip
-
position
(x=0, y=0, w='100%', h='100%', distort=True)[source]¶ Positions and resizes the clip. Coordinates can be either in pixels or percent.
To maintain aspect ration, set distort=False
Parameters: - x – optional x coordinate
- y – optional y coordinate
- w – optional width
- h – optional height
- distort (bool) – Option to distort the image or maintain its ratio
-
posterize
(levels=0.1)[source]¶ Posterizes the clip by reducing the number of colors used.
Parameters: levels (float) – Number of values per channel
-
resize
(w='100%', h='100%', distort=True)[source]¶ Resizes the clip. Coordinates can be either in pixels or percent.
To maintain aspect ration, set distort=False
Parameters: - w – optional width
- h – optional height
- distort (bool) – Option to distort the image or maintain its ratio
-
saturate
(saturation=0.125)[source]¶ Adjusts the saturation of the clip
Parameters: saturation (float) – Saturation amount (0 to 1)
-
save
(filename, **kwargs)[source]¶ Saves the clip as a video file
Parameters: - filename (str) – The file to save to.
- kwargs – Pass in any arguments that you would to Composition (width, height, fps, bgcolor)
-
set_duration
(duration)[source]¶ Sets the duration of the clip
Parameters: duration (float) – Duration of the clip in seconds
-
set_mask
(clip)[source]¶ Sets the mask for the clip based on the luma values of a video, image, or vidpy Clip
Parameters: clip (Clip or path) – any vidpy clip, or path to video or image
-
set_offset
(offset)[source]¶ Sets the offset of the clip - determines when the clip will start playing.
Parameters: offset (float) – Offset of the clip in seconds
-
sharpness
(amount=0.3, size=0)[source]¶ Sharpens the clips https://www.mltframework.org/plugins/FilterFrei0r-sharpness/
Parameters:
-
softglow
(blur=0.5, brightness=0.75, sharpness=0.85, blurblend=0)[source]¶ Does softglow effect on highlights
Parameters:
-
speed
(speed)[source]¶ Sets the playback speed of the clip.
The speed can be any number between 20 and 0.01. Negative values will play video in reverse.
Parameters: speed (float) – playback speed
-
text
(text, color='#ffffff', bgcolor='0x00000000', olcolor='0x00000000', outline=0, halign='center', valign='middle', pad=0, font='Sans', size=1080, style='normal', weight=400, bbox=(0, 0, '100%', '100%'))[source]¶ Overlays text on a clip.
Parameters: - text (str) – The text
- font (str) – The font family to use
- color (str) – Text foreground color
- bgcolor (str) – Optional background color
- olcolor (str) – Text outline color
- outline (int) – Outline size
- style (str) – Font style, can be “normal” or “italic”
- weight (int) – The weight of the text (boldness). Can be between 100 and 1000
- bbox (list) – A bounding box for text to appear in. By default is (0, 0, ‘100%’, ‘100%’
- halign (str) – Horizontal aligment of text. Can be “center” (default), “left” or “right”
- valign (str) – Vertical aligment of text. Can be “middle” (default), “top” or “bottom”
-
threshold
(threshold=0.5)[source]¶ Thresholds the clip
Parameters: threshold (float) – Threshold value (0 to 1)
-
total_frames
¶ Total frames in the original clip
-
transition
(name, params=None)[source]¶ Adds any melt transition to a track
For a full list, see: https://www.mltframework.org/plugins/PluginsTransitions/
Parameters:
-
volume
(amt)[source]¶ Sets the volume for the clip, from 0 (mute) to 1 (full volume)
Parameters: amt (float) – Volume between 0 and 1
-
width
¶ Width of the original clip
Text¶
-
class
vidpy.
Text
(text, start=0, end=None, offset=0, color='#ffffff', bgcolor='0x00000000', olcolor='0x00000000', outline=0, halign='center', valign='middle', pad=0, font='Sans', size=1080, style='normal', weight=400, bbox=(0, 0, '100%', '100%'), **kwargs)[source]¶ Subclass of Clip that allows you to write text in your composition
Parameters: - text (str) – The text
- font (str) – The font family to use
- color (str) – Text foreground color
- bgcolor (str) – Optional background color
- olcolor (str) – Text outline color
- outline (int) – Outline size
- style (str) – Font style, can be “normal” or “italic”
- weight (int) – The weight of the text (boldness). Can be between 100 and 1000
- bbox (list) – A bounding box for text to appear in. By default is (0, 0, ‘100%’, ‘100%’
- halign (str) – Horizontal aligment of text. Can be “center” (default), “left” or “right”
- valign (str) – Vertical aligment of text. Can be “middle” (default), “top” or “bottom”
Color¶
Camera¶
Composition¶
-
class
vidpy.
Composition
(clips, bgcolor='#000000', singletrack=False, duration=None, fps=None, width=None, height=None)[source]¶ A composition made of a list of clips.
Parameters: - clips (list) – A list of Clip objects
- bgcolor (str) – The background color of the composition, in hex
- singletrack (bool) – Boolean that determines if clips play all at once (default) or sequentially
- duration (float) – Duration of the composition in seconds.
- fps (int) – Frames per second of output
- width (int) – Width of output in pixels
- height (int) – Height of output in pixels
-
args
()[source]¶ Generate mlt command line arguments
Returns: mlt command line arguments Return type: str
-
save
(filename, **kwargs)[source]¶ Save the composition as a video file.
Parameters: - filename (str) – the file to save to (any video type is accepted)
- **kwargs – additional parameters to pass to ffmpeg
Returns: the path to the saved file
Return type: filename (str)