Skip to main content

Module filter

Module filter 

Source
Expand description

Video filters — per-frame transforms applied to decoded frames before per-rung scaling and encoding.

The canonical representation is a list of VideoFilter values. Two kinds:

  • Stateless filters (apply runs them directly): crop, pad, hflip, vflip, rotate, grayscale (geometry, any bit depth) + invert, brightness, contrast, saturation (colour, 8-bit).
  • Resource filters need a one-time setup before they can run per frame — overlay loads its PNG and converts it to YUV + alpha. Build a FilterChain with FilterChain::prepare (loads overlays once) and call FilterChain::apply per 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--vf style — parse_chain / [Display]: crop=1280:720,hflip,overlay=logo.png:24:24.

Geometric ops are pure sample rearrangement (run on raw bytes, any bit depth). Colour + overlay ops work on 8-bit Yuv420p (the default SDR output).

Structs§

FilterChain
A filter chain with its resources prepared (overlay PNGs loaded + converted). Build once with prepare, then apply per frame.

Enums§

VideoFilter
One video-filter step. The canonical, code-interpreted representation.

Functions§

apply
Apply one stateless filter. (Overlay errors here — use FilterChain.)
apply_chain
Apply a whole stateless chain to a frame, in order. Returns an error if the chain contains an overlay (use FilterChain for 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".