Configure libvpx-vp9 row-mt Parameter in FFmpeg

This article provides a straightforward guide on how to configure the row-mt (row-based multi-threading) parameter when encoding video with the libvpx-vp9 codec in FFmpeg. You will learn what row-mt is, how to enable it in your command-line interface, and how it significantly speeds up VP9 encoding times by optimizing multi-core CPU usage.

What is row-mt?

Row-based multi-threading (row-mt) is a feature in the libvpx VP9 encoder that allows the encoder to process multiple rows of video blocks simultaneously. By default, VP9 encoding can be incredibly slow because standard tile-based threading has limitations on how well it can distribute work across modern CPUs with high core counts. Enabling row-mt drastically improves thread utilization, resulting in much faster encoding speeds with virtually no loss in visual quality.

How to Enable row-mt in FFmpeg

To use row-based multi-threading, you need to pass the -row-mt 1 option to your FFmpeg command. For this parameter to work effectively, you must also define the number of threads FFmpeg is allowed to use via the -threads parameter.

Basic FFmpeg Command Syntax

ffmpeg -i input.mp4 -c:v libvpx-vp9 -row-mt 1 -threads 8 output.webm

Parameter Breakdown

  • -c:v libvpx-vp9: Specifies the VP9 encoder.
  • -row-mt 1: Enables row-based multi-threading (set to 0 to disable).
  • -threads 8: Tells the encoder to use 8 CPU threads. You should adjust this number to match the capabilities of your processor.

When encoding with VP9, it is common to use two-pass encoding for the best quality and file size ratio. Below is an example of a high-quality, speed-optimized 1-pass CRF (Constant Rate Factor) encode using row-mt.

ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 30 -b:v 0 -row-mt 1 -threads 12 -speed 2 output.webm

In this command:

  • -crf 30 -b:v 0 enables constant quality mode.
  • -threads 12 allocates 12 threads to the process.
  • -speed 2 balances encoding speed and quality. Combined with -row-mt 1, this significantly reduces encoding time on multi-core systems.

Requirements

To use the -row-mt parameter, ensure that:

  1. Your FFmpeg installation is compiled with libvpx support.
  2. The underlying libvpx library version is 1.7.0 or higher (which is standard in almost all modern FFmpeg builds).