Table of Contents

Class VideoCropBlock

Namespace
VisioForge.Core.MediaBlocks.VideoProcessing
Assembly
VisioForge.Core.dll

MediaBlock that crops video frames by removing specified regions from the edges or center. Video cropping allows precise trimming of unwanted areas from video content, supporting pixel-accurate region selection with top, bottom, left, and right margins. This is essential for removing black bars, focusing on specific areas of interest, changing aspect ratios, or preparing content for different display formats. The cropping operation is lossless and preserves the original video quality while reducing the frame dimensions. Implements the VisioForge.Core.MediaBlocks.MediaBlock. Implements the VisioForge.Core.MediaBlocks.IMediaBlockInternals. Implements the IDisposable.

public class VideoCropBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals

Inheritance

Implements

Inherited Members

Extension Methods

Constructors

VideoCropBlock(CropVideoEffect)

Initializes a new instance of the VisioForge.Core.MediaBlocks.VideoProcessing.VideoCropBlock class with the specified crop settings. The settings define how many pixels to remove from each edge of the video frames.

public VideoCropBlock(CropVideoEffect settings)

Parameters

settings CropVideoEffect

The CropVideoEffect settings specifying crop margins for top, bottom, left, and right edges.

Properties

Input

Gets the input.

public override MediaBlockPad Input { get; }

Property Value

MediaBlockPad

Inputs

Gets the inputs.

public override MediaBlockPad[] Inputs { get; }

Property Value

MediaBlockPad[]

Output

Gets the output.

public override MediaBlockPad Output { get; }

Property Value

MediaBlockPad

Outputs

Gets the outputs.

public override MediaBlockPad[] Outputs { get; }

Property Value

MediaBlockPad[]

Settings

Gets or sets the crop settings that define which regions to remove from the video frames. These settings specify the number of pixels to crop from the top, bottom, left, and right edges of each frame, allowing precise control over the final video dimensions and content area.

public CropVideoEffect Settings { get; set; }

Property Value

CropVideoEffect

Type

Gets the type.

public override MediaBlockType Type { get; }

Property Value

MediaBlockType

Methods

Build()

Constructs and initializes the video crop filter and its associated GStreamer elements. This method creates the filter with the specified crop settings, establishes input and output pads, and prepares the block for video frame cropping operations.

public override bool Build()

Returns

bool

true if the filter was successfully built and configured; false if initialization failed.

CleanUp()

Releases all resources and performs cleanup operations for this video crop block. This method disposes of the GStreamer elements and resets the build state.

public void CleanUp()

Dispose(bool)

Releases unmanaged and - optionally - managed resources.

protected override void Dispose(bool disposing)

Parameters

disposing bool

true to release both managed and unmanaged resources; false to release only unmanaged resources.

GetCore()

Gets the core BaseElement wrapper that provides additional functionality around the GStreamer video crop filter element.

public BaseElement GetCore()

Returns

BaseElement

The BaseElement wrapper instance that encapsulates the GStreamer video crop filter.

GetElement()

Gets the underlying GStreamer element that performs the video cropping operations.

public Element GetElement()

Returns

Element

The GStreamer Element instance representing the video crop filter.

IsAvailable()

Determines whether the video crop filter is available on the current system. This checks if the required GStreamer video processing plugins are installed and accessible. The correct NuGet SDK redistribution package should be included in your project.

public static bool IsAvailable()

Returns

bool

true if the video crop filter is available and can be used; otherwise, false.

Update()

Updates the crop settings in real-time while the pipeline is running. Call this method after modifying the Settings property to apply new crop margins immediately. This allows dynamic adjustment of the crop area during video processing.

public void Update()

IMediaBlockInternals.SetContext(MediaBlocksPipeline)

Associates this video crop 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

pipeline MediaBlocksPipeline

The MediaBlocksPipeline instance that will manage this block.

See Also