How to Set Tile Rows and Columns in Libaom?
When encoding video with the AV1 codec using libaom,
managing how a frame is split into grids—known as tiles—is crucial for
multi-threaded performance and hardware decoding efficiency. This
article explains how to explicitly specify the number of tile columns
and rows using FFmpeg command-line flags. We will cover the standard
parameters (-tile-columns and -tile-rows), how
their values are calculated exponentially, and the practical trade-offs
between encoding speed and video quality.
Understanding AV1 Tiles and Log2 Scaling
Unlike older codecs where you might specify the exact number of rows
or columns directly, libaom uses a \(log_2\) scale for its tiling arguments.
This means the value you pass to the encoder is the exponent of a power
of 2.
The mathematical relationship is defined as:
\[\text{Number of Tiles} = 2^{\text{parameter}}\]
For example, if you want a specific number of subdivisions, you must pass the corresponding exponent:
- 0: \(2^0 = 1\) tile
- 1: \(2^1 = 2\) tiles
- 2: \(2^2 = 4\) tiles
- 3: \(2^3 = 8\) tiles
- 4: \(2^4 = 16\) tiles
FFmpeg Command Syntax for Libaom Tiling
To set these configurations in FFmpeg, use the
-tile-columns and -tile-rows flags. Below is a
practical example of a complete FFmpeg command configuring a 4x2 tile
grid (4 columns and 2 rows, resulting in 8 total independent tiles):
ffmpeg -i input.mp4 -c:v libaom-av1 -crf 30 -b:v 0 -tile-columns 2 -tile-rows 1 output.mkvIn this command:
-tile-columns 2creates \(2^2 = 4\) horizontal columns.-tile-rows 1creates \(2^1 = 2\) vertical rows.
Why Tile Specifications Matter
Adjusting your tile layout directly impacts two major areas of video processing:
- Encoding and Decoding Speed: AV1 encoders can
process separate tiles concurrently. If you have a CPU with many
threads, increasing the tile count allows
libaomto better utilize your hardware, drastically reducing encoding times. - Compression Efficiency: High tile counts come with a minor penalty. Because the encoder cannot look across tile boundaries to predict motion or compress data, splitting a frame into too many tiles will slightly lower the overall visual quality per bitrate.
For standard 1080p video, a setting of
-tile-columns 2 -tile-rows 1 (a 4x2 grid) is generally
considered the sweet spot for balancing multi-threading benefits without
noticeably degrading compression efficiency. For 4K video, you can
safely scale up to -tile-columns 3 -tile-rows 2 to
accommodate the larger resolution.