Skip to content

Cropdetect

Video Single output Transform

Auto-detect crop size.

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

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

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

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
limitfloat0.094117647058824065535Threshold below which the pixel is considered black
roundint160Value by which the width/height should be divisible
reset_countint00Recalculate the crop area after this many frames
skipint20Number of initial frames to skip
max_outliersint00Threshold count of outliers
modeCropdetectModeblackblack, mvedgesset mode
highfloat0.09803921568627501Set high threshold for edge detection
lowfloat0.05882352941176501Set low threshold for edge detection
mv_thresholdint80100motion vector threshold when estimating video window size

FFmpeg also names these options (use the parameter shown above): resetreset_count.


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