How to Set FFmpeg Subpixel Motion Estimation with -subq

This article explains how to use the -subq (subpixel quality) parameter in FFmpeg to control the subpixel motion estimation quality level during video encoding. You will learn what this parameter does, how its values affect both compression efficiency and encoding speed, and how to implement it in your command-line workflows for x264 and x265 encoders.

What is -subq?

The -subq option (also known as subme in raw x264/x265 library terms) controls the sub-pixel motion estimation complexity. Motion estimation allows video encoders to find matches between frames to compress video. By looking at fractions of a pixel (subpixels), the encoder can find much more accurate matches, which significantly improves compression efficiency and video quality at the cost of processing power.

Choosing the Right -subq Level

The value you pass to -subq is an integer, typically ranging from 0 to 11 for x264 (though 0 to 10 are the most commonly utilized levels). Lower numbers prioritize encoding speed, while higher numbers prioritize video quality and file size optimization.

Here is a breakdown of the standard quality levels:

FFmpeg Command Examples

To apply -subq in your FFmpeg command, insert the flag followed by your desired integer value.

High-Quality Encoding Example

To encode a video with high-quality subpixel motion estimation (level 9) using the libx264 library:

ffmpeg -i input.mp4 -c:v libx264 -subq 9 -crf 23 output.mp4

High-Speed Encoding Example

If you need to encode a video quickly (e.g., for live streaming) and can sacrifice some compression efficiency, use a lower level like 2:

ffmpeg -i input.mp4 -c:v libx264 -subq 2 -crf 23 output.mp4

Using x264-params

Alternatively, you can set this parameter directly inside the encoder-specific options using the subme key:

ffmpeg -i input.mp4 -c:v libx264 -x264-params subme=7 -crf 23 output.mp4