Class VFPAnalyzer
- Namespace
- VisioForge.Core.VideoFingerPrinting
- Assembly
- VisioForge.Core.dll
Provides high-level methods for video fingerprinting analysis, comparison, and search operations.
public static class VFPAnalyzerInheritance
Inherited Members
Remarks
The VisioForge.Core.VideoFingerPrinting.VFPAnalyzer class is the main entry point for video fingerprinting operations. It provides methods to generate fingerprints from video files, compare videos for similarity, and search for video fragments within larger videos. The class handles the complexity of video decoding, frame processing, and fingerprint generation, providing a simple API for common video fingerprinting tasks. All methods are static and support asynchronous operations.
Properties
DebugDir
Gets or sets the directory path for debug output.
public static string DebugDir { get; set; }Property Value
Remarks
When set, the analyzer may save intermediate processing results, frames, or other diagnostic information to this directory for troubleshooting purposes.
Methods
Compare(VFPFingerPrint, VFPFingerPrint, TimeSpan)
Compares two video fingerprints to determine their similarity.
public static int Compare(VFPFingerPrint fp1, VFPFingerPrint fp2, TimeSpan shift)Parameters
fp1VFPFingerPrint-
The first video fingerprint to compare.
fp2VFPFingerPrint-
The second video fingerprint to compare.
shiftTimeSpan-
Maximum time shift allowed during comparison. The comparison will test alignments within this time range to find the best match.
Returns
- int
-
A difference score where lower values indicate greater similarity. Returns MaxValue if either fingerprint is null.
Remarks
This method is used to compare fingerprints generated with VisioForge.Core.VideoFingerPrinting.VFPAnalyzer.GetComparingFingerprintForVideoFileAsync(VisioForge.Core.VideoFingerPrinting.VFPFingerprintSource,VisioForge.Core.VideoFingerPrinting.VFPErrorCallback,VisioForge.Core.VideoFingerPrinting.VFPProgressCallback). The shift parameter allows for temporal misalignment between videos, which is useful when comparing videos that may have different intros or be slightly out of sync. The comparison is performed in one-second increments.
CompareVideoFilesAsync(VFPFingerprintSource, VFPFingerprintSource, TimeSpan, VFPErrorCallback, int)
Compares two video files to determine if they contain the same content.
public static Task<bool> CompareVideoFilesAsync(VFPFingerprintSource file1, VFPFingerprintSource file2, TimeSpan shift, VFPErrorCallback errorCallback, int threshold = 500)Parameters
file1VFPFingerprintSource-
Configuration for the first video file to compare.
file2VFPFingerprintSource-
Configuration for the second video file to compare.
shiftTimeSpan-
Maximum time shift allowed during comparison. The comparison will test alignments within this time range to find the best match.
errorCallbackVFPErrorCallback-
Optional callback to receive error messages during processing.
thresholdint-
Maximum difference score to consider videos as matching. Default is 500. Lower values require closer matches.
Returns
- Task<bool>
-
A task that represents the asynchronous operation. The task result contains
trueif the videos are considered identical (difference below threshold); otherwise,false.
Remarks
This is a convenience method that combines fingerprint generation and comparison into a single operation. It generates comparison fingerprints for both videos and then compares them. This method is suitable for determining if two video files contain the same content, even if they have different encodings, resolutions, or minor edits. The threshold parameter should be adjusted based on the expected similarity and quality requirements.
GetComparingFingerprintForVideoFileAsync(VFPFingerprintSource, VFPErrorCallback, VFPProgressCallback)
Generates a fingerprint from a video file optimized for whole-video comparison operations.
public static Task<VFPFingerPrint> GetComparingFingerprintForVideoFileAsync(VFPFingerprintSource source, VFPErrorCallback errorDelegate = null, VFPProgressCallback progressDelegate = null)Parameters
sourceVFPFingerprintSource-
The video source configuration including file path, time range, and processing options.
errorDelegateVFPErrorCallback-
Optional callback to receive error messages during processing.
progressDelegateVFPProgressCallback-
Optional callback to receive progress updates (0-100) during processing.
Returns
- Task<VFPFingerPrint>
-
A task that represents the asynchronous operation. The task result contains the generated VisioForge.Core.VideoFingerPrinting.VFPFingerPrint or
nullif an error occurred.
Remarks
This method generates fingerprints optimized for comparing entire videos or large segments to determine overall similarity. It processes the complete specified time range and creates a comprehensive fingerprint. For searching short fragments within longer videos, use VisioForge.Core.VideoFingerPrinting.VFPAnalyzer.GetSearchFingerprintForVideoFileAsync(VisioForge.Core.VideoFingerPrinting.VFPFingerprintSource,VisioForge.Core.VideoFingerPrinting.VFPErrorCallback,VisioForge.Core.VideoFingerPrinting.VFPProgressCallback) instead. The method handles video decoding, frame extraction, optional transformations (cropping, resizing), and ignored area masking automatically.
GetSearchFingerprintForVideoFileAsync(VFPFingerprintSource, VFPErrorCallback, VFPProgressCallback)
Generates a fingerprint from a video file optimized for fragment search operations.
public static Task<VFPFingerPrint> GetSearchFingerprintForVideoFileAsync(VFPFingerprintSource source, VFPErrorCallback errorDelegate = null, VFPProgressCallback progressDelegate = null)Parameters
sourceVFPFingerprintSource-
The video source configuration including file path, time range, and processing options.
errorDelegateVFPErrorCallback-
Optional callback to receive error messages during processing.
progressDelegateVFPProgressCallback-
Optional callback to receive progress updates (0-100) during processing.
Returns
- Task<VFPFingerPrint>
-
A task that represents the asynchronous operation. The task result contains the generated VisioForge.Core.VideoFingerPrinting.VFPFingerPrint or
nullif an error occurred.
Remarks
This method generates fingerprints optimized for searching video fragments within larger videos. It's designed to create fingerprints of short clips (e.g., commercials, intros, or specific scenes) that can then be located within full-length videos. For comparing entire videos, use VisioForge.Core.VideoFingerPrinting.VFPAnalyzer.GetComparingFingerprintForVideoFileAsync(VisioForge.Core.VideoFingerPrinting.VFPFingerprintSource,VisioForge.Core.VideoFingerPrinting.VFPErrorCallback,VisioForge.Core.VideoFingerPrinting.VFPProgressCallback) instead. The method includes detection for processing issues like stuck frames.
Search(VFPFingerPrint, VFPFingerPrint, TimeSpan, int, bool)
Searches for occurrences of a video fragment within a larger video.
public static List<TimeSpan> Search(VFPFingerPrint fp1, VFPFingerPrint fp2, TimeSpan duration, int maxDifference, bool allowMultipleFragments)Parameters
fp1VFPFingerPrint-
The fingerprint of the video fragment to search for (needle). Should be generated using VisioForge.Core.VideoFingerPrinting.VFPAnalyzer.GetSearchFingerprintForVideoFileAsync(VisioForge.Core.VideoFingerPrinting.VFPFingerprintSource,VisioForge.Core.VideoFingerPrinting.VFPErrorCallback,VisioForge.Core.VideoFingerPrinting.VFPProgressCallback).
fp2VFPFingerPrint-
The fingerprint of the video to search within (haystack). Can be generated using either fingerprint generation method.
durationTimeSpan-
The duration of the fragment being searched for. Used to prevent overlapping matches when searching for multiple occurrences.
maxDifferenceint-
Maximum allowed difference score for a valid match. Lower values require closer matches. Typical values range from 5 to 20.
allowMultipleFragmentsbool-
If
true, searches for all occurrences of the fragment. Iffalse, returns only the first match.
Returns
- List<TimeSpan>
-
A list of timestamps where matches were found. Returns an empty list if no matches are found or if either fingerprint is null.
Remarks
This is the synchronous version of VisioForge.Core.VideoFingerPrinting.VFPAnalyzer.SearchAsync(VisioForge.Core.VideoFingerPrinting.VFPFingerPrint,VisioForge.Core.VideoFingerPrinting.VFPFingerPrint,System.TimeSpan,System.Int32,System.Boolean). The search algorithm uses a sliding window approach to find the best matches within the specified difference threshold.
SearchAsync(VFPFingerPrint, VFPFingerPrint, TimeSpan, int, bool)
Asynchronously searches for occurrences of a video fragment within a larger video.
public static Task<List<TimeSpan>> SearchAsync(VFPFingerPrint fp1, VFPFingerPrint fp2, TimeSpan duration, int maxDifference, bool allowMultipleFragments)Parameters
fp1VFPFingerPrint-
The fingerprint of the video fragment to search for (needle). Should be generated using VisioForge.Core.VideoFingerPrinting.VFPAnalyzer.GetSearchFingerprintForVideoFileAsync(VisioForge.Core.VideoFingerPrinting.VFPFingerprintSource,VisioForge.Core.VideoFingerPrinting.VFPErrorCallback,VisioForge.Core.VideoFingerPrinting.VFPProgressCallback).
fp2VFPFingerPrint-
The fingerprint of the video to search within (haystack). Can be generated using either fingerprint generation method.
durationTimeSpan-
The duration of the fragment being searched for. Used to prevent overlapping matches when searching for multiple occurrences.
maxDifferenceint-
Maximum allowed difference score for a valid match. Lower values require closer matches. Typical values range from 5 to 20.
allowMultipleFragmentsbool-
If
true, searches for all occurrences of the fragment. Iffalse, returns only the first match.
Returns
- Task<List<TimeSpan>>
-
A task that represents the asynchronous operation. The task result contains a list of timestamps where matches were found, or an empty list if no matches.
Remarks
This method is ideal for finding commercials, intros, or specific scenes within longer videos. The search is performed on a background thread to avoid blocking.
SetLicenseKey(string)
Sets license key for Video Fingerprinting SDK.
public static void SetLicenseKey(string vfpLicense)Parameters
vfpLicensestring-
Video Fingerprinting SDK license key.