How to Use the FFmpeg Signature Filter
This article provides a quick overview and practical guide on how to
use the FFmpeg signature filter to generate and compare
video fingerprints. You will learn how to export a video’s unique
signature to a file and how to compare two different video files to
detect duplicate or highly similar content, even if they have different
resolutions, bitrates, or file formats.
The signature filter in FFmpeg is an advanced tool used
for video fingerprinting. It analyzes the visual content of a video to
create a unique identifier (signature) that can be used to detect
duplicates, copyright infringement, or tampered media.
1. Generating and Exporting a Video Signature
To generate a signature file for a video without re-encoding or
outputting a new video file, use the signature filter and
direct the output to a null muxer (-f null -).
Run the following command to export the signature in XML format:
ffmpeg -i input.mp4 -vf "signature=format=xml:filename=signature.xml" -f null -Parameter Breakdown:
format=xml: Specifies the output format of the signature file. You can choosexml(readable) orbin(binary, more compact).filename=signature.xml: Defines the path and name of the output signature file.-f null -: Tells FFmpeg to process the video but discard the final video output, as we only need the generated signature file.
2. Comparing Two Videos Directly
You can compare two video files in real-time to see if they contain matching content. This is useful for identifying if one video is a derivative, copy, or clip of another.
Run this command to compare two videos using the
filter_complex flag:
ffmpeg -i video1.mp4 -i video2.mp4 -filter_complex "[0:v][1:v]signature=detect_matching=1" -f null -Parameter Breakdown:
[0:v][1:v]: Feeds the video streams of both input files into the filter.detect_matching=1: Enables the matching algorithm. FFmpeg will scan both streams and output the matching frames, timecodes, and confidence scores directly to the console log.
3. Fine-Tuning the Matching Sensitivity
If you are getting false positives or missing matches due to compression artifacts or resolution changes, you can adjust the threshold and match relationship parameters:
ffmpeg -i video1.mp4 -i video2.mp4 -filter_complex "[0:v][1:v]signature=detect_matching=1:threshold=10000:min_lines=15" -f null -threshold: Sets the maximum distance between feature vectors to be considered a match (default is 9000). Lowering this value makes matching stricter (fewer false positives); raising it makes matching more lenient (handles highly compressed videos better).min_lines: Specifies the minimum number of matching frame sequences required to declare a match (default is 15). Increasing this prevents short, accidental scene similarities from triggering a match.