FFmpeg Decimate Filter Custom Frame Match Guide

This article explains how to use the decimate filter in FFmpeg to remove duplicate frames using custom frame match options. You will learn the core parameters of the decimate filter, how to configure block matching and difference thresholds, and see practical command-line examples to optimize your video frame rate reduction.

The decimate filter in FFmpeg is primarily used to drop duplicate frames from a video stream, a process common in inverse telecine (IVTC) workflows or when compressing screen recordings. By default, the filter looks at a cycle of 5 frames and drops the longest-running duplicate. However, you can customize this behavior using specific matching parameters to handle complex video sources.

Core Parameters for Custom Matching

To fine-tune how FFmpeg identifies duplicate frames, you can adjust the following key options:

Practical Command Examples

1. Basic Decimation with Custom Cycle

If you have a video where 2 frames are duplicated in every 10-frame sequence, you can set a custom cycle:

ffmpeg -i input.mp4 -vf "decimate=cycle=10:drop_count=2" output.mp4

2. Strict Duplicate Matching for High-Quality Video

If your video has subtle noise that prevents FFmpeg from detecting duplicates, you can lower the sensitivity by adjusting the hi, lo, and frac values. This forces the filter to tolerate minor differences:

ffmpeg -i input.mp4 -vf "decimate=hi=1024:lo=512:frac=0.10" output.mp4

In this command: * hi=1024 and lo=512 increase the pixel difference thresholds, meaning small variations (like compression artifacts or noise) are ignored. * frac=0.10 means only 10% of the image blocks need to change for FFmpeg to classify the frame as a new, unique frame.

3. Loose Matching for Static Content

For slideshows, presentations, or software tutorials where frames remain static for long periods, you can make the matching much looser to ensure heavy duplication is aggressively removed:

ffmpeg -i input.mp4 -vf "decimate=cycle=25:drop_count=20:frac=0.05" output.mp4

This configuration analyzes larger cycles of 25 frames, dropping up to 20 duplicates per cycle, while requiring only a 5% block change to declare a frame unique.