Table of Contents

Class MediaFileInfo

Namespace
VisioForge.Core.Types.MediaInfo
Assembly
VisioForge.Core.dll

Provides comprehensive information about a media file, including details about its container, video streams, audio streams, subtitle streams, and RTP streams.

public class MediaFileInfo

Inheritance

Inherited Members

Examples

// Assume 'mediaInfo' is an instance of MediaFileInfo obtained from a media file.
Console.WriteLine($"File Duration: {mediaInfo.Container.Duration}");
Console.WriteLine($"File Format: {mediaInfo.Container.Format}");

if (mediaInfo.VideoStreams.Any())
{
    Console.WriteLine($"\nVideo Streams ({mediaInfo.VideoStreams.Count}):");
    foreach (var videoStream in mediaInfo.VideoStreams)
    {
        Console.WriteLine($"  - {videoStream.Codec} ({videoStream.Width}x{videoStream.Height} @ {videoStream.FrameRate.Value:F2} FPS)");
    }
}

if (mediaInfo.AudioStreams.Any())
{
    Console.WriteLine($"\nAudio Streams ({mediaInfo.AudioStreams.Count}):");
    foreach (var audioStream in mediaInfo.AudioStreams)
    {
        Console.WriteLine($"  - {audioStream.Codec} ({audioStream.Channels} ch, {audioStream.SampleRate} Hz)");
    }
}

if (mediaInfo.SubtitleStreams.Any())
{
    Console.WriteLine($"\nSubtitle Streams ({mediaInfo.SubtitleStreams.Count}):");
    foreach (var subtitleStream in mediaInfo.SubtitleStreams)
    {
        Console.WriteLine($"  - {subtitleStream.Codec} ({subtitleStream.Language})");
    }
}

Remarks

This class serves as a central repository for all parsed metadata from a media file. It is typically populated by a media information parser and is essential for applications that need to display detailed file properties, select specific streams for playback or processing, or analyze media content. The Container property provides format-level information such as duration and container type (MP4, AVI, MKV, etc.). Stream collections (VideoStreams, AudioStreams, SubtitleStreams, RTPStreams) contain detailed properties for each elementary stream. Media files can contain multiple streams of each type (e.g., multiple audio tracks for different languages). The IsLive property indicates real-time sources like cameras or network streams, which affects buffering and seeking behavior. GetAudioInfo and GetVideoInfo methods provide quick access to the primary stream information in platform-native formats. The ToString method generates a human-readable summary of all detected streams. This class is thread-safe for reading after initialization, but modifications should be synchronized. Used extensively for stream selection, transcoding planning, and media player initialization.

Constructors

MediaFileInfo()

Initializes a new instance of the VisioForge.Core.Types.MediaInfo.MediaFileInfo class. All stream lists and the container info are initialized to empty instances.

public MediaFileInfo()

Properties

AudioStreams

Gets a list of VisioForge.Core.Types.MediaInfo.AudioStreamInfo objects, each representing an audio stream found in the media file.

public List<AudioStreamInfo> AudioStreams { get; }

Property Value

List<AudioStreamInfo>

Container

Gets the VisioForge.Core.Types.MediaInfo.MediaContainerInfo for the media file. This contains overall information about the file's container format and duration.

public MediaContainerInfo Container { get; }

Property Value

MediaContainerInfo

IsLive

Gets or sets a value indicating whether the media source is live (e.g., a live stream from a camera or network).

public bool IsLive { get; set; }

Property Value

bool

RTPStreams

Gets a list of VisioForge.Core.Types.MediaInfo.RTPStreamInfo objects, each representing an RTP (Real-time Transport Protocol) stream found in the media file.

public List<RTPStreamInfo> RTPStreams { get; }

Property Value

List<RTPStreamInfo>

SubtitleStreams

Gets a list of VisioForge.Core.Types.MediaInfo.SubtitleStreamInfo objects, each representing a subtitle stream found in the media file.

public List<SubtitleStreamInfo> SubtitleStreams { get; }

Property Value

List<SubtitleStreamInfo>

VideoStreams

Gets a list of VisioForge.Core.Types.MediaInfo.VideoStreamInfo objects, each representing a video stream found in the media file.

public List<VideoStreamInfo> VideoStreams { get; }

Property Value

List<VideoStreamInfo>

Methods

Clear()

Clears all stream information and resets the container information to its default empty state.

public void Clear()

GetAudioInfo()

Retrieves audio information in the VisioForge.Core.Types.X.AudioInfoX format from the first available audio stream.

public AudioInfoX GetAudioInfo()

Returns

AudioInfoX

An VisioForge.Core.Types.X.AudioInfoX object if an audio stream is present; otherwise, null.

GetVideoInfo()

Retrieves video information in the VisioForge.Core.Types.X.VideoFrameInfoX format from the first available video stream.

public VideoFrameInfoX GetVideoInfo()

Returns

VideoFrameInfoX

A VisioForge.Core.Types.X.VideoFrameInfoX object if a video stream is present; otherwise, null.

ToString()

Returns a string that represents the current VisioForge.Core.Types.MediaInfo.MediaFileInfo instance. The string includes summary information about the container and all detected video and audio streams.

public override string ToString()

Returns

string

A String that represents this instance.