Table of Contents

Class FrameSource

Namespace
VisioForge.Core.VideoFingerPrinting
Assembly
VisioForge.Core.dll

Provides video frame extraction and processing capabilities for video fingerprinting operations.

public class FrameSource : IDisposable

Inheritance

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

Rect

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

Size

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

MediaBlocksPipeline

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

TimeSpan

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

TimeSpan

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

disposing bool

true to release both managed and unmanaged resources; false to 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

sourceSettings UniversalSourceSettings

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 true if playback started successfully; otherwise, false.

Remarks

This method constructs a media processing pipeline with the following components:

  1. Universal source for reading the video file
  2. Optional crop block if Crop property is set
  3. Optional resize block if CustomResolution property is set
  4. Sample grabber for extracting individual frames
  5. Null renderer as the pipeline sink
The pipeline begins processing immediately after successful initialization. Video frames are delivered through the VisioForge.Core.VideoFingerPrinting.FrameSource.OnVideoFrame event.

OnError

Occurs when an error happens during video processing.

public event EventHandler<ErrorsEventArgs> OnError

Event Type

EventHandler<ErrorsEventArgs>

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> OnStop

Event Type

EventHandler<StopEventArgs>

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> OnVideoFrame

Event Type

EventHandler<VideoFrameXBufferEventArgs>

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.

See Also