moviepy.video.VideoClip.TextClip#
- class moviepy.video.VideoClip.TextClip(font, text=None, filename=None, font_size=None, size=(None, None), margin=(None, None), color='black', bg_color=None, stroke_color=None, stroke_width=0, method='label', text_align='left', horizontal_align='center', vertical_align='center', interline=4, transparent=True, duration=None)[source]#
Class for autogenerated text clips.
Creates an ImageClip originating from a script-generated text image.
- Parameters:
font – Path to the font to use. Must be an OpenType font. See
TextClip.list('font')
for the list of fonts you can use on your computer.text – A string of the text to write. Can be replaced by argument
filename
.filename – The name of a file in which there is the text to write, as a string or a path-like object. Can be provided instead of argument
text
font_size – Font size in point. Can be auto-set if method=’caption’, or if method=’label’ and size is set.
size – Size of the picture in pixels. Can be auto-set if method=’label’ and font_size is set, but mandatory if method=’caption’. the height can be None for caption if font_size is defined, it will then be auto-determined.
margin – Margin to be added arround the text as a tuple of two (symmetrical) or four (asymmetrical). Either
(horizontal, vertical)
or(left, top, right, bottom)
. By default no margin (None, None). This is especially usefull for auto-compute size to give the text some extra room.bg_color – Color of the background. Default to None for no background. Can be a RGB (or RGBA if transparent =
True
)tuple
, a color name, or an hexadecimal notation.color – Color of the text. Default to “black”. Can be a RGB (or RGBA if transparent =
True
)tuple
, a color name, or an hexadecimal notation.
- stroke_color
Color of the stroke (=contour line) of the text. If
None
, there will be no stroke.- stroke_width
Width of the stroke, in pixels. Can be a float, like 1.5.
- method
Either ‘label’ (default, the picture will be autosized so as to fit exactly the size) or ‘caption’ (the text will be drawn in a picture with fixed size provided with the
size
argument). If caption, the text will be wrapped automagically.- text_align
center | left | right. Text align similar to css. Default to
left
.- horizontal_align
center | left | right. Define horizontal align of text bloc in image. Default to
center
.- vertical_align
center | top | bottom. Define vertical align of text bloc in image. Default to
center
.- interline
Interline spacing. Default to
4
.- transparent
True
(default) if you want to take into account the transparency in the image.- duration
Duration of the clip