Skip to content

Drawtext

Video Single output Transform

Draw text on top of video frames using libfreetype library.

FFmpeg filter: drawtext — the official reference.

Add it to a graph. The explicit form works for every filter — bind it to its input and read the result from outputs():

$node = $video->addFilter(new Drawtext());
$result = $node->outputs()[0];

Shorthand. Single-output filters can skip the node — apply() returns the result stream directly:

$result = $video->apply(new Drawtext());

TODO — when this filter shines: what it’s the right tool for, what to reach for instead when it isn’t, and how it composes with neighbouring filters.

TODO — prose: how the filter actually works and what its key parameters mean (the explanation FFmpeg’s terse option help omits).

TODO — runnable PHP, with the equivalent ffmpeg CLI alongside.

TODO

TODO

ParameterTypeDefaultRange / valuesDescription
fontfilestringset font file
textstringset text
textfilestringset text file
fontcolorstringblackset foreground color
fontcolor_exprstringset foreground color expression
boxcolorstringwhiteset box color
bordercolorstringblackset border color
shadowcolorstringblackset shadow color
boxboolfalseset box
boxborderwstring0set box borders width
line_spacingint0set line spacing in pixels
fontsizeint|float|stringexpressionset font size
text_alignint|string0set text alignment
xint|float|string0expressionset x expression
yint|float|string0expressionset y expression
boxwint00set box width
boxhint00set box height
shadowxint0set shadow x offset
shadowyint0set shadow y offset
borderwint0set border width
tabsizeint40set tab size
basetimeintset base time
fontstringSansFont name
expansionDrawtextExpansionnormalnone, normal, strftimeset the expansion mode
y_alignDrawtextYAligntexttext, baseline, fontset the y alignment
timecodestringset initial timecode
tc24hmaxboolfalseset 24 hours max (timecode only)
timecode_ratestringset rate (timecode only)
reloadint00reload text file at specified frame interval
alphastring1apply alpha while rendering
fix_boundsboolfalsecheck and fix text coords to avoid clipping
start_numberint00start frame number for n/frame_num variable
text_sourcestringthe source of text
text_shapingbooltrueattempt to shape text before drawing
ft_load_flagsint|string0set font loading flags for libfreetype

FFmpeg also names these options (use the parameter shown above): rtimecode_rate, ratetimecode_rate.


Maps to FFmpeg’s drawtext filter. Verified against ffmpeg n7.1.1.

An Artisan Build project.

Built on FFmpeg — an independent binding, not affiliated with or endorsed by the FFmpeg project. Support FFmpeg.