Show / Hide Table of Contents

Class FilterContext

Represents an instance of a filter within an FFmpeg filter graph.

Inheritance
object
OptionQueryableBase
FilterContext
AudioBufferSink
AudioBufferSource
AudioFormat
FramePack
HWDownload
HWUpload
HWUploadCuda
VideoBufferSink
VideoBufferSource
Implements
IOptionQueryable
ILoggingContext
IAVPointer<_AVFilterContext>
IBufferSource
IBufferSink
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.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: FFmpeg.Filters
Assembly: FFmpeg.dll
Syntax
public class FilterContext : OptionQueryableBase, IOptionQueryable, ILoggingContext, IAVPointer<_AVFilterContext>, IBufferSource, IBufferSink
Remarks

A FilterContext stores the state of a filter after it has been added to a FilterGraph. It provides access to the filter's options, pads, links, and methods for sending or receiving frames from buffer source and sink filters.

Properties

View Source

ExtraHWFrames

Gets or sets the number of additional hardware frames allocated by the filter.

Declaration
public int ExtraHWFrames { get; set; }
Property Value
Type Description
int
Remarks

This property is primarily used with hardware-accelerated filters to reduce pipeline stalls caused by frame buffering.

View Source

Filter

Gets the filter associated with this context.

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

HwDeviceContext

Gets the hardware device context used by the filter.

Declaration
public DeviceContext_ref HwDeviceContext { get; }
Property Value
Type Description
DeviceContext_ref
Remarks

Hardware-accelerated filters use this device context to determine the hardware device on which their operations are performed.

For filters such as HWUpload, the device context specifies the hardware device to which system-memory frames are uploaded unless the filter is configured to derive a device using its DeriveDevice property.

View Source

InputCount

Gets the number of input pads exposed by the filter.

Declaration
public uint InputCount { get; }
Property Value
Type Description
uint
View Source

InputFilterLinks

Gets all connected input links.

Declaration
public IEnumerable<FilterLink> InputFilterLinks { get; }
Property Value
Type Description
IEnumerable<FilterLink>
Remarks

Only connected input pads are included in the enumeration.

View Source

InputFilterPads

Gets an enumeration of all input pads.

Declaration
public IEnumerable<FilterPad> InputFilterPads { get; }
Property Value
Type Description
IEnumerable<FilterPad>
View Source

Name

Gets the name of the filter context.

Declaration
public string Name { get; }
Property Value
Type Description
string
View Source

OutputCount

Gets the number of output pads exposed by the filter.

Declaration
public uint OutputCount { get; }
Property Value
Type Description
uint
View Source

OutputFilterLinks

Gets all connected output links.

Declaration
public IEnumerable<FilterLink> OutputFilterLinks { get; }
Property Value
Type Description
IEnumerable<FilterLink>
Remarks

Only connected output pads are included in the enumeration.

View Source

OutputFilterPads

Gets an enumeration of all output pads.

Declaration
public IEnumerable<FilterPad> OutputFilterPads { get; }
Property Value
Type Description
IEnumerable<FilterPad>
View Source

Pointer

Gets a pointer to the filter context, used for option queries.

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

Threads

Gets or sets the maximum number of worker threads used by the filter.

Declaration
public int Threads { get; set; }
Property Value
Type Description
int

A value less than or equal to zero lets FFmpeg choose the appropriate thread count automatically.

Methods

View Source

Allocate(string, Filter, FilterGraph)

Allocates a filter context without initializing it.

Declaration
public static FilterContext? Allocate(string name, Filter filter, FilterGraph graph)
Parameters
Type Name Description
string name

The name of the filter instance.

Filter filter

The filter to allocate.

FilterGraph graph

The filter graph that will own the filter.

Returns
Type Description
FilterContext

A newly allocated FilterContext, or null if the allocation failed.

Remarks

Unlike Create(string, Filter, string?, FilterGraph), this method only allocates the filter context. Before the filter can be used, it must be initialized by calling one of the Init() overloads. This overload is useful when filter options must be configured before initialization.

View Source

As<T>()

Creates a managed wrapper of the specified filter context type for the current native filter context.

Declaration
public T As<T>() where T : FilterContext
Returns
Type Description
T

A managed wrapper of type T referencing the current native filter context.

Type Parameters
Name Description
T

The managed filter context type to create.

Remarks

This method does not verify that the underlying native filter is compatible with T. The caller is responsible for ensuring that the requested type corresponds to the native filter context.

Exceptions
Type Condition
InvalidCastException

T does not provide a constructor accepting an _AVFilterContext*.

View Source

Create(string, Filter, AVDictionary, FilterGraph)

Creates and initializes a filter using the specified dictionary of options.

Declaration
public static FilterContext Create(string name, Filter filter, AVDictionary dictionary, FilterGraph graph)
Parameters
Type Name Description
string name

The name of the filter instance.

Filter filter

The filter to create.

AVDictionary dictionary

The dictionary containing the filter options.

FilterGraph graph

The filter graph that will own the filter.

Returns
Type Description
FilterContext

The initialized FilterContext.

Remarks

This method allocates the filter, applies the specified options during initialization, and returns the initialized filter context.

View Source

Create(string, Filter, AVMultiDictionary, FilterGraph)

Creates and initializes a filter using the specified multi-value dictionary of options.

Declaration
public static FilterContext Create(string name, Filter filter, AVMultiDictionary dictionary, FilterGraph graph)
Parameters
Type Name Description
string name

The name of the filter instance.

Filter filter

The filter to create.

AVMultiDictionary dictionary

The multi-value dictionary containing the filter options.

FilterGraph graph

The filter graph that will own the filter.

Returns
Type Description
FilterContext

The initialized FilterContext.

Remarks

This method allocates the filter, initializes it using the specified options, and returns the initialized filter context.

View Source

Create(string, Filter, FilterGraph)

Creates and initializes a filter within the specified filter graph.

Declaration
public static FilterContext Create(string name, Filter filter, FilterGraph graph)
Parameters
Type Name Description
string name

The name of the filter instance.

Filter filter

The filter to create.

FilterGraph graph

The filter graph that will own the filter.

Returns
Type Description
FilterContext

The initialized FilterContext.

Remarks

Unlike Allocate(string, Filter, FilterGraph), this method both allocates and initializes the filter. After the method returns successfully, the filter is ready to be linked into a filter graph and used.

View Source

Create(string, Filter, IDictionary<string, string>, FilterGraph)

Creates and initializes a filter using the specified dictionary of options.

Declaration
public static FilterContext Create(string name, Filter filter, IDictionary<string, string> dictionary, FilterGraph graph)
Parameters
Type Name Description
string name

The name of the filter instance.

Filter filter

The filter to create.

IDictionary<string, string> dictionary

A dictionary containing the filter options. After the method returns, the dictionary contains only the options that were not recognized by the filter.

FilterGraph graph

The filter graph that will own the filter.

Returns
Type Description
FilterContext

The initialized FilterContext.

Remarks

This method allocates the filter, initializes it using the specified options, and returns the initialized filter context.

View Source

Create(string, Filter, string?, FilterGraph)

Creates and initializes a filter within the specified filter graph.

Declaration
public static FilterContext Create(string name, Filter filter, string? args, FilterGraph graph)
Parameters
Type Name Description
string name

The name of the filter instance.

Filter filter

The filter to create.

string args

An optional filter argument string, or null to use the filter's default settings.

FilterGraph graph

The filter graph that will own the filter.

Returns
Type Description
FilterContext

The initialized FilterContext.

Remarks

Unlike Allocate(string, Filter, FilterGraph), this method both allocates and initializes the filter. After the method returns successfully, the filter is ready to be linked into a filter graph and used.

View Source

Delete()

This frees the filter context and removes it from it's filter graph

Declaration
public void Delete()
View Source

GetInputFilterLink(int)

Gets the link connected to the specified input pad.

Declaration
public FilterLink? GetInputFilterLink(int index)
Parameters
Type Name Description
int index

The zero-based input pad index.

Returns
Type Description
FilterLink

The connected FilterLink, or null if the input pad is not connected.

View Source

GetInputFilterPad(int)

Gets the number of output pads exposed by the filter.

Declaration
public FilterPad GetInputFilterPad(int index)
Parameters
Type Name Description
int index
Returns
Type Description
FilterPad
View Source

GetOutputFilterLink(int)

Gets the link connected to the specified output pad.

Declaration
public FilterLink? GetOutputFilterLink(int index)
Parameters
Type Name Description
int index

The zero-based output pad index.

Returns
Type Description
FilterLink

The connected FilterLink, or null if the output pad is not connected.

View Source

GetOutputFilterPad(int)

Gets the output pad at the specified index.

Declaration
public FilterPad GetOutputFilterPad(int index)
Parameters
Type Name Description
int index
Returns
Type Description
FilterPad
View Source

Init()

Initializes the filter context without arguments.

Declaration
public AVResult32 Init()
Returns
Type Description
AVResult32
View Source

Init(AVDictionary)

Initializes the filter using the specified dictionary of options.

Declaration
public AVResult32 Init(AVDictionary dictionary)
Parameters
Type Name Description
AVDictionary dictionary

The dictionary containing the filter options. Recognized options are removed from the dictionary during initialization.

Returns
Type Description
AVResult32

The result of the initialization operation.

Remarks

This method wraps FFmpeg's avfilter_init_dict(). Any options that are not recognized by the filter remain in dictionary after the method returns.

View Source

Init(AVMultiDictionary)

Initializes the filter using the specified dictionary of options.

Declaration
public AVResult32 Init(AVMultiDictionary dictionary)
Parameters
Type Name Description
AVMultiDictionary dictionary

The dictionary containing the filter options. Recognized options are removed from the dictionary during initialization.

Returns
Type Description
AVResult32

The result of the initialization operation.

Remarks

This method wraps FFmpeg's avfilter_init_dict(). Any options that are not recognized by the filter remain in dictionary after the method returns.

View Source

Init(IDictionary<string, string>)

Initializes the filter using the specified dictionary of options.

Declaration
public AVResult32 Init(IDictionary<string, string> dictionary)
Parameters
Type Name Description
IDictionary<string, string> dictionary

A dictionary containing the filter options. After the method returns, the dictionary contains only the options that were not recognized by the filter.

Returns
Type Description
AVResult32

The result of the initialization operation.

Remarks

If dictionary is an AVDictionary, it is passed directly to FFmpeg. Otherwise, it is copied into a temporary AVDictionary, and the remaining unrecognized options are copied back into the original dictionary after initialization.

View Source

Init(string?)

Initializes the filter using an argument string.

Declaration
public AVResult32 Init(string? args)
Parameters
Type Name Description
string args
Returns
Type Description
AVResult32
View Source

ToString()

Returns a string that identifies the filter context.

Declaration
public override string ToString()
Returns
Type Description
string

A string containing the filter context name and filter name.

Overrides
object.ToString()

Implements

IOptionQueryable
ILoggingContext
IAVPointer<T>
IBufferSource
IBufferSink

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