How to Set Triangular High-Pass Dither in FFmpeg

This article explains how to configure the audio resampling engine in FFmpeg to use the triangular high-pass dither method. You will learn the specific command-line arguments and audio filter syntax required to apply this dithering technique during bit-depth reduction, ensuring high-quality audio output with minimized audible quantization noise.

When reducing the bit depth of an audio file (for example, converting 24-bit audio to 16-bit), dithering is used to mask quantization distortion. The triangular high-pass dither method (triangular_hp) is highly favored because it shifts the dither noise to higher, less audible frequencies.

To apply this specific dither method in FFmpeg, you must use the aresample audio filter or the global swresample option.

The most robust way to set the dither method is through the aresample filter. You must also specify the target output sample format (such as signed 16-bit, s16) for the dithering to take effect.

Use the following command structure:

ffmpeg -i input.wav -af "aresample=out_sample_fmt=s16:dither_method=triangular_hp" output.wav

In this command: * -af: Defines the audio filter graph. * aresample: Invokes the resampling filter. * out_sample_fmt=s16: Sets the output format to 16-bit PCM (where dithering is required). * dither_method=triangular_hp: Explicitly sets the dither to triangular high-pass.

Method 2: Using the Global Command Option

Alternatively, you can set the dither method globally using the -dither_method flag. This is useful when you are changing the audio codec and bit depth using standard stream copy and codec parameters:

ffmpeg -i input.wav -c:a pcm_s16le -dither_method triangular_hp output.wav

In this command: * -c:a pcm_s16le: Encodes the audio to 16-bit Little Endian PCM. * -dither_method triangular_hp: Instructs the software resampler to apply triangular high-pass dithering during the conversion.

Verifying the Setup

To ensure FFmpeg is applying the setting correctly, you can increase the log level to verbose. Run the command with -loglevel verbose at the beginning:

ffmpeg -loglevel verbose -i input.wav -af "aresample=out_sample_fmt=s16:dither_method=triangular_hp" output.wav

In the terminal output, look for the [parsed_aresample_...] or [swr...] configuration block, which will explicitly state: dither_method: triangular_hp or Dither method: triangular_hp.