How to Enable or Disable Dither in FFmpeg
This article explains how to control dithering when resampling audio or changing bit depth using FFmpeg. You will learn the specific command-line options and audio filter parameters required to toggle dithering on or off, helping you manage quantization noise and maintain control over your audio output quality.
Understanding Dithering in FFmpeg
When downsampling audio (for example, converting from 24-bit to 16-bit), quantization error can introduce unwanted distortion. Dithering adds a small amount of randomized noise to mask this distortion.
FFmpeg handles audio resampling via the swresample
library. To control whether dithering is applied, you can manipulate two
main settings: the dither scale and the dither
method.
How to Disable Dithering
The most reliable way to completely disable dithering in FFmpeg is to
set the dither scale to 0.
Using Global Command Options
You can apply this globally during a conversion by using the
-dither_scale flag:
ffmpeg -i input.wav -c:a pcm_s16le -ar 44100 -dither_scale 0 output.wavUsing the Audio Filtergraph
If you are using the audio resampler filter (aresample),
you can pass the dither_scale option directly into the
filterchain:
ffmpeg -i input.wav -af "aresample=dither_scale=0" -c:a pcm_s16le output.wavHow to Enable and Configure Dithering
If you want to ensure dithering is active, you must set the
dither_scale to 1 (or your preferred
intensity) and choose a dither_method.
Available Dither Methods
FFmpeg supports several dithering algorithms: *
rectangular * triangular *
triangular_hp (High-pass triangular) *
lipshitz * shibata * f_weighted *
modified_e_weighted * improved_e_weighted
Using Global Command Options
To enable dithering with a specific method (for example,
triangular):
ffmpeg -i input.wav -c:a pcm_s16le -dither_method triangular -dither_scale 1 output.wavUsing the Audio Filtergraph
To achieve the same result using the aresample
filter:
ffmpeg -i input.wav -af "aresample=dither_method=triangular:dither_scale=1" -c:a pcm_s16le output.wav