Expand description
Video filters — per-frame transforms applied to decoded frames before per-rung scaling and encoding.
§Layout
The canonical representation is a list of VideoFilter values. This
mod.rs owns the cross-cutting pieces — the enum, the textual / structured
parsers, the apply dispatch, the FilterChain, and the shared plane
helpers — while each filter’s implementation lives in its own file:
[crop], [pad], [hflip], [vflip], [rotate], [grayscale],
[overlay], [invert], [brightness], [contrast], [saturation], and
the [denoise] family (one file per algorithm under denoise/).
Two kinds of filter:
- Stateless (
applyruns them directly): crop, pad, hflip, vflip, rotate, grayscale (geometry, any bit depth); invert, brightness, contrast, saturation (colour, 8-bit); anddenoise(selectable algorithm, 8-bit). - Resource filters need one-time setup —
overlayloads its PNG and converts it to YUV + alpha. Build aFilterChainwithFilterChain::prepare(loads overlays once) and callFilterChain::applyper frame.
Two interchangeable serializations (they round-trip:
parse_chain(&chain_to_string(c)) == c):
- Structured objects (serde feature) — a YAML/JSON DSL writes a chain as
a list of objects:
[{crop: {w,h}}, hflip, {overlay: {image: "logo.png"}}]. - Textual ffmpeg-
-vfstyle —parse_chain/ [Display]:crop=1280:720,hflip,overlay=logo.png:24:24.
Structs§
- Filter
Chain - A filter chain with its resources prepared (overlay PNGs loaded + converted).
Build once with
prepare, thenapplyper frame.
Enums§
- Denoise
Method - Which spatial denoise algorithm
super::VideoFilter::Denoiseruns. Each suits a different kind of noise;strengththen blends the result with the source. (Temporal denoisers — hqdn3d / NLM-temporal — need frame history and don’t fit this stateless per-frame filter; a future extension.) - Video
Filter - One video-filter step. The canonical, code-interpreted representation.
Functions§
- apply
- Apply one stateless filter, dispatching to its module. (
Overlayerrors here — useFilterChain.) - apply_
chain - Apply a whole stateless chain to a frame, in order. Returns an error if
the chain contains an
overlay(useFilterChainfor that). - chain_
to_ string - A whole chain as a comma-separated textual string (the inverse of
parse_chain). - parse_
chain - Parse an ffmpeg-
-vf-style chain, e.g."crop=1280:720,hflip".