Show / Hide Table of Contents

Class FormatContext

Inheritance
object
OptionQueryableBase
FormatContext
DemuxerContext
MuxerContext
Implements
IOptionQueryable
ILoggingContext
IDisposable
IAVPointer<_AVFormatContext>
Inherited Members
OptionQueryableBase.ResetOptions()
OptionQueryableBase.GetOptions(bool)
OptionQueryableBase.FindOption(string, bool)
OptionQueryableBase.SetOption(string, string, bool)
OptionQueryableBase.SetOption(string, long, bool)
OptionQueryableBase.SetOption(string, bool, bool)
OptionQueryableBase.SetOption(string, double, bool)
OptionQueryableBase.SetOption(string, Rational, bool)
OptionQueryableBase.SetOption(string, ReadOnlySpan<byte>, bool)
OptionQueryableBase.SetOption(string, ReadOnlyMemory<byte>, bool)
OptionQueryableBase.SetOption(string, int, int, bool)
OptionQueryableBase.SetOption(string, (int Width, int Height), bool)
OptionQueryableBase.SetOption(string, PixelFormat, bool)
OptionQueryableBase.SetOption(string, SampleFormat, bool)
OptionQueryableBase.SetOption(string, IDictionary<string, string>, bool)
OptionQueryableBase.SetOption(string, ILookup<string, string>, bool)
OptionQueryableBase.SetOption(IDictionary<string, string>, bool)
OptionQueryableBase.SetOption(string, ref ILookup<string, string>, bool)
OptionQueryableBase.SetOption<T>(string, T, bool)
OptionQueryableBase.SetOption(string, object, bool)
OptionQueryableBase.SetOption(Option, string, bool)
OptionQueryableBase.SetOption(Option, bool, bool)
OptionQueryableBase.SetOption(Option, long, bool)
OptionQueryableBase.SetOption(Option, double, bool)
OptionQueryableBase.SetOption(Option, Rational, bool)
OptionQueryableBase.SetOption(Option, ReadOnlySpan<byte>, bool)
OptionQueryableBase.SetOption(Option, ReadOnlyMemory<byte>, bool)
OptionQueryableBase.SetOption(Option, int, int, bool)
OptionQueryableBase.SetOption(Option, (int Width, int Height), bool)
OptionQueryableBase.SetOption(Option, PixelFormat, bool)
OptionQueryableBase.SetOption(Option, SampleFormat, bool)
OptionQueryableBase.SetOption(Option, IDictionary<string, string>, bool)
OptionQueryableBase.SetOption(Option, ILookup<string, string>, bool)
OptionQueryableBase.SetOption<T>(Option, T, bool)
OptionQueryableBase.SetOption(Option, object, bool)
OptionQueryableBase.TryGetOption(string, out string, bool)
OptionQueryableBase.TryGetOption(string, out long, bool)
OptionQueryableBase.TryGetOption<T>(string, out T, bool)
OptionQueryableBase.TryGetOption(string, out ulong, bool)
OptionQueryableBase.TryGetOption(string, out int, bool)
OptionQueryableBase.TryGetOption(string, out bool, bool)
OptionQueryableBase.TryGetOption(string, out uint, bool)
OptionQueryableBase.TryGetOption(string, out double, bool)
OptionQueryableBase.TryGetOption(string, out Rational, bool)
OptionQueryableBase.TryGetOption(string, out PixelFormat, bool)
OptionQueryableBase.TryGetOption(string, out SampleFormat, bool)
OptionQueryableBase.TryGetOption(string, out IDictionary<string, string>, bool)
OptionQueryableBase.TryGetOption(string, out Dictionary<string, string>, bool)
OptionQueryableBase.TryGetOption(string, out AVDictionary, bool)
OptionQueryableBase.TryGetOption(string, out ILookup<string, string>, bool)
OptionQueryableBase.TryGetOption(string, out AVMultiDictionary, bool)
OptionQueryableBase.TryGetOption(string, out int, out int, bool)
OptionQueryableBase.TryGetOption(string, out (int Width, int Height), bool)
OptionQueryableBase.TryGetOption(string, Span<byte>, bool)
OptionQueryableBase.TryGetOption(string, out byte[], bool)
OptionQueryableBase.TryGetOption(string, out Memory<byte>, bool)
OptionQueryableBase.TryGetOption(string, out ReadOnlyMemory<byte>, bool)
OptionQueryableBase.TryGetOption(string, out object, bool)
OptionQueryableBase.TryGetOption(Option, out string, bool)
OptionQueryableBase.TryGetOption(Option, out long, bool)
OptionQueryableBase.TryGetOption<T>(Option, out T, bool)
OptionQueryableBase.TryGetOption(Option, out ulong, bool)
OptionQueryableBase.TryGetOption(Option, out int, bool)
OptionQueryableBase.TryGetOption(Option, out bool, bool)
OptionQueryableBase.TryGetOption(Option, out uint, bool)
OptionQueryableBase.TryGetOption(Option, out double, bool)
OptionQueryableBase.TryGetOption(Option, out Rational, bool)
OptionQueryableBase.TryGetOption(Option, out PixelFormat, bool)
OptionQueryableBase.TryGetOption(Option, out SampleFormat, bool)
OptionQueryableBase.TryGetOption(Option, out IDictionary<string, string>, bool)
OptionQueryableBase.TryGetOption(Option, out Dictionary<string, string>, bool)
OptionQueryableBase.TryGetOption(Option, out AVDictionary, bool)
OptionQueryableBase.TryGetOption(Option, out ILookup<string, string>, bool)
OptionQueryableBase.TryGetOption(Option, out AVMultiDictionary, bool)
OptionQueryableBase.TryGetOption(Option, out int, out int, bool)
OptionQueryableBase.TryGetOption(Option, out (int Width, int Height), bool)
OptionQueryableBase.TryGetOption(Option, out byte[], bool)
OptionQueryableBase.TryGetOption(Option, out Memory<byte>, bool)
OptionQueryableBase.TryGetOption(Option, out ReadOnlyMemory<byte>, bool)
OptionQueryableBase.TryGetOption(Option, Span<byte>, bool)
OptionQueryableBase.TryGetOption(Option, out object, bool)
OptionQueryableBase.SetOption(string, ChannelLayout, bool)
OptionQueryableBase.SetOption(Option, ChannelLayout, bool)
OptionQueryableBase.TryGetOption(string, out ChannelLayout, bool)
OptionQueryableBase.TryGetOption(Option, out ChannelLayout, bool)
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: FFmpeg.Formats
Assembly: FFmpeg.dll
Syntax
public abstract class FormatContext : OptionQueryableBase, IOptionQueryable, ILoggingContext, IDisposable, IAVPointer<_AVFormatContext>
Remarks

FormatContext provides the common functionality shared by demuxing and muxing format contexts. It wraps FFmpeg's native FFmpeg.AutoGen._AVFormatContext structure and exposes a managed, object-oriented API for working with media containers, streams, metadata, and format-specific options.

As a wrapper around unmanaged resources, this class implements IDisposable. Instances should be disposed when no longer needed to release the underlying FFmpeg resources.

Because this class derives from OptionQueryableBase, any FFmpeg options supported by FFmpeg.AutoGen._AVFormatContext can be queried and modified through the managed options API.

Constructors

View Source

FormatContext(_AVFormatContext*)

Initializes a new FormatContext from an existing native FFmpeg.AutoGen._AVFormatContext.

Declaration
protected FormatContext(_AVFormatContext* context)
Parameters
Type Name Description
_AVFormatContext* context

The native format context to wrap.

Properties

View Source

Chapters

Gets the chapters contained in the media.

Declaration
public virtual ChapterList Chapters { get; }
Property Value
Type Description
ChapterList
Remarks

The returned collection provides access to the chapter entries stored in the underlying format context.

View Source

Flags

Gets the flags associated with this format context.

Declaration
public FormatContextFlags Flags { get; }
Property Value
Type Description
FormatContextFlags
View Source

IsDisposed

Indicates whether the instance is disposed.

Declaration
public bool IsDisposed { get; }
Property Value
Type Description
bool
View Source

Metadata

Gets the metadata associated with the format context.

Declaration
public AVDictionary_ref Metadata { get; }
Property Value
Type Description
AVDictionary_ref
View Source

Pointer

Abstract base class that provides access to a pointer for AVOptions retrieval.

Declaration
protected override void* Pointer { get; }
Property Value
Type Description
void*
Overrides
OptionQueryableBase.Pointer
View Source

Seekable

Gets the types of seeking supported by the underlying I/O context.

Declaration
public Seekable Seekable { get; }
Property Value
Type Description
Seekable
Remarks

The value indicates which seeking operations are supported by the underlying AVIOContext. Derived classes can modify this value when creating or configuring a custom I/O context.

View Source

StartTimeRealTime

Gets the wall-clock time at which the media stream started.

Declaration
public DateTime? StartTimeRealTime { get; }
Property Value
Type Description
DateTime?
Remarks

Returns null if the information is unavailable.

View Source

StreamCount

Gets the number of streams in this format context.

Declaration
public int StreamCount { get; }
Property Value
Type Description
int
View Source

Streams

Cached managed wrappers for the native streams.

Declaration
public IReadOnlyList<AVStream> Streams { get; }
Property Value
Type Description
IReadOnlyList<AVStream>
Remarks

The collection is synchronized with the underlying native stream array on demand. If FFmpeg adds or replaces streams, the cached managed wrappers are recreated automatically.

View Source

Url

Gets the URL or filename associated with the format context.

Declaration
public string? Url { get; }
Property Value
Type Description
string
Remarks

Returns null if no URL has been assigned.

Methods

View Source

Dispose()

Disposes of the resources used by the FormatContext and suppresses finalization.

Declaration
public void Dispose()
View Source

Dispose(bool)

Releases the resources used by the current format context.

Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type Name Description
bool disposing

Indicates whether the method is being called from the Dispose() method or a finalizer.

View Source

~FormatContext()

Finalizes the FormatContext.

Declaration
protected ~FormatContext()
View Source

FindBestStream(MediaType)

Finds the most appropriate stream of the specified media type.

Declaration
public int FindBestStream(MediaType type)
Parameters
Type Name Description
MediaType type

The media type to search for.

Returns
Type Description
int

The zero-based stream index if a suitable stream is found; otherwise a negative FFmpeg error code.

Remarks

This method calls FFmpeg's av_find_best_stream() using the default stream selection behavior.

View Source

Free()

Releases the resources associated with this format context.

Declaration
public void Free()
Remarks

Equivalent to calling Dispose().

View Source

GetOutputTimestamp(int, out TimeSpan, out TimeSpan)

Retrieves the most recently output timestamp for a stream.

Declaration
public AVResult32 GetOutputTimestamp(int streamIndex, out TimeSpan timestamp, out TimeSpan wallTime)
Parameters
Type Name Description
int streamIndex

The index of the output stream.

TimeSpan timestamp

Receives the output timestamp converted to the stream's time base.

TimeSpan wallTime

Receives the corresponding wall-clock timestamp.

Returns
Type Description
AVResult32

The result returned by av_get_output_timestamp().

Remarks

This method is primarily intended for monitoring the progress of output devices or muxers that support timestamp reporting.

View Source

SetContext(IOContext, IOOptions, int)

Associates a custom IOContext with this format context.

Declaration
public void SetContext(IOContext context, IOOptions options, int bufferSize = 32768)
Parameters
Type Name Description
IOContext context

The IOContext to associate with the current format context.

IOOptions options

The IOOptions specifying the operations (e.g., read or write) to be used with the context.

int bufferSize

The size of the buffer to use for the I/O operations. Default is 32 KB.

Remarks

Calling this method replaces any previously associated IOContext. The supplied context is initialized and attached to this format context.

Implements

IOptionQueryable
ILoggingContext
IDisposable
IAVPointer<T>

Extension Methods

LoggingContextExtensions.Debug(ILoggingContext, string)
LoggingContextExtensions.Error(ILoggingContext, string)
LoggingContextExtensions.Fatal(ILoggingContext, string)
LoggingContextExtensions.Info(ILoggingContext, string)
LoggingContextExtensions.Log(ILoggingContext, LogLevel, string)
LoggingContextExtensions.Panic(ILoggingContext, string)
LoggingContextExtensions.Trace(ILoggingContext, string)
LoggingContextExtensions.Verbose(ILoggingContext, string)
LoggingContextExtensions.Warning(ILoggingContext, string)
  • View Source
In this article
Back to top Generated by DocFX