FFmpeg 5.1.6
Since* 2.6
#

Use a palette to downsample an input video stream.

The filter takes two inputs: one video stream and a palette. The palette must be a 256 pixels image.

It accepts the following options:

dither

Select dithering mode. Available algorithms are:

bayer

Ordered 8x8 bayer dithering (deterministic)

heckbert

Dithering as defined by Paul Heckbert in 1982 (simple error diffusion). Note: this dithering is sometimes considered "wrong" and is included as a reference.

floyd_steinberg

Floyd and Steingberg dithering (error diffusion)

sierra2

Frankie Sierra dithering v2 (error diffusion)

sierra2_4a

Frankie Sierra dithering v2 "Lite" (error diffusion)

Default is sierra2_4a.

bayer_scale

When bayer dithering is selected, this option defines the scale of the pattern (how much the crosshatch pattern is visible). A low value means more visible pattern for less banding, and higher value means less visible pattern at the cost of more banding.

The option must be an integer value in the range [0,5]. Default is 2.

diff_mode

If set, define the zone to process

rectangle

Only the changing rectangle will be reprocessed. This is similar to GIF cropping/offsetting compression mechanism. This option can be useful for speed if only a part of the image is changing, and has use cases such as limiting the scope of the error diffusal dither to the rectangle that bounds the moving scene (it leads to more deterministic output if the scene doesn’t change much, and as a result less moving noise and better GIF compression).

Default is none.

new

Take new palette for each output frame.

alpha_threshold

Sets the alpha threshold for transparency. Alpha values above this threshold will be treated as completely opaque, and values below this threshold will be treated as completely transparent.

The option must be an integer value in the range [0,255]. Default is 128.

use_alpha

Apply the palette by taking alpha values into account. Only useful with palettes that are containing multiple colors with alpha components. Setting this will automatically disable ’alpha_treshold’.

#

Examples

  • Use a palette (generated for example with palettegen) to encode a GIF using ffmpeg:

    ffmpeg -i input.mkv -i palette.png -lavfi paletteuse output.gif