Class FrameSource
- Namespace
- VisioForge.Core.VideoFingerPrinting
- Assembly
- VisioForge.Core.dll
Provides video frame extraction and processing capabilities for video fingerprinting operations.
public class FrameSource : IDisposableInheritance
Implements
Inherited Members
Remarks
The VisioForge.Core.VideoFingerPrinting.FrameSource class creates a media processing pipeline that extracts video frames from various sources and applies optional transformations such as cropping and resizing. It uses the MediaBlocks pipeline architecture to process video streams and deliver individual frames through events. This class is designed to work with the video fingerprinting system to provide preprocessed frames for fingerprint generation.
Properties
Crop
Gets or sets the area to crop from video frames.
public Rect Crop { get; set; }Property Value
Remarks
Cropping is useful for removing black bars, watermarks, or other static elements that could interfere with fingerprint matching. The crop is applied before resizing.
CustomResolution
Gets or sets the custom resolution for video frame output.
public Size CustomResolution { get; set; }Property Value
Remarks
Resizing is performed after cropping. Smaller resolutions can improve fingerprinting performance and reduce memory usage while maintaining sufficient detail for matching.
Pipeline
Gets the media blocks pipeline used for video processing.
public MediaBlocksPipeline Pipeline { get; }Property Value
Remarks
The pipeline is created when VisioForge.Core.VideoFingerPrinting.FrameSource.PlayAsync(VisioForge.Core.Types.X.Sources.UniversalSourceSettings) is called and disposed when the FrameSource is disposed. It coordinates all media blocks in the processing chain.
StartPosition
Gets or sets the start position within the video.
public TimeSpan StartPosition { get; set; }Property Value
Remarks
Use this property to skip unwanted content at the beginning of the video, such as introductions or advertisements.
StopPosition
Gets or sets the stop position within the video.
public TimeSpan StopPosition { get; set; }Property Value
Remarks
Use this property to exclude content at the end of the video, such as credits or advertisements. Processing will stop when this position is reached.
Methods
Dispose(bool)
Releases unmanaged and - optionally - managed resources.
protected virtual void Dispose(bool disposing)Parameters
disposingbool-
trueto release both managed and unmanaged resources;falseto release only unmanaged resources.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()~FrameSource()
Finalizes an instance of the VisioForge.Core.VideoFingerPrinting.FrameSource class.
protected ~FrameSource()PlayAsync(UniversalSourceSettings)
Starts asynchronous video playback and frame extraction.
public Task<bool> PlayAsync(UniversalSourceSettings sourceSettings)Parameters
sourceSettingsUniversalSourceSettings-
The settings defining the video source, including file path and format options.
Returns
- Task<bool>
-
A task that represents the asynchronous operation. The task result contains
trueif playback started successfully; otherwise,false.
Remarks
This method constructs a media processing pipeline with the following components:
- Universal source for reading the video file
- Optional crop block if Crop property is set
- Optional resize block if CustomResolution property is set
- Sample grabber for extracting individual frames
- Null renderer as the pipeline sink
OnError
Occurs when an error happens during video processing.
public event EventHandler<ErrorsEventArgs> OnErrorEvent Type
Remarks
This event provides detailed error information including error codes and descriptions. Common errors include file access issues, codec problems, or memory allocation failures.
OnStop
Occurs when video playback is stopped.
public event EventHandler<StopEventArgs> OnStopEvent Type
Remarks
This event is raised when the pipeline stops, either due to reaching the end of the video, encountering an error, or being manually stopped. The event args indicate the reason for stopping.
OnVideoFrame
Occurs when a new video frame is available for processing.
public event EventHandler<VideoFrameXBufferEventArgs> OnVideoFrameEvent Type
Remarks
This event is raised for each video frame extracted from the source. The frame data is provided in RGB format and includes timing information. Subscribers should process frames quickly to avoid blocking the pipeline.