Class VideoBufferSource
Represents a video buffer source filter that supplies video frames to a filter graph.
Inherited Members
Namespace: FFmpeg.Filters.VideoFilters
Assembly: FFmpeg.dll
Syntax
public class VideoBufferSource : FilterContext, IOptionQueryable, ILoggingContext, IAVPointer<_AVFilterContext>, IBufferSink, IBufferSource
Remarks
A VideoBufferSource is the entry point for video frames into a filter graph. It can be configured using explicit video parameters, BufferSrcParameters, a CodecContext, or an AVStream.
Properties
View SourceAlphaMode
Gets or sets the alpha mode of the video frames.
Declaration
public AlphaMode AlphaMode { get; set; }
Property Value
| Type | Description |
|---|---|
| AlphaMode | The alpha mode, or Unspecified if the option could not be read. |
ColorRange
Gets or sets the color range of the video frames.
Declaration
public ColorRange ColorRange { get; set; }
Property Value
| Type | Description |
|---|---|
| ColorRange | The color range, or Unspecified if the option could not be read. |
ColorSpace
Gets or sets the color space of the video frames.
Declaration
public ColorSpace ColorSpace { get; set; }
Property Value
| Type | Description |
|---|---|
| ColorSpace | The color space, or Unspecified if the option could not be read. |
FrameRate
Gets or sets the frame rate of the video source.
Declaration
public Rational FrameRate { get; set; }
Property Value
| Type | Description |
|---|---|
| Rational | The frame rate of the video source. |
Height
Gets or sets the height of the video frames in pixels.
Declaration
public int Height { get; set; }
Property Value
| Type | Description |
|---|---|
| int | The frame height in pixels, or |
PixelAspectRation
Gets or sets the sample aspect ratio of the video frames.
Declaration
public Rational PixelAspectRation { get; set; }
Property Value
| Type | Description |
|---|---|
| Rational | The sample aspect ratio of the video frames. |
PixelFormat
Gets or sets the pixel format of the video frames accepted by the source filter.
Declaration
public PixelFormat PixelFormat { get; set; }
Property Value
| Type | Description |
|---|---|
| PixelFormat | The pixel format, or None if the option could not be read. |
Size
Gets or sets the dimensions of the video frames.
Declaration
public (int Width, int Height) Size { get; set; }
Property Value
| Type | Description |
|---|---|
| (int Width, int Height) | A tuple containing the width and height of the video frames. |
TimeBase
Gets or sets the time base of the video frames.
Declaration
public Rational TimeBase { get; set; }
Property Value
| Type | Description |
|---|---|
| Rational | The time base used for timestamps of frames submitted to the source. |
Width
Gets or sets the width of the video frames in pixels.
Declaration
public int Width { get; set; }
Property Value
| Type | Description |
|---|---|
| int | The frame width in pixels, or |
Methods
View SourceAllocate(string, FilterGraph)
Allocates an uninitialized video buffer source filter.
Declaration
public static VideoBufferSource 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 |
|---|---|
| VideoBufferSource | The allocated, uninitialized video buffer source filter. |
Remarks
The returned filter has not been initialized. Configure its options or properties as required and call Init() before using it in the filter graph.
Exceptions
| Type | Condition |
|---|---|
| FFmpegException | The filter could not be allocated. |
Create(string, CodecContext, FilterGraph)
Creates and initializes a video buffer source filter from a codec context.
Declaration
public static VideoBufferSource Create(string name, CodecContext ctx, FilterGraph graph)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the filter instance. |
| CodecContext | ctx | The codec context containing the video format parameters. |
| FilterGraph | graph | The filter graph that will own the filter. |
Returns
| Type | Description |
|---|---|
| VideoBufferSource | The initialized video buffer source filter. |
Remarks
The source is configured from the codec context's video properties, including its dimensions, pixel format, time base, frame rate, color information, alpha mode, and pixel aspect ratio.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException |
|
| FFmpegException | The filter could not be allocated, configured, or initialized. |
Create(string, BufferSrcParameters, FilterGraph)
Creates and initializes a video buffer source filter from the specified buffer source parameters.
Declaration
public static VideoBufferSource Create(string name, BufferSrcParameters parameters, FilterGraph graph)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the filter instance. |
| BufferSrcParameters | parameters | The parameters describing the video source. |
| FilterGraph | graph | The filter graph that will own the filter. |
Returns
| Type | Description |
|---|---|
| VideoBufferSource | The initialized video buffer source filter. |
Remarks
The supplied parameters must describe a video source. Audio parameters are rejected because this class represents a video buffer source.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException |
|
| FFmpegException | The filter could not be configured or initialized. |
Create(string, AVStream, FilterGraph)
Creates and initializes a video buffer source filter from an input stream.
Declaration
public static VideoBufferSource Create(string name, AVStream stream, FilterGraph graph)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the filter instance. |
| AVStream | stream | The input stream containing the video format parameters. |
| FilterGraph | graph | The filter graph that will own the filter. |
Returns
| Type | Description |
|---|---|
| VideoBufferSource | The initialized video buffer source filter. |
Remarks
The source is configured from the stream's codec parameters and timing information.
Exceptions
| Type | Condition |
|---|---|
| ArgumentException |
|
| FFmpegException | The filter could not be allocated, configured, or initialized. |
Create(string, int, int, PixelFormat, Rational, FilterGraph)
Creates and initializes a video buffer source filter using the specified video format.
Declaration
public static VideoBufferSource Create(string name, int width, int height, PixelFormat format, Rational timeBase, FilterGraph graph)
Parameters
| Type | Name | Description |
|---|---|---|
| string | name | The name of the filter instance. |
| int | width | The width of the video frames, in pixels. |
| int | height | The height of the video frames, in pixels. |
| PixelFormat | format | The pixel format of the video frames. |
| Rational | timeBase | The time base of the input video stream. |
| FilterGraph | graph | The filter graph that will own the filter. |
Returns
| Type | Description |
|---|---|
| VideoBufferSource | The initialized video buffer source filter. |
Remarks
Unlike Allocate(string, FilterGraph), this method initializes the filter before returning it, leaving it ready to receive frames.
Exceptions
| Type | Condition |
|---|---|
| FFmpegException | The filter could not be configured or initialized. |
Drain()
Signals end-of-stream to the video 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 a frame to the video buffer source filter.
Declaration
public AVResult32 SendFrame(AVFrame? frame, bool keepRef = false)
Parameters
| Type | Name | Description |
|---|---|---|
| AVFrame | frame | The 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 a 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 of the operation. |
ToString()
Returns a string representation of the video format.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | A string containing the video dimensions and pixel format. |