Configure Minimum CU Size in FFmpeg libx265

To configure the minimum Coding Unit (CU) size in the libx265 encoder using FFmpeg, you must pass the min-cu-size parameter through the -x265-params flag. This article explains how to set this parameter, the available options, and how altering the minimum CU size affects your video encoding speed and quality.

In the HEVC (H.265) video compression standard, frames are partitioned into Coding Tree Units (CTUs), which are recursively split into smaller square Coding Units (CUs). By default, libx265 uses a maximum CU size of 64x64 and allows the encoder to split these blocks down to a minimum size of 8x8 to capture fine details.

The min-cu-size Parameter

You can restrict the encoder from splitting block sizes down to the smallest default size by using the min-cu-size option. The valid values for this parameter are:

FFmpeg Command Syntax

To apply this configuration in FFmpeg, pass the parameter inside the -x265-params argument.

Here is an example command that sets the minimum CU size to 16:

ffmpeg -i input.mp4 -c:v libx265 -x265-params min-cu-size=16 -c:a copy output.mp4

If you are passing multiple parameters to libx265, separate each key-value pair with a colon (:):

ffmpeg -i input.mp4 -c:v libx265 -x265-params crf=23:preset=medium:min-cu-size=16 -c:a copy output.mp4

Performance and Quality Impact

Adjusting the minimum CU size creates a direct trade-off between encoding speed and compression efficiency: