Transcode VP9 Video with Custom Tiles in FFmpeg
This article provides a straightforward guide on how to transcode
video to the VP9 format using FFmpeg’s libvpx-vp9 encoder
with customized multi-threading tiles. You will learn the specific
command-line arguments needed to define custom tile columns and rows,
allowing you to optimize encoding speed and playback performance for
high-resolution videos.
Understanding VP9 Tiles
VP9 introduces “tiles,” which split a video frame into a grid of
independent regions. These regions can be encoded and decoded in
parallel. By default, the libvpx-vp9 encoder may not use
tiles efficiently, which can lead to slow encoding times on multi-core
processors. Setting custom tiles allows FFmpeg to utilize more CPU
threads.
FFmpeg Command for VP9 Custom Tiles
To transcode a video using custom tiles, use the
-tile-columns and -tile-rows parameters. The
values for these parameters are represented in log2 scale (e.g., a value
of 1 means \(2^1 = 2\), a value of 2
means \(2^2 = 4\)).
Here is a standard command to transcode a video to VP9 with custom tiles:
ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:v 2M -tile-columns 2 -tile-rows 1 -frame-parallel 1 -threads 8 output.webmParameter Breakdown
-c:v libvpx-vp9: Specifies the VP9 video encoder.-b:v 2M: Sets the target video bitrate to 2 Mbps.-tile-columns 2: Creates \(2^2 = 4\) tile columns.-tile-rows 1: Creates \(2^1 = 2\) tile rows. Combined with the columns, this creates a grid of 8 tiles (\(4 \times 2\)).-frame-parallel 1: Enables parallel decoding of frames, which improves playback performance on client devices.-threads 8: Sets the number of threads FFmpeg should use. For optimal performance, the thread count should equal or exceed the total number of tiles (in this case, 8).
Recommended Tile Settings by Resolution
Tile configurations should scale with the resolution of your source video. Below are the recommended settings for common resolutions:
For 1080p (Full HD) Video
- Columns:
-tile-columns 2(4 columns) - Rows:
-tile-rows 1(2 rows) - Total Tiles: 8
- Threads:
-threads 8
For 4K (Ultra HD) Video
- Columns:
-tile-columns 3(8 columns) - Rows:
-tile-rows 2(4 rows) - Total Tiles: 32
- Threads:
-threads 16or higher (depending on CPU cores)
Using these custom tile configurations will significantly reduce encoding times while maintaining high-quality VP9 compression.