Class MKVSinkBlock
- Namespace
- VisioForge.Core.MediaBlocks.Sinks
- Assembly
- VisioForge.Core.dll
MKV (Matroska) sink block for creating highly flexible multimedia container files.
public class MKVSinkBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals, IMediaBlockDynamicInputsInheritance
Implements
Inherited Members
Extension Methods
Remarks
The MKV sink block creates Matroska files, one of the most flexible and feature-rich multimedia container formats available. Matroska is an open-source format that can hold an unlimited number of video, audio, subtitle, and metadata tracks in a single file. It's particularly popular for high-quality video archiving and distribution.
Key Features:
- Support for virtually any video and audio codec
- Multiple video, audio, and subtitle tracks in one file
- Chapter markers and navigation menus
- Metadata and tag support (title, artist, etc.)
- Error recovery features for damaged files
- Variable framerate support
- Attachments (fonts, images, etc.)
- Streaming capability over HTTP
Typical Use Cases:
- High-quality video archiving and preservation
- Multi-language video distribution (multiple audio/subtitle tracks)
- Anime and foreign film distribution with subtitles
- Professional video production workflows
- Creating files with multiple camera angles
- Long-duration recordings that may need error recovery
Technical Specifications:
- Based on EBML (Extensible Binary Meta Language)
- No inherent resolution or bitrate limitations
- Supports all common codecs: H.264, H.265, VP9, AV1, AAC, FLAC, etc.
- Subtitle formats: SRT, SSA/ASS, VobSub, and more
- Precise timestamp handling with nanosecond accuracy
Advantages over other containers: MKV offers more features than MP4 but may have less universal playback support. It's ideal when flexibility and features are more important than compatibility. Modern players and devices increasingly support MKV natively.
Constructors
MKVSinkBlock(MKVSinkSettings)
Initializes a new instance of the VisioForge.Core.MediaBlocks.Sinks.MKVSinkBlock class with the specified settings.
public MKVSinkBlock(MKVSinkSettings settings)Parameters
settingsMKVSinkSettings-
The VisioForge.Core.Types.X.Sinks.MKVSinkSettings object containing configuration for the MKV output, including filename, metadata, and any specific Matroska features to enable.
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 MKV sink configuration settings.
public MKVSinkSettings Settings { get; set; }Property Value
Type
Gets the media block type identifier for the MKV sink.
public override MediaBlockType Type { get; }Property Value
Methods
Build()
Builds and initializes the MKV 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 Matroska muxer and configures input pads for video, audio, and subtitle streams. MKV's flexibility means it can accept multiple streams of each type, creating a multi-track output file.
CleanUp()
Cleans up resources and finalizes the MKV file.
public void CleanUp()Remarks
This method disposes of the underlying GStreamer Matroska muxer and ensures the MKV file is properly finalized with all necessary headers, indexes, and seek tables for optimal playback.
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. MKV supports: VisioForge.Core.MediaBlocks.MediaBlockPadMediaType.Video for any video codec, VisioForge.Core.MediaBlocks.MediaBlockPadMediaType.Audio for any audio codec, and VisioForge.Core.MediaBlocks.MediaBlockPadMediaType.Subtitle for subtitle tracks.
Returns
- MediaBlockPad
-
A new VisioForge.Core.MediaBlocks.MediaBlockPad configured for the specified media type. MKV's flexibility means it can accept almost any properly formatted stream.
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 Matroska muxer for advanced configuration and feature control.
GetElement()
Gets the native GStreamer element for direct GStreamer API access.
public Element GetElement()Returns
- Element
-
The underlying Gst.Element representing the Matroska muxer, typically 'matroskamux' in GStreamer.
GetFilenameOrURL()
Gets the output filename where the MKV file will be written.
public string GetFilenameOrURL()Returns
- string
-
The file path specified in the settings. MKV files typically use the .mkv extension, though .mka (audio only) and .mks (subtitles only) are also valid.
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. Note that MKV can have multiple pads of the same type for multi-track files.
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 MKV file.
public void SetFilenameOrURL(string value)Parameters
valuestring-
The file path where the MKV file should be written. The directory must exist. Use the .mkv extension for video files.
Remarks
This method only updates the settings. The filename cannot be changed once the pipeline is running and writing has begun.
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.