How to Adjust Adaptive Quantization Strength in FFmpeg

This guide explains how to use the -aq-strength parameter in FFmpeg to adjust adaptive quantization strength during video encoding. You will learn what adaptive quantization is, how the strength parameter affects video quality and bitrate distribution, and the exact commands needed to optimize your video encodes using the libx264 and libx265 library encoders.

What is Adaptive Quantization (AQ)?

Adaptive Quantization (AQ) is an encoding technique that redistributes bits within a single frame based on complexity. Instead of applying the same compression level to the entire image, AQ shifts bits away from high-complexity, high-motion areas (where human eyes are less likely to notice compression artifacts) and redirects them to flat, low-motion, or gradient areas (such as skies or dark walls) where banding and blocking are highly visible.

Understanding the -aq-strength Parameter

The -aq-strength flag controls how aggressively FFmpeg redistributes these bits.

Prerequisite: Setting the AQ Mode

The -aq-strength parameter only works if Adaptive Quantization is enabled via the -aq-mode option. If -aq-mode is set to 0 (disabled), changes to -aq-strength will have no effect.

Common AQ modes for libx264 and libx265 include: * 1 (Variance AQ - default) * 2 (Auto-Variance AQ) * 3 (Biased Variance AQ, optimized for dark scenes)

How to Use -aq-strength in FFmpeg Commands

To apply these settings, pass the -aq-mode and -aq-strength flags to your encoder.

Example for libx264 (H.264)

In this example, we set the AQ mode to 1 and increase the strength slightly to 1.3 to help reduce banding in a gradient-heavy video:

ffmpeg -i input.mp4 -c:v libx264 -crf 20 -aq-mode 1 -aq-strength 1.3 output.mp4

Example for libx265 (HEVC)

For the H.265/HEVC encoder, you must pass these parameters inside the -x265-params argument:

ffmpeg -i input.mp4 -c:v libx265 -crf 22 -x265-params aq-mode=1:aq-strength=1.2 output.mp4

Tips for Tuning AQ Strength