What is the ffmpeg -subcmp parameter
This article explains the function of the -subcmp
parameter in FFmpeg, detailing how it controls sub-pixel motion
estimation comparison during video encoding. You will learn what this
parameter does, how it impacts video quality and encoding speed, and the
common values you can use in your command-line workflows.
The -subcmp parameter in FFmpeg stands for
sub-pixel comparison. It is an encoding option used to
set the comparison function (or decision metric) for sub-pixel motion
estimation during video compression.
How Motion Estimation Works
Video encoders compress video by looking for movement between frames, a process called motion estimation. Instead of saving every pixel of every frame, the encoder identifies blocks of pixels that have shifted from one frame to the next. To achieve higher precision, modern encoders perform this search at the sub-pixel level (such as half-pixel or quarter-pixel accuracy) by interpolating the space between pixels.
The Role of -subcmp
The -subcmp parameter determines the mathematical
algorithm the encoder uses to compare these sub-pixel blocks and decide
which match is the most accurate. Choosing a more precise comparison
algorithm results in better compression and higher video quality, but it
requires more CPU processing power.
Common Values and Metrics
You can assign different comparison functions to
-subcmp. The most common options include:
- sad (Sum of Absolute Differences): A fast but less precise metric that calculates the absolute differences between pixel values.
- sse (Sum of Squared Errors): A metric that squares the differences, penalizing larger discrepancies more heavily than SAD.
- satd (Sum of Absolute Hadamard Transformed Differences): A more complex metric that analyzes frequency domain differences. It is slower than SAD but yields significantly better visual quality and compression efficiency.
- dct (Discrete Cosine Transform): Compares blocks in the DCT domain. This is computationally expensive but highly accurate.
- rd (Rate-Distortion optimal): Focuses on optimizing the balance between bitrate (rate) and quality loss (distortion). This is the slowest and highest-quality option.
- zero: Disables sub-pixel comparison, offering the fastest encoding speed at the cost of video quality.
Practical Usage
To use the -subcmp parameter in an FFmpeg command, you
append it to your encoder settings. For example, to set the sub-pixel
comparison to use the Hadamard transform (satd) with an
MPEG-4 encoder, you would use the following syntax:
ffmpeg -i input.mp4 -c:v mpeg4 -subcmp satd output.mp4Adjusting this parameter allows you to fine-tune the balance between encoding speed and the final output’s visual quality based on your hardware capabilities and project requirements.