Remove Duplicate Frames in FFmpeg with Decimate

This article explains how to use the decimate filter in FFmpeg to identify and remove duplicate frames from video files. You will learn the basic command syntax, how the filter operates on a specific frame-cycle basis, and how to adjust parameters like threshold and cycle size to optimize your video’s frame rate and file size.

How the Decimate Filter Works

The decimate filter is designed to drop frames that are nearly identical to their adjacent frames. It operates on a fixed cycle of frames. By default, it looks at blocks of 5 frames and drops the one that is most similar to its predecessor, effectively converting 30 fps video (often telecined) down to 24 fps.

Basic Syntax

To apply the default decimate filter, use the -vf (video filter) flag followed by decimate:

ffmpeg -i input.mp4 -vf decimate output.mp4

This default command uses a cycle of 5 frames (cycle=5) and drops 1 frame per cycle, resulting in a 20% reduction in the total frame count.

Adjusting Filter Parameters

You can fine-tune the filter using specific parameters to match your video’s unique characteristics:

Example: Customizing Cycle and Threshold

If you have a video where duplicates occur less frequently, you can increase the cycle size and adjust the sensitivity:

ffmpeg -i input.mp4 -vf "decimate=cycle=10:dupthresh=2.0" output.mp4

In this command, FFmpeg examines groups of 10 frames, detects duplicates with a slightly higher tolerance (2.0), and drops the single most redundant frame from each group.

Decimate vs. Mpdecimate

It is important to choose the right tool for your specific video:

If your video has irregular duplicates, use mpdecimate instead:

ffmpeg -i input.mp4 -vf mpdecimate -vsync vfr output.mp4