TextClip

class moviepy.video.VideoClip.TextClip(text=None, filename=None, size=None, color='black', bg_color='transparent', font_size=None, font='Courier', stroke_color=None, stroke_width=1, method='label', kerning=None, align='center', interline=None, tempfilename=None, temptxt=None, transparent=True, remove_temp=True, print_cmd=False)[source]

Bases: moviepy.video.VideoClip.ImageClip

Class for autogenerated text clips.

Creates an ImageClip originating from a script-generated text image. Requires ImageMagick.

Parameters
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 txt

size

Size of the picture in pixels. Can be auto-set if method=’label’, but mandatory if method=’caption’. the height can be None, it will then be auto-determined.

bg_color

Color of the background. See TextClip.list('color') for a list of acceptable names.

color

Color of the text. See TextClip.list('color') for a list of acceptable names.

font

Name of the font to use. See TextClip.list('font') for the list of fonts you can use on your computer.

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 (sometimes it is buggy, not my fault, complain to the ImageMagick crew) and can be aligned or centered (see parameter align).

kerning

Changes the default spacing between letters. For instance kerning=-1 will make the letters 1 pixel nearer from ach other compared to the default spacing.

align

center | East | West | South | North . Will only work if method is set to caption

transparent

True (default) if you want to take into account the transparency in the image.

Methods

list(arg)

Returns a list of all valid entries for the font or color argument of TextClip.

search(string, arg)

Returns the of all valid entries which contain string for the argument arg of TextClip, for instance

static list(arg)[source]

Returns a list of all valid entries for the font or color argument of TextClip.

static search(string, arg)[source]

Returns the of all valid entries which contain string for the argument arg of TextClip, for instance

>>> # Find all the available fonts which contain "Courier"
>>> print(TextClip.search('Courier', 'font'))