Class CodecParameters
A managed wrapper around the unmanaged FFmpeg _AVCodecParameters structure, providing safe access to codec parameters.
Inherited Members
Namespace: FFmpeg.Codecs
Assembly: FFmpeg.dll
Syntax
public sealed class CodecParameters : IDisposable, ICodecParameters
Constructors
View SourceCodecParameters()
Initializes a new instance of the CodecParameters class, allocating a new _AVCodecParameters structure and setting its fields to default values.
Declaration
public CodecParameters()
Exceptions
| Type | Condition |
|---|---|
| OutOfMemoryException | Thrown if the underlying _AVCodecParameters cannot be allocated. |
Properties
View SourceAlphaMode
Gets or sets how the alpha channel is represented in relation to the color components.
Declaration
public AlphaMode AlphaMode { get; set; }
Property Value
| Type | Description |
|---|---|
| AlphaMode |
Remarks
Premultiplied indicates that the color components are already multiplied by the alpha value, while Straight indicates that the alpha channel is stored independently of the color components.
BitRate
Gets or sets the average bitrate of the encoded data, in bits per second.
Declaration
public int BitRate { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
BitsPerCodedSample
Gets or sets the number of bits per coded sample in the bitstream.
Declaration
public int BitsPerCodedSample { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
BitsPerRawSample
Gets or sets the number of bits per raw sample in the output.
Declaration
public int BitsPerRawSample { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
BlockAlign
Gets or sets the number of bytes per coded audio frame.
Declaration
public int BlockAlign { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
ChannelLayout
Declaration
public ChannelLayout_ref ChannelLayout { get; }
Property Value
| Type | Description |
|---|---|
| ChannelLayout_ref |
Channels
Gets the number of audio channels for the current codec parameters.
Declaration
public int Channels { get; }
Property Value
| Type | Description |
|---|---|
| int |
Remarks
This value indicates the number of channels in the audio stream, such as 1 for mono, 2 for stereo, or higher for surround formats. The meaning is related to the ChannelLayout property.
ChromaLocation
Gets or sets the chroma location in the video.
Declaration
public ChromaLocation ChromaLocation { get; set; }
Property Value
| Type | Description |
|---|---|
| ChromaLocation |
CodecId
Gets or sets the specific codec ID used for the encoded data.
Declaration
public CodecID CodecId { get; set; }
Property Value
| Type | Description |
|---|---|
| CodecID |
CodecTag
Gets or sets the codec tag, which is additional information about the codec (corresponding to the AVI FOURCC).
Declaration
public FourCC CodecTag { get; set; }
Property Value
| Type | Description |
|---|---|
| FourCC |
ColorPrimaries
Gets or sets the color primaries of the video.
Declaration
public ColorPrimaries ColorPrimaries { get; set; }
Property Value
| Type | Description |
|---|---|
| ColorPrimaries |
ColorRange
Gets or sets the color range of the video.
Declaration
public ColorRange ColorRange { get; set; }
Property Value
| Type | Description |
|---|---|
| ColorRange |
ColorSpace
Gets or sets the color space of the video.
Declaration
public ColorSpace ColorSpace { get; set; }
Property Value
| Type | Description |
|---|---|
| ColorSpace |
ColorTransferCharacteristic
Gets or sets the color transfer characteristic of the video.
Declaration
public ColorTransferCharacteristic ColorTransferCharacteristic { get; set; }
Property Value
| Type | Description |
|---|---|
| ColorTransferCharacteristic |
ExtraData
Gets the extra binary data needed for initializing the decoder.
Declaration
public Span<byte> ExtraData { get; }
Property Value
| Type | Description |
|---|---|
| Span<byte> |
FieldOrder
Gets or sets the order of the fields in interlaced video.
Declaration
public FieldOrder FieldOrder { get; set; }
Property Value
| Type | Description |
|---|---|
| FieldOrder |
FrameRate
Gets or sets the frame rate (frames per second) for video streams with constant frame durations.
Declaration
public Rational FrameRate { get; set; }
Property Value
| Type | Description |
|---|---|
| Rational |
FrameSize
Gets or sets the number of audio samples per frame, if known.
Declaration
public int FrameSize { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Height
Gets or sets the height of the video frame in pixels.
Declaration
public int Height { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
InitialPadding
Gets or sets the amount of padding inserted by the encoder at the beginning of the audio stream.
Declaration
public int InitialPadding { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Level
Gets or sets the codec-specific level.
Declaration
public int Level { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
MediaType
Gets or sets the general type of the encoded data (e.g., video, audio).
Declaration
public MediaType MediaType { get; set; }
Property Value
| Type | Description |
|---|---|
| MediaType |
PixelFormat
Gets or sets the pixel format of the codec parameters.
Declaration
public PixelFormat PixelFormat { get; set; }
Property Value
| Type | Description |
|---|---|
| PixelFormat |
Remarks
The pixel format determines how video frames are stored and processed. Ensure that the assigned value is compatible with the codec being used.
Profile
Gets or sets the codec-specific profile.
Declaration
public Profile Profile { get; set; }
Property Value
| Type | Description |
|---|---|
| Profile |
SampleAspectRatio
Gets or sets the sample aspect ratio (width/height) of a single pixel.
Declaration
public Rational SampleAspectRatio { get; set; }
Property Value
| Type | Description |
|---|---|
| Rational |
SampleFormat
Gets or sets the sample format of the codec parameters.
Declaration
public SampleFormat SampleFormat { get; set; }
Property Value
| Type | Description |
|---|---|
| SampleFormat |
Remarks
The sample format determines how audio samples are stored and processed. Ensure that the assigned value is compatible with the codec being used.
SampleRate
Gets or sets the audio sample rate (number of samples per second).
Declaration
public int SampleRate { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
SeekPreroll
Gets or sets the number of samples to skip after a discontinuity.
Declaration
public int SeekPreroll { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
TrailingPadding
Gets or sets the amount of padding appended by the encoder at the end of the audio stream.
Declaration
public int TrailingPadding { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
VideoDelay
Gets or sets the number of frames to delay video frames.
Declaration
public int VideoDelay { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Width
Gets or sets the width of the video frame in pixels.
Declaration
public int Width { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
View SourceCopyFrom(CodecContext)
Copies the contents of a CodecContext instance to this instance.
Declaration
public void CopyFrom(CodecContext other)
Parameters
| Type | Name | Description |
|---|---|---|
| CodecContext | other | The CodecContext instance to copy from. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| ApplicationException | Thrown if copying fails. |
CopyFrom(ICodecParameters)
Copies the contents of another CodecParameters instance to this instance.
Declaration
public void CopyFrom(ICodecParameters other)
Parameters
| Type | Name | Description |
|---|---|---|
| ICodecParameters | other | The other CodecParameters instance to copy from. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| ApplicationException | Thrown if copying fails. |
CopyTo(CodecContext)
Copies the contents of this instance to a specified CodecContext instance.
Declaration
public void CopyTo(CodecContext other)
Parameters
| Type | Name | Description |
|---|---|---|
| CodecContext | other | The CodecContext instance to copy to. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
| ApplicationException | Thrown if copying fails. |
Dispose()
Frees the _AVCodecParameters instance and everything associated with it.
Declaration
public void Dispose()
~CodecParameters()
Finalizer for the CodecParameters class. Ensures resources are freed when the object is garbage collected.
Declaration
protected ~CodecParameters()
GetAudioFrameDuration(int)
Calculates the duration of an audio frame, given the frame size in bytes.
Declaration
public int GetAudioFrameDuration(int frameBytes)
Parameters
| Type | Name | Description |
|---|---|---|
| int | frameBytes | The size of the audio frame in bytes. |
Returns
| Type | Description |
|---|---|
| int | The duration of the audio frame in milliseconds. |
SetExtraData(ReadOnlySpan<byte>)
Sets the extra binary data needed for initializing the decoder.
Declaration
public void SetExtraData(ReadOnlySpan<byte> data)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<byte> | data | The extra binary data to set. |
Exceptions
| Type | Condition |
|---|---|
| OutOfMemoryException | Thrown if memory allocation fails. |