How to Use the FFmpeg Decimate Filter
This article explains how to use the decimate filter in
FFmpeg to remove duplicate frames from your video files. You will learn
the basic syntax of the filter, its primary use cases—such as inverse
telecine (IVTC) and cleaning up screen recordings—and how to customize
its parameters like cycle size and duplicate thresholds for optimal
results.
What is the Decimate Filter?
The decimate filter in FFmpeg is a video filter designed
to drop frames that are duplicates of preceding frames. It looks at a
specific group of consecutive frames (a “cycle”), identifies the most
redundant frame based on pixel difference thresholds, and removes
it.
This filter is commonly used in: * Inverse Telecine (IVTC): Reverting 30fps (NTSC) telecined video back to its original 24fps film rate by dropping one duplicate frame out of every five. * Screen Recordings: Removing identical frames generated when the screen is static, helping to compress file size. * Stop-Motion or Animation: Cleaning up accidental duplicate captures.
Basic Syntax
To apply the default decimate filter, use the
-vf decimate option in your FFmpeg command:
ffmpeg -i input.mp4 -vf decimate output.mp4By default, the filter operates on a cycle of 5 frames. It will analyze every 5 frames, find the single frame that is most similar to its predecessor, and drop it if it meets the similarity threshold. This effectively reduces a 29.97 fps video to 23.976 fps.
Key Parameters of the Decimate Filter
You can fine-tune how the filter detects and drops duplicates by
passing specific parameters in a key-value format:
decimate=parameter1=value1:parameter2=value2.
1. cycle
The cycle parameter set the frame bin size. FFmpeg will
drop exactly one frame from this number of frames. *
Default: 5 * Example:
decimate=cycle=10 (drops 1 frame out of every 10)
2. dupthresh
This sets the threshold for duplicate detection. If the difference
between two frames is below this value, they are considered duplicates.
* Default: 1.1 * Usage:
Increase this value if FFmpeg is failing to detect duplicates due to
compression noise. Decrease it if it is dropping unique, low-motion
frames. * Example:
decimate=dupthresh=2.0
3. scthresh
The scene change threshold. This prevents the filter from dropping
frames across a sudden scene cut, even if the algorithm thinks they are
similar. * Default: 15.0 *
Example: decimate=scthresh=10.0
4. blockx and blocky
These define the size of the macroblocks used for comparing frames. *
Default: 32 (32x32 pixels) *
Usage: Smaller blocks increase comparison precision but
require more CPU processing power.
Practical Examples
Standard Inverse Telecine (IVTC)
When converting telecined 30fps video back to 24fps,
decimate is usually paired with the fieldmatch
filter to reconstruct the original progressive frames first:
ffmpeg -i input_telecine.mp4 -vf fieldmatch,decimate output_progressive.mp4Removing Heavy Duplicates with Custom Thresholds
If your video has digital noise that prevents FFmpeg from recognizing
duplicates, you can raise the duplicate threshold
(dupthresh):
ffmpeg -i input.mp4 -vf decimate=cycle=5:dupthresh=2.5 output.mp4Custom Frame Rate Reductions
If you want to drop one duplicate frame out of every 10 frames instead of the standard 5, adjust the cycle parameter:
ffmpeg -i input.mp4 -vf decimate=cycle=10 output.mp4