Use FFmpeg Signature Filter to Generate Visual Signatures
This article explains how to use the FFmpeg signature
filter to generate and compare unique visual signatures, also known as
video fingerprints. You will learn the exact command-line syntax
required to export these signatures to files and how to use the filter
to detect duplicate or highly similar video content across different
files.
Understanding the Signature Filter
The signature filter in FFmpeg analyzes the visual
content of a video and creates a robust fingerprint. This fingerprint is
resistant to changes in resolution, bitrate, container format, and minor
compression artifacts. It is highly useful for duplicate detection,
copyright enforcement, and automated content tracking.
Generating a Visual Signature File
To generate a signature file for a video without re-encoding or
outputting a new video file, you can run the filter and direct the
output to the null muxer (-f null -).
FFmpeg supports two output formats for signatures: binary (smaller file size) and XML (human-readable).
Binary Format (Recommended for Storage)
ffmpeg -i input.mp4 -vf "signature=format=binary:filename=signature.bin" -f null -XML Format (Recommended for Inspection)
ffmpeg -i input.mp4 -vf "signature=format=xml:filename=signature.xml" -f null -In these commands: * -vf "signature=..." defines the
video filter graph. * format specifies whether the output
file should be binary or xml. *
filename sets the path where the generated signature will
be saved. * -f null - tells FFmpeg not to write an output
video file, saving processing time.
Comparing Two Videos Directly
You can compare two video files in real-time to check if they contain
the same visual content by using FFmpeg’s complex filtergraph. To do
this, set the number of inputs (nb_inputs) to
2 and define a detection mode.
ffmpeg -i video1.mp4 -i video2.mp4 -filter_complex "[0:v][1:v]signature=nb_inputs=2:detectmode=wide" -f null -Key Parameters for Comparison:
nb_inputs=2: Instructs the filter to accept and compare two video streams.detectmode: Defines the matching algorithm.fast: Suitable for quick lookups or when the videos are nearly identical in timing.wide: Better for detecting matches where frames may have been dropped, edited, or if the speed of the videos varies slightly.
The console output will display matching statistics, including the matching frames and percentage of similarity, allowing you to programmatically or visually verify if the videos are duplicates.