Configure FFmpeg Paletteuse Dither Options
This article explains how to configure and use the different
dithering options within the FFmpeg paletteuse filter. You
will learn about the available dithering algorithms, how they impact
visual quality and file size when generating GIFs or indexed-color
videos, and the exact command-line syntax required to implement
them.
The paletteuse filter in FFmpeg applies a custom color
palette to an input video, a process essential for creating high-quality
GIFs. Dithering is used during this process to prevent color banding by
diffusing quantization errors. You can configure the dithering behavior
using the dither option inside the paletteuse
filter.
The basic syntax for applying a specific dither option is:
ffmpeg -i input.mp4 -i palette.png -filter_complex "paletteuse=dither=dither_mode" output.gifAvailable Dither Modes
FFmpeg offers several dithering algorithms, each with its own balance of visual quality, processing speed, and compression efficiency:
floyd_steinberg: This is the default dither mode. It uses error diffusion to create a smooth transition between colors, resulting in high visual quality. However, because it introduces noise, it can result in larger file sizes.bayer: This option uses ordered dithering with a crosshatch/checkerboard pattern. It is computationally fast and compresses better than Floyd-Steinberg, but the grid pattern is often highly visible.sierra2: A 2-row error diffusion algorithm. It offers high quality, similar to Floyd-Steinberg, but with slightly different distribution characteristics.sierra2_4a: A fast, simplified version of Sierra2. It is often a good compromise between quality and file size.heckbert: An error diffusion method based on Paul Heckbert’s color quantization algorithm.none: Disables dithering entirely. This results in distinct color banding but produces the smallest possible file size and cleanest flat colors.
Additional Configuration Options
Depending on your chosen dither mode, you can fine-tune the output using helper options:
Bayer Scale
(bayer_scale)
When using dither=bayer, you can control the scale (or
intensity) of the Bayer pattern using the bayer_scale
option. It accepts an integer value from 0 to
5 (default is 2). Lower values make the
pattern less noticeable but may introduce banding.
ffmpeg -i input.mp4 -i palette.png -filter_complex "paletteuse=dither=bayer:bayer_scale=3" output.gifDiff Mode (diff_mode)
To optimize file size for error diffusion dithering (like
floyd_steinberg or sierra2), you can enable
diff_mode. Setting diff_mode=rectangle zones
in on only the changed portions of the frame, preventing dither noise
from regenerating across static background areas.
ffmpeg -i input.mp4 -i palette.png -filter_complex "paletteuse=dither=floyd_steinberg:diff_mode=rectangle" output.gif