Class AVISinkBlock
- Namespace
- VisioForge.Core.MediaBlocks.Sinks
- Assembly
- VisioForge.Core.dll
Implements a sink block for writing media data to AVI (Audio Video Interleave) container files. Supports multiple audio and video streams with configurable encoding parameters. AVI is a multimedia container format that stores audio and video data in a file container that allows synchronous audio-with-video playback.
public class AVISinkBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals, IMediaBlockDynamicInputsInheritance
Implements
Inherited Members
Extension Methods
Remarks
The AVISinkBlock provides functionality to write media streams to AVI files, supporting: - Multiple video streams with different codecs - Multiple audio streams with various encoders - Configurable container and codec settings - Frame-accurate synchronization
This block accepts dynamic inputs for video and audio streams, which must be added before building the pipeline. Each stream can have its own encoding configuration.
Common use cases include: - Recording video from cameras to AVI files - Converting media to AVI format - Creating multi-stream AVI files - Archiving video content
Constructors
AVISinkBlock(AVISinkSettings)
Initializes a new instance of the VisioForge.Core.MediaBlocks.Sinks.AVISinkBlock class.
public AVISinkBlock(AVISinkSettings settings)Parameters
settingsAVISinkSettings-
The configuration settings for the AVI sink, including filename and codec parameters.
Exceptions
- ArgumentNullException
-
Thrown when
settingsisnull.
AVISinkBlock(string)
Initializes a new instance of the VisioForge.Core.MediaBlocks.Sinks.AVISinkBlock class.
public AVISinkBlock(string filename)Parameters
filenamestring-
The filename.
Properties
Input
Gets the first input pad from the collection of inputs.
public override MediaBlockPad Input { get; }Property Value
Inputs
Gets all input pads available for this sink.
public override MediaBlockPad[] Inputs { get; }Property Value
Output
Gets the output pad for this block.
public override MediaBlockPad Output { get; }Property Value
Outputs
Gets all output pads for this block.
public override MediaBlockPad[] Outputs { get; }Property Value
Settings
Gets or sets the AVI sink configuration settings.
public AVISinkSettings Settings { get; set; }Property Value
Remarks
These settings control various aspects of the AVI file creation including:
- Output filename and path
- Video codec settings (resolution, bitrate, framerate)
- Audio codec settings (sample rate, channels, bitrate)
- Container-specific parameters
Type
Gets the type of this media block.
public override MediaBlockType Type { get; }Property Value
Methods
Build()
Builds the AVI sink block and prepares it for operation.
public override bool Build()Returns
- bool
-
trueif the build was successful; otherwise,false.
Remarks
This method:
- Creates the underlying AVI sink element
- Configures it with the provided settings
- Sets up input pads for all added streams
- Validates that all components are properly initialized
CleanUp()
Performs cleanup of resources used by the AVI sink.
public void CleanUp()Remarks
This method releases the underlying GStreamer element and resets the build state. It is called during disposal to ensure proper resource cleanup.
CreateNewInput(MediaBlockPadMediaType)
Creates a new input pad for the specified media type.
public MediaBlockPad CreateNewInput(MediaBlockPadMediaType mediaType)Parameters
mediaTypeMediaBlockPadMediaType-
The type of media this input will accept (video, audio, etc.).
Returns
- MediaBlockPad
-
A new VisioForge.Core.MediaBlocks.MediaBlockPad configured for the specified media type.
Remarks
Use this method to add inputs for each stream you want to include in the AVI file. Multiple video and audio streams can be added, but subtitle streams are not supported by AVI.
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 core.
public BaseElement GetCore()Returns
- BaseElement
-
VisioForge.Core.GStreamer.Base.BaseElement.
GetElement()
Gets the element.
public Element GetElement()Returns
- Element
-
Gst.Element.
GetFilenameOrURL()
Gets the output filename for the AVI file.
public string GetFilenameOrURL()Returns
- string
-
The full path to the output AVI file.
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.
Returns
- MediaBlockPad
-
The first input pad matching the media type;
nullif no match is found.
Remarks
This method is useful when you need to connect to an existing input pad rather than creating a new one.
IsAvailable()
Determines whether the AVI sink functionality is available on the current platform.
public static bool IsAvailable()Returns
- bool
-
trueif AVI sink is available; otherwise,false. Availability depends on GStreamer plugins and platform support.
Remarks
This method checks for the presence of required GStreamer plugins (avimux, filesink) and should be called before attempting to create an AVISinkBlock instance.
SetFilenameOrURL(string)
Sets the output filename for the AVI file.
public void SetFilenameOrURL(string value)Parameters
valuestring-
The full path where the AVI file should be written.
Remarks
The directory must exist and be writable. The file will be overwritten if it already exists.
IMediaBlockInternals.SetContext(MediaBlocksPipeline)
Sets the context.
void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)Parameters
pipelineMediaBlocksPipeline-
The pipeline.