Class AudioBufferSource
Represents an audio buffer source filter that supplies audio frames to a filter graph.
Inherited Members
Namespace: FFmpeg.Filters.AudioFilters
Assembly: FFmpeg.dll
Syntax
public class AudioBufferSource : FilterContext, IOptionQueryable, ILoggingContext, IAVPointer<_AVFilterContext>, IBufferSink, IBufferSource
Remarks
An AudioBufferSource is the entry point for audio frames into a filter graph. The source can be configured using explicit audio parameters, BufferSrcParameters, a CodecContext, or an AVStream.
Properties
View SourceChannelLayout
Gets or sets the channel layout of the audio source.
Declaration
public ChannelLayout? ChannelLayout { get; set; }
Property Value
| Type | Description |
|---|---|
| ChannelLayout | The channel layout of the source. |
Channels
Gets or sets the number of audio channels of the source.
Declaration
public int Channels { get; set; }
Property Value
| Type | Description |
|---|---|
| int | The number of audio channels, or |
SampleFormat
Gets or sets the sample format of the audio source.
Declaration
public SampleFormat SampleFormat { get; set; }
Property Value
| Type | Description |
|---|---|
| SampleFormat | The sample format, or None if the option could not be read. |
SampleRate
Gets or sets the sample rate of the audio source.
Declaration
public int SampleRate { get; set; }
Property Value
| Type | Description |
|---|---|
| int | The sample rate in samples per second, or |
TimeBase
Gets or sets the time base of the audio source.
Declaration
public Rational TimeBase { get; set; }
Property Value
| Type | Description |
|---|---|
| Rational | The time base used for timestamps of audio frames submitted to the source, or NaN if the option could not be read. |
Methods
View SourceAllocate(string, FilterGraph)
Allocates an uninitialized audio buffer source filter.
Declaration
public static AudioBufferSource 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 |
|---|---|
| AudioBufferSource | The allocated, uninitialized audio buffer source filter. |
Exceptions
| Type | Condition |
|---|---|
| FFmpegException | The filter could not be allocated. |
Create(string, CodecContext, FilterGraph)
Creates and initializes an audio buffer source filter using the settings from a codec context.
Declaration
public static AudioBufferSource Create(string name, CodecContext ctx, FilterGraph graph)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the filter instance. |
| CodecContext | ctx | The codec context whose audio parameters are used to configure the filter. |
| FilterGraph | graph | The filter graph that will own the filter. |
Returns
| Type | Description |
|---|---|
| AudioBufferSource | The initialized audio buffer source filter. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException |
|
| FFmpegException | The filter could not be allocated, configured, or initialized. |
Create(string, BufferSrcParameters, FilterGraph)
Creates and initializes an audio buffer source filter using the specified buffer source parameters.
Declaration
public static AudioBufferSource Create(string name, BufferSrcParameters parameters, FilterGraph graph)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the filter instance. |
| BufferSrcParameters | parameters | The parameters used to configure the audio buffer source. |
| FilterGraph | graph | The filter graph that will own the filter. |
Returns
| Type | Description |
|---|---|
| AudioBufferSource | The initialized audio buffer source filter. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException |
|
| FFmpegException | The filter could not be configured or initialized. |
Create(string, AVStream, FilterGraph)
Creates and initializes an audio buffer source filter using the settings from an audio stream.
Declaration
public static AudioBufferSource Create(string name, AVStream stream, FilterGraph graph)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the filter instance. |
| AVStream | stream | The audio stream whose parameters are used to configure the filter. |
| FilterGraph | graph | The filter graph that will own the filter. |
Returns
| Type | Description |
|---|---|
| AudioBufferSource | The initialized audio buffer source filter. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException |
|
| FFmpegException | The filter could not be allocated, configured, or initialized. |
Create(string, int, SampleFormat, ChannelLayout, FilterGraph)
Creates and initializes an audio buffer source filter using the specified audio format and channel layout.
Declaration
public static AudioBufferSource Create(string name, int sampleRate, SampleFormat sampleFormat, ChannelLayout channelLayout, FilterGraph graph)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the filter instance. |
| int | sampleRate | The sample rate, in samples per second. |
| SampleFormat | sampleFormat | The sample format. |
| ChannelLayout | channelLayout | The channel layout of the audio stream. |
| FilterGraph | graph | The filter graph that will own the filter. |
Returns
| Type | Description |
|---|---|
| AudioBufferSource | The initialized audio buffer source filter. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
| FFmpegException | The filter could not be configured or initialized. |
Create(string, int, SampleFormat, int, FilterGraph)
Creates and initializes an audio buffer source filter using the specified audio format.
Declaration
public static AudioBufferSource Create(string name, int sampleRate, SampleFormat sampleFormat, int channels, FilterGraph graph)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the filter instance. |
| int | sampleRate | The sample rate, in samples per second. |
| SampleFormat | sampleFormat | The sample format. |
| int | channels | The number of audio channels. |
| FilterGraph | graph | The filter graph that will own the filter. |
Returns
| Type | Description |
|---|---|
| AudioBufferSource | The initialized audio buffer source filter. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|
| FFmpegException | The filter could not be configured or initialized. |
Drain()
Signals end-of-stream to the audio buffer source filter.
Declaration
public AVResult32 Drain()
Returns
| Type | Description |
|---|---|
| AVResult32 | The result returned by FFmpeg. |
Remarks
After end-of-stream has been signaled, no further frames can be submitted to the source filter.
SendFrame(AVFrame?, bool)
Sends an audio frame to the buffer source filter.
Declaration
public AVResult32 SendFrame(AVFrame? frame, bool keepRef = false)
Parameters
| Type | Name | Description |
|---|---|---|
| AVFrame | frame | The audio frame to send, or null to signal end-of-stream. |
| bool | keepRef | true to retain a reference to the supplied frame; false to allow FFmpeg to take ownership of the frame when possible. |
Returns
| Type | Description |
|---|---|
| AVResult32 | The result returned by FFmpeg. |
Remarks
When keepRef is true, FFmpeg creates
a new reference to the supplied frame. When it is false,
ownership of the frame may be transferred to the filter.
SetBufferSourceParameters(BufferSrcParameters)
Sets the parameters of the audio buffer source filter.
Declaration
public AVResult32 SetBufferSourceParameters(BufferSrcParameters parameters)
Parameters
| Type | Name | Description |
|---|---|---|
| BufferSrcParameters | parameters | The buffer source parameters to apply. |
Returns
| Type | Description |
|---|---|
| AVResult32 | The result returned by FFmpeg. |
Remarks
This method must be called before the filter is initialized.
ToString()
Returns a string representation of the audio format.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | A string containing the sample rate, channel count, and sample format. |