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.gif

Available Dither Modes

FFmpeg offers several dithering algorithms, each with its own balance of visual quality, processing speed, and compression efficiency:

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.gif

Diff 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