Show / Hide Table of Contents

Class CodecParameters

A managed wrapper around the unmanaged FFmpeg _AVCodecParameters structure, providing safe access to codec parameters.

Inheritance
object
CodecParameters
Implements
IDisposable
ICodecParameters
Inherited Members
object.GetType()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: FFmpeg.Codecs
Assembly: FFmpeg.dll
Syntax
public sealed class CodecParameters : IDisposable, ICodecParameters

Constructors

View Source

CodecParameters()

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 Source

AlphaMode

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.

View Source

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
View Source

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
View Source

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
View Source

BlockAlign

Gets or sets the number of bytes per coded audio frame.

Declaration
public int BlockAlign { get; set; }
Property Value
Type Description
int
View Source

ChannelLayout

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

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.

View Source

ChromaLocation

Gets or sets the chroma location in the video.

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

CodecId

Gets or sets the specific codec ID used for the encoded data.

Declaration
public CodecID CodecId { get; set; }
Property Value
Type Description
CodecID
View Source

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
View Source

ColorPrimaries

Gets or sets the color primaries of the video.

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

ColorRange

Gets or sets the color range of the video.

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

ColorSpace

Gets or sets the color space of the video.

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

ColorTransferCharacteristic

Gets or sets the color transfer characteristic of the video.

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

ExtraData

Gets the extra binary data needed for initializing the decoder.

Declaration
public Span<byte> ExtraData { get; }
Property Value
Type Description
Span<byte>
View Source

FieldOrder

Gets or sets the order of the fields in interlaced video.

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

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
View Source

FrameSize

Gets or sets the number of audio samples per frame, if known.

Declaration
public int FrameSize { get; set; }
Property Value
Type Description
int
View Source

Height

Gets or sets the height of the video frame in pixels.

Declaration
public int Height { get; set; }
Property Value
Type Description
int
View Source

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
View Source

Level

Gets or sets the codec-specific level.

Declaration
public int Level { get; set; }
Property Value
Type Description
int
View Source

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
View Source

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.

View Source

Profile

Gets or sets the codec-specific profile.

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

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
View Source

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.

View Source

SampleRate

Gets or sets the audio sample rate (number of samples per second).

Declaration
public int SampleRate { get; set; }
Property Value
Type Description
int
View Source

SeekPreroll

Gets or sets the number of samples to skip after a discontinuity.

Declaration
public int SeekPreroll { get; set; }
Property Value
Type Description
int
View Source

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
View Source

VideoDelay

Gets or sets the number of frames to delay video frames.

Declaration
public int VideoDelay { get; set; }
Property Value
Type Description
int
View Source

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 Source

CopyFrom(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 other is null.

ApplicationException

Thrown if copying fails.

View Source

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 other is null.

ApplicationException

Thrown if copying fails.

View Source

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 other is null.

ApplicationException

Thrown if copying fails.

View Source

Dispose()

Frees the _AVCodecParameters instance and everything associated with it.

Declaration
public void Dispose()
View Source

~CodecParameters()

Finalizer for the CodecParameters class. Ensures resources are freed when the object is garbage collected.

Declaration
protected ~CodecParameters()
View Source

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.

View Source

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.

Implements

IDisposable
ICodecParameters
  • View Source
In this article
Back to top Generated by DocFX