Class VideoScaleBlock
- Assembly
- VisioForge.Core.dll
MediaBlock that performs video frame scaling and resizing operations with support for various interpolation methods. This block can resize video to specific dimensions, maintain aspect ratios, and apply different scaling algorithms including nearest neighbor and bilinear filtering. It's essential for adapting video content to different display sizes, preparing content for encoding at specific resolutions, or creating picture-in-picture effects. Implements the VisioForge.Core.MediaBlocks.MediaBlock. Implements the VisioForge.Core.MediaBlocks.IMediaBlockInternals. Implements the IDisposable.
public class VideoScaleBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternalsInheritance
Implements
Inherited Members
Extension Methods
Constructors
VideoScaleBlock()
Initializes a new instance of the VisioForge.Core.MediaBlocks.VideoProcessing.VideoScaleBlock class with default settings (no specific dimensions, bilinear scaling).
public VideoScaleBlock()VideoScaleBlock(int, int)
Initializes a new instance of the VisioForge.Core.MediaBlocks.VideoProcessing.VideoScaleBlock class with the specified target dimensions.
public VideoScaleBlock(int width, int height)Parameters
widthint-
The target width in pixels (0 to maintain aspect ratio).
heightint-
The target height in pixels (0 to maintain aspect ratio).
VideoScaleBlock(int, int, VideoScaleMethod)
Initializes a new instance of the VisioForge.Core.MediaBlocks.VideoProcessing.VideoScaleBlock class with the specified target dimensions and scaling method.
public VideoScaleBlock(int width, int height, VFVideoScale.VideoScaleMethod method)Parameters
widthint-
The target width in pixels (0 to maintain aspect ratio).
heightint-
The target height in pixels (0 to maintain aspect ratio).
methodVFVideoScale.VideoScaleMethod-
The scaling interpolation method to use.
Properties
AddBorders
Gets or sets whether to add black borders to maintain aspect ratio. When true, the video will be scaled to fit within the target dimensions while preserving aspect ratio, with black borders added as needed.
public bool AddBorders { get; set; }Property Value
Height
Gets or sets the target height for video scaling. Set to 0 to maintain original height or calculate from width and aspect ratio.
public int Height { get; set; }Property Value
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
ScaleMethod
Gets or sets the scaling interpolation method. Different methods provide different quality/performance trade-offs.
public VFVideoScale.VideoScaleMethod ScaleMethod { get; set; }Property Value
- VFVideoScale.VideoScaleMethod
Type
Gets the type.
public override MediaBlockType Type { get; }Property Value
Width
Gets or sets the target width for video scaling. Set to 0 to maintain original width or calculate from height and aspect ratio.
public int Width { get; set; }Property Value
Methods
Build()
Constructs and initializes the video scale transformation filter and its associated GStreamer elements. This method creates the filter with the specified dimensions and scaling method, establishes input and output pads, and prepares the block for video scaling processing.
public override bool Build()Returns
- bool
-
trueif the filter was successfully built and configured;falseif initialization failed.
CleanUp()
Releases all resources and performs cleanup operations for this video scale transformation 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
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 GStreamer video scale filter element.
public BaseElement GetCore()Returns
- BaseElement
-
The BaseElement wrapper instance that encapsulates the GStreamer video scale filter.
GetElement()
Gets the underlying GStreamer element that performs the video scaling transformations.
public Element GetElement()Returns
- Element
-
The GStreamer Element instance representing the video scale filter.
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 video scale transformation 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.