Class WebMSinkBlock
- Namespace
- VisioForge.Core.MediaBlocks.Sinks
- Assembly
- VisioForge.Core.dll
WebM sink block for creating WebM container files with VP8/VP9 video and Vorbis/Opus audio.
public class WebMSinkBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals, IMediaBlockDynamicInputsInheritance
Implements
Inherited Members
Extension Methods
Remarks
The WebM sink block creates WebM files, an open-source multimedia container format designed specifically for the web. WebM is based on a subset of the Matroska (MKV) container and is optimized for streaming over the internet. It's particularly popular for HTML5 video delivery due to its royalty-free codecs and broad browser support.
Key Features:
- Support for VP8 and VP9 video codecs
- Support for Vorbis and Opus audio codecs
- Optimized for web streaming and HTML5 video
- Royalty-free format with no licensing fees
- Metadata and chapter support
- Efficient compression with good quality
- Native browser support in Chrome, Firefox, Opera, and Edge
Typical Use Cases:
- Creating video content for web platforms
- HTML5 video embedding without plugin requirements
- Open-source video distribution
- Streaming video content with adaptive bitrate
- Creating royalty-free video archives
Technical Specifications:
- Container: Based on Matroska (MKV) format
- Video codecs: VP8 (older), VP9 (recommended for better compression)
- Audio codecs: Vorbis (older), Opus (recommended for better quality)
- Maximum resolution: No inherent limit (4K and beyond supported)
- Streaming: Supports progressive download and adaptive streaming
Browser Compatibility: WebM is natively supported in most modern browsers without plugins. For maximum compatibility, consider providing fallback formats like MP4.
Constructors
WebMSinkBlock(WebMSinkSettings)
Initializes a new instance of the VisioForge.Core.MediaBlocks.Sinks.WebMSinkBlock class with the specified settings.
public WebMSinkBlock(WebMSinkSettings settings)Parameters
settingsWebMSinkSettings-
The VisioForge.Core.Types.X.Sinks.WebMSinkSettings object containing configuration for the WebM output, including the target filename and any specific muxing parameters.
WebMSinkBlock(string)
Initializes a new instance of the VisioForge.Core.MediaBlocks.Sinks.WebMSinkBlock class with a simple filename.
public WebMSinkBlock(string filename)Parameters
filenamestring-
The path where the WebM file will be written. The file extension should be .webm. The directory must exist and be writable.
Properties
Input
Gets the first input pad from the collection of available inputs.
public override MediaBlockPad Input { get; }Property Value
Inputs
Gets all available input pads for connecting multiple media streams.
public override MediaBlockPad[] Inputs { get; }Property Value
Output
Gets the output pad for this sink block.
public override MediaBlockPad Output { get; }Property Value
Outputs
Gets all output pads for this sink block.
public override MediaBlockPad[] Outputs { get; }Property Value
Settings
Gets or sets the WebM sink configuration settings.
public WebMSinkSettings Settings { get; set; }Property Value
Type
Gets the media block type identifier for the WebM sink.
public override MediaBlockType Type { get; }Property Value
Methods
Build()
Builds and initializes the WebM sink pipeline components.
public override bool Build()Returns
- bool
-
trueif the sink was successfully built and all requested input pads were created;falseif initialization failed or required pads couldn't be allocated.
Remarks
This method creates the underlying GStreamer WebM muxer element and configures input pads for each media stream. The muxer expects VP8/VP9 video and/or Vorbis/Opus audio streams.
CleanUp()
Cleans up resources and finalizes the WebM file.
public void CleanUp()Remarks
This method disposes of the underlying GStreamer WebM muxer element and ensures the WebM file is properly finalized with correct headers and indexes.
CreateNewInput(MediaBlockPadMediaType)
Creates a new input pad for connecting a media stream of the specified type.
public MediaBlockPad CreateNewInput(MediaBlockPadMediaType mediaType)Parameters
mediaTypeMediaBlockPadMediaType-
The type of media stream to accept. WebM supports: VisioForge.Core.MediaBlocks.MediaBlockPadMediaType.Video for VP8/VP9 video streams and VisioForge.Core.MediaBlocks.MediaBlockPadMediaType.Audio for Vorbis/Opus audio streams.
Returns
- MediaBlockPad
-
A new VisioForge.Core.MediaBlocks.MediaBlockPad configured for the specified media type. Ensure connected streams use WebM-compatible codecs.
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 GStreamer wrapper element for advanced pipeline integration.
public BaseElement GetCore()Returns
- BaseElement
-
The VisioForge.Core.GStreamer.Base.BaseElement wrapper providing access to the underlying GStreamer WebM muxer for advanced configuration.
GetElement()
Gets the native GStreamer element for direct GStreamer API access.
public Element GetElement()Returns
- Element
-
The underlying Gst.Element representing the WebM muxer, typically 'webmmux' in GStreamer.
GetFilenameOrURL()
Gets the output filename where the WebM file will be written.
public string GetFilenameOrURL()Returns
- string
-
The file path specified in the settings. WebM files typically use the .webm extension.
GetInput(MediaBlockPadMediaType)
Gets an existing input pad that matches the specified media type.
public MediaBlockPad GetInput(MediaBlockPadMediaType mediaType)Parameters
mediaTypeMediaBlockPadMediaType-
The media type to search for among existing input pads.
Returns
- MediaBlockPad
-
The first VisioForge.Core.MediaBlocks.MediaBlockPad that matches the specified media type, or
nullif no matching input pad exists.
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.
SetFilenameOrURL(string)
Sets the output filename for the WebM file.
public void SetFilenameOrURL(string value)Parameters
valuestring-
The file path where the WebM file should be written. The directory must exist. Use the .webm extension for proper file association.
Remarks
This method only updates the settings. The actual file location cannot be changed once the pipeline is running.
IMediaBlockInternals.SetContext(MediaBlocksPipeline)
Sets the pipeline context for this media block.
void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)Parameters
pipelineMediaBlocksPipeline-
The VisioForge.Core.MediaBlocks.MediaBlocksPipeline that owns this sink block, providing access to the pipeline context and logging facilities.
Remarks
This method is called internally by the pipeline during initialization and should not be called directly by user code.