Class AudioFormat
Represents an audio format filter that constrains the sample format, sample rate, and channel layout of audio passing through a filter graph.
Inherited Members
Namespace: FFmpeg.Filters.AudioFilters
Assembly: FFmpeg.dll
Syntax
public class AudioFormat : FilterContext, IOptionQueryable, ILoggingContext, IAVPointer<_AVFilterContext>, IBufferSource, IBufferSink
Remarks
The audio format filter does not perform a standalone conversion itself. Instead, it specifies the audio formats that are acceptable for the output of the filter, allowing FFmpeg's filter graph negotiation to select or insert the appropriate conversion when necessary.
Properties
View SourceChannelLayouts
Gets or sets the channel layouts accepted by the filter.
Declaration
public IReadOnlyList<ChannelLayout> ChannelLayouts { get; set; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<ChannelLayout> | A collection containing the accepted channel layouts. An empty collection indicates that no channel layout constraint is configured. |
SampleFormats
Gets or sets the sample formats accepted by the filter.
Declaration
public IReadOnlyList<SampleFormat> SampleFormats { get; set; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<SampleFormat> | A collection containing the accepted sample formats. An empty collection indicates that no sample format constraint is configured. |
SampleRates
Gets or sets the sample rates accepted by the filter.
Declaration
public IReadOnlyList<int> SampleRates { get; set; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<int> | A collection containing the accepted sample rates in samples per second. An empty collection indicates that no sample rate constraint is configured. |
Methods
View SourceAllocate(string, FilterGraph)
Allocates an uninitialized audio format filter.
Declaration
public static AudioFormat Allocate(string name, FilterGraph graph)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the filter instance. |
| FilterGraph | graph | The filter graph that will own the filter. |
Returns
| Type | Description |
|---|---|
| AudioFormat | The allocated, uninitialized audio format filter. |
Exceptions
| Type | Condition |
|---|---|
| FFmpegException | The filter could not be allocated. |
Create(string, SampleFormat, int, ChannelLayout, FilterGraph)
Creates and initializes an audio format filter configured for a specific sample format, sample rate, and channel layout.
Declaration
public static AudioFormat Create(string name, SampleFormat sampleFormat, int sampleRate, ChannelLayout channelLayout, FilterGraph graph)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the filter instance. |
| SampleFormat | sampleFormat | The sample format accepted by the filter. |
| int | sampleRate | The sample rate accepted by the filter, in samples per second. |
| ChannelLayout | channelLayout | The channel layout accepted by the filter. |
| FilterGraph | graph | The filter graph that will own the filter. |
Returns
| Type | Description |
|---|---|
| AudioFormat | The initialized audio format filter. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
| FFmpegException | The filter could not be configured or initialized. |
Create(string, ReadOnlySpan<SampleFormat>, ReadOnlySpan<int>, ReadOnlySpan<ChannelLayout>, FilterGraph)
Creates and initializes an audio format filter configured with one or more acceptable sample formats, sample rates, and channel layouts.
Declaration
public static AudioFormat Create(string name, ReadOnlySpan<SampleFormat> sampleFormats, ReadOnlySpan<int> sampleRates, ReadOnlySpan<ChannelLayout> channelLayouts, FilterGraph graph)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the filter instance. |
| ReadOnlySpan<SampleFormat> | sampleFormats | The sample formats accepted by the filter. An empty span leaves the sample format unconstrained. |
| ReadOnlySpan<int> | sampleRates | The sample rates accepted by the filter, in samples per second. An empty span leaves the sample rate unconstrained. |
| ReadOnlySpan<ChannelLayout> | channelLayouts | The channel layouts accepted by the filter. An empty span leaves the channel layout unconstrained. |
| FilterGraph | graph | The filter graph that will own the filter. |
Returns
| Type | Description |
|---|---|
| AudioFormat | The initialized audio format filter. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | One of the specified sample rates is less than or equal to zero. |
| FFmpegException | The filter could not be configured or initialized. |