Filters
A first-class filter graph API: every FFmpeg filter as a typed PHP class, with one
documentation page each — parameters, runnable PHP, the equivalent ffmpeg CLI, gotchas, and a
live in-browser playground.
How a filter attaches
Section titled “How a filter attaches”A filter transforms a stream and returns a new one. The whole catalog is reachable as Filter
classes, and the friendly methods and apply() are sugar over one canonical path: a
FilterNode binds a filter to its input streams, and you read its results with outputs().
$clip->scale(1280, 720); // friendly method — sugar$clip->apply(new \FFmpeg\Filter\Vignette()); // any filter, by its 1:1 class — also sugarConcretely, $clip->apply($f, ...$extra) is exactly $clip->addFilter($f, $extra)->outputs()[0]:
build the node, return its sole output. Nothing has privileged access — the convenience layer
goes through the same door you can use directly.
Parameters can be a number, an FFmpeg expression string, or a PHP closure run per frame — and a bad expression is caught the instant you construct the filter. See the Architecture for the model behind all of it.
One output, or many
Section titled “One output, or many”A Filter is just configuration; the wiring is a separate, immutable FilterNode that binds the
input streams (input 0 first, more for multi-input filters) and exposes the results by pad.
Most filters have a single output, so apply() hides the node and returns that one output —
taking extra inputs positionally for multi-input filters like overlay:
$bg->apply(new Overlay(x: 10, y: 10), $logo); // 2 inputs → 1 outputA filter with several outputs — split — is built as a node, stream-first with addFilter()
or directly with new FilterNode(...), and you read its outputs by pad index. Each output is a
normal stream, so you can process the branches independently and recombine them:
[$a, $b] = array_values($clip->addFilter(new Split(2))->outputs()); // [0 => …, 1 => …]$thumb = $b->apply(new Scale(160, 120));$result = $a->apply(new Overlay(x: 10, y: 10), $thumb); // recombine the branchesapply() accepts only single-output filters, so $clip->apply(new Split(2)) is a type error —
and if one slips past the types, the exception says so plainly: “Split has multiple outputs —
build it with addFilter() and read outputs(), not apply().”
Browse by kind
Section titled “Browse by kind”- Sources — synthesize a stream from nothing (color, bars, tones, silence)
- Audio — transform an audio stream (loudness, mixing, dynamics, fades)
- Video — transform a video stream (scale, crop, overlay, text)
Every filter page follows one strict template — parameter table, examples, gotchas, FFmpeg provenance — so the catalog stays consistent across hundreds of filters.
An Artisan Build project.
Built on FFmpeg — an independent binding, not affiliated with or endorsed by the FFmpeg project. Support FFmpeg.