Skip to content

Drawbox

Video Single output Transform

Draw a colored box on the input video.

FFmpeg filter: drawbox — 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 Drawbox(…));
$result = $node->outputs()[0];

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

$result = $video->apply(new Drawbox(…));

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
xint|float|string0expressionset horizontal position of the left box edge
yint|float|string0expressionset vertical position of the top box edge
widthint|float|string0expressionset width of the box
heightint|float|string0expressionset height of the box
colorstringblack—set color of the box
thicknessstring3—set the box thickness
replaceboolfalse—replace color & alpha
box_sourcestring——use datas from bounding box in side data

FFmpeg also names these options (use the parameter shown above): w → width, h → height, c → color, t → thickness.


Maps to FFmpeg’s drawbox 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.