Skip to main content

How to find one video fragment in another

This tutorial will show you how to find one video fragment in another using the VisioForge Video Fingerprinting SDK.

The sample uses the .Net API. As an alternative, you can use the C++ API.

.Net API

Use the SDK to get fingerprints for both files and perform partial file analysis.

Analyze fragment file (short duration):

// create video file source
var fragmentSrc = new VFPFingerprintSource(ShortFile, VFSimplePlayerEngine.LAV);
fragmentSrc.StopTime = TimeSpan.FromMilliseconds(5000);

// get fingerprint
var fragment = VFPAnalyzer.GetSearchFingerprintForVideoFile(fragmentSrc, ErrorCallback);

Do the same for the second (long) file, but do not limit duration.

// create video file source
var mainSrc = new VFPFingerprintSource(LongFile, VFSimplePlayerEngine.LAV);

// get fingerprint
var main = VFPAnalyzer.GetSearchFingerprintForVideoFile(mainSrc, ErrorCallback);

We need to define the error callback function to get errors from the SDK.

Error callback code:

private static void ErrorCallback(string error)
{
Console.WriteLine(error);
}

Search one fingerprint in another

// set the maximum difference level
var maxDifference = 500;

// search one video fragment in another video using fingerprints
var res = VFPSearch.Search(fragment, 0, main, 0, out var difference, maxDifference);

// check the result
if (res > 0)
{
TimeSpan ts = new TimeSpan(res * TimeSpan.TicksPerSecond);
Console.WriteLine($"Detected fragment file at {ts:g}, difference level is {difference}");
}
else
{
Console.WriteLine("Fragment file not found.");
}

More

Visit the product page for more information, pricing details, and download links.