Class VideoSampleGrabberBlock
- Assembly
- VisioForge.Core.dll
Video sample grabber block for frame capture and analysis during playback. This block provides real-time access to video frames as they pass through the pipeline, enabling frame extraction, analysis, processing, and snapshot capabilities. Features multiple output formats (buffer, SKBitmap, System.Drawing.Bitmap), configurable pixel formats, frame caching for snapshots, and event-based frame delivery. Essential for video analysis applications, thumbnail generation, motion detection, computer vision integration, real-time monitoring, and any scenario requiring access to raw video data. Implements the VisioForge.Core.MediaBlocks.MediaBlock. Implements the VisioForge.Core.MediaBlocks.IMediaBlockInternals. Implements the IDisposable.
public class VideoSampleGrabberBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternalsInheritance
Implements
Inherited Members
Extension Methods
Constructors
VideoSampleGrabberBlock(VideoFormatX, bool, bool)
Initializes a new instance of the VisioForge.Core.MediaBlocks.VideoProcessing.VideoSampleGrabberBlock class with specified capture format and rendering options.
public VideoSampleGrabberBlock(VideoFormatX format = VideoFormatX.RGBA, bool addNullRenderer = false, bool nullRendererSync = false)Parameters
formatVideoFormatX-
The pixel format for captured frames (default: RGBA).
addNullRendererbool-
if set to
trueadd null renderer for capture-only scenarios. nullRendererSyncbool-
if set to
truenull renderer synchronizes to pipeline clock.
Fields
TAG
Logging tag used to identify log messages from this video sample grabber block.
protected const string TAG = "VideoSampleGrabberBlock"Field Value
Properties
Input
Gets the input.
public override MediaBlockPad Input { get; }Property Value
Inputs
Gets the inputs.
public override MediaBlockPad[] Inputs { get; }Property Value
Output
Gets the output.
public override MediaBlockPad Output { get; }Property Value
Outputs
Gets the outputs.
public override MediaBlockPad[] Outputs { get; }Property Value
SaveLastFrame
Gets or sets a value indicating whether to save the last frame. You can use it to take a snapshot with GetFrame() method. When enabled, maintains a cache of the most recent frame for on-demand retrieval.
public bool SaveLastFrame { get; set; }Property Value
Type
Gets the type.
public override MediaBlockType Type { get; }Property Value
Methods
Build()
Constructs and initializes the video sample grabber and its associated elements. This method creates the grabber with the specified format, establishes event handlers, configures pads, and prepares the block for frame capture and analysis.
public override bool Build()Returns
- bool
-
trueif the grabber was successfully built and configured;falseif initialization failed.
CleanUp()
Releases all resources and performs cleanup operations for this sample grabber block. This method disposes of the grabber elements and resets the build state.
public void CleanUp()Dispose(bool)
Releases unmanaged and - optionally - managed resources.
protected override void Dispose(bool disposing)Parameters
disposingbool-
trueto release both managed and unmanaged resources;falseto release only unmanaged resources.
GetCore()
Gets the core BaseElement wrapper that provides additional functionality around the video sample grabber element.
public BaseElement GetCore()Returns
- BaseElement
-
The BaseElement wrapper instance that encapsulates the sample grabber.
GetElement()
Gets the underlying GStreamer element that performs the frame capture.
public Element GetElement()Returns
- Element
-
The GStreamer Element instance representing the sample grabber.
GetLastFrame()
Gets the last captured video frame as raw data. Requires SaveLastFrame to be enabled before capture.
public VideoFrameX GetLastFrame()Returns
- VideoFrameX
-
The last captured VideoFrameX object, or null if not available.
GetLastFrameAsSKBitmap()
Gets the last captured frame as a SkiaSharp.SKBitmap. Requires SaveLastFrame to be enabled and BGRA/RGBA format.
public SKBitmap GetLastFrameAsSKBitmap()Returns
- SKBitmap
-
The last captured frame as SKBitmap, or null if not available.
IsAvailable()
Determines whether this media block is available. Correct NuGet SDK redist should be included into your project.
public static bool IsAvailable()Returns
- bool
-
trueif this media block is available; otherwise,false.
IMediaBlockInternals.SetContext(MediaBlocksPipeline)
Associates this sample grabber block with a pipeline and initializes its internal context. This method is called internally when the block is added to a pipeline.
void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)Parameters
pipelineMediaBlocksPipeline-
The MediaBlocksPipeline instance that will manage this block.
OnVideoFrameBuffer
This event occurs whenever each new video frame is received. Provides raw frame data as a buffer for custom processing.
public event EventHandler<VideoFrameXBufferEventArgs> OnVideoFrameBufferEvent Type
OnVideoFrameSKBitmap
This event occurs whenever each new video frame is received (SkiaSharp Bitmap). Provides frames as SKBitmap objects for cross-platform image processing.
public event EventHandler<VideoFrameSKBitmapEventArgs> OnVideoFrameSKBitmap