Skip to main content

How do I compare two video files?

SDK allows you to compare two video files using the fingerprinting method. The fingerprinting method is based on the analysis of video frames and audio samples. The SDK calculates a unique fingerprint for each video file, which can be used to compare files.

.Net API

Get comparing fingerprints for two video files, using the DirectShow engine, for the first 5 seconds for each file.

// create source for a first video file using DirectShow engine
var source1 = new VFPFingerprintSource(File1, VFSimplePlayerEngine.LAV);
source1.StopTime = TimeSpan.FromMilliseconds(5000);

// get first fingerprint
var fp1 = VFPAnalyzer.GetComparingFingerprintForVideoFile(source1, ErrorCallback);

Do the same for the second file.

// create source for a second video file using DirectShow engine
var source2 = new VFPFingerprintSource(File2, VFSimplePlayerEngine.LAV);
source2.StopTime = TimeSpan.FromMilliseconds(5000);

// get second fingerprint
var fp2 = VFPAnalyzer.GetComparingFingerprintForVideoFile(source2, ErrorCallback);

Find the difference between files.

// compare first and second fingerprints
var res = VFPCompare.Compare(fp1, fp2, 500);

// check the result
if (res < 300)
{
Console.WriteLine("Input files are similar.");
}
else
{
Console.WriteLine("Input files are different.");
}

Also, you can save the fingerprint to a small binary file.

VFPFingerPrint fp1 = ...;
fp1.Save(filename);

You can use the fingerprint files instead of analyzing the video files each time. One minute of a video fingerprint file takes about 250 KB of disk space. Also, you can use MongoDB to store fingerprints with SDK extension usage.

More

Product page