pub enum BlendMode {
Show 24 variants
Normal,
Multiply,
Screen,
Overlay,
SoftLight,
HardLight,
ColorDodge,
ColorBurn,
Darken,
Lighten,
Difference,
Exclusion,
Add,
Subtract,
Hue,
Saturation,
Color,
Luminosity,
PorterDuffOver,
PorterDuffUnder,
PorterDuffIn,
PorterDuffOut,
PorterDuffAtop,
PorterDuffXor,
}Expand description
Specifies how two video layers are combined during compositing.
Variants are grouped into two families:
-
Photographic blend modes (18) — operate on pixel values; both layers are typically opaque. Implemented via
FFmpeg’sblendfilter with theall_modeoption, exceptBlendMode::Normalwhich usesoverlay. -
Porter-Duff alpha compositing (6) — operate on the alpha channel; at least the top layer must carry an alpha channel (e.g.
rgbaoryuva420ppixel format).
§Implementation status
All 14 arithmetic photographic modes and all 6 Porter-Duff operations are fully implemented and covered by regression tests (issues #327–#347).
The four HSL-space modes — BlendMode::Hue, BlendMode::Saturation,
BlendMode::Color, and BlendMode::Luminosity — are accepted by the
builder but produce no output at runtime: FFmpeg’s blend filter does not
include these mode names in the bundled version. The builder returns
FilterError::BuildFailed when the filter graph
cannot be configured for these modes.
Variants§
Normal
Standard alpha-over composite (top * opacity + bottom * (1 − opacity)).
Implemented via FFmpeg’s overlay=format=auto:shortest=1.
Multiply
Multiply per-channel pixel values; darkens the result.
Maps to blend all_mode=multiply.
Screen
Inverse of multiply; lightens the result.
Maps to blend all_mode=screen.
Overlay
Combines Multiply and Screen based on base-layer luminance.
Maps to blend all_mode=overlay.
SoftLight
Gentle contrast enhancement; 50 % gray top layer is identity.
Maps to blend all_mode=softlight.
HardLight
Harsher version of Overlay; driven by the top layer’s luminance.
Maps to blend all_mode=hardlight.
ColorDodge
Brightens the base by dividing it by the inverse of the blend.
Maps to blend all_mode=dodge.
ColorBurn
Darkens the base; inverse of Color Dodge.
Maps to blend all_mode=burn.
Darken
Retains the darker of the two pixels per channel.
Maps to blend all_mode=darken.
Lighten
Retains the lighter of the two pixels per channel.
Maps to blend all_mode=lighten.
Difference
Per-channel absolute difference. Useful for alignment verification.
Maps to blend all_mode=difference.
Exclusion
Similar to Difference but with lower contrast in mid-tones.
Maps to blend all_mode=exclusion.
Add
Linear addition, clamped at maximum.
Maps to blend all_mode=addition.
Subtract
Linear subtraction, clamped at minimum.
Maps to blend all_mode=subtract.
Hue
Applies the top layer’s hue to the base’s saturation and luminance.
Maps to blend all_mode=hue.
Note: not supported by the bundled FFmpeg blend filter; graph
construction succeeds but no output frame is produced at runtime.
Saturation
Applies the top layer’s saturation to the base’s hue and luminance.
Maps to blend all_mode=saturation.
Note: not supported by the bundled FFmpeg blend filter; graph
construction succeeds but no output frame is produced at runtime.
Color
Applies the top layer’s hue + saturation to the base’s luminance.
Maps to blend all_mode=color.
Note: not supported by the bundled FFmpeg blend filter; graph
construction succeeds but no output frame is produced at runtime.
Luminosity
Applies the top layer’s luminance to the base’s hue and saturation.
Maps to blend all_mode=luminosity.
Note: not supported by the bundled FFmpeg blend filter; graph
construction succeeds but no output frame is produced at runtime.
PorterDuffOver
Top layer rendered over the bottom (standard alpha compositing).
Implemented via overlay=format=auto:shortest=1.
PorterDuffUnder
Bottom layer rendered over the top; equivalent to Over with inputs swapped.
PorterDuffIn
Top layer masked by the bottom layer’s alpha (intersection).
PorterDuffOut
Top layer visible only where the bottom layer is transparent.
PorterDuffAtop
Top layer placed atop the bottom; visible only where the bottom is opaque.
PorterDuffXor
Pixels from exactly one layer (XOR of opaque regions).