Interface ICodecParameters
Defines an interface for accessing and modifying codec parameters, including audio, video, and general stream properties.
Namespace: FFmpeg.Codecs
Assembly: FFmpeg.dll
Syntax
public interface ICodecParameters
Properties
View SourceBitRate
Gets or sets the target bit rate in bits per second for the codec.
Declaration
int BitRate { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
BitsPerCodedSample
Gets or sets the number of bits per coded sample.
Declaration
int BitsPerCodedSample { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
BitsPerRawSample
Gets or sets the number of bits per raw (uncoded) sample.
Declaration
int BitsPerRawSample { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
BlockAlign
Gets or sets the block alignment (in bytes) for audio data.
Declaration
int BlockAlign { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
ChannelLayout
Gets or sets the channel layout, which defines the spatial arrangement of audio channels (e.g., mono, stereo, 5.1 surround).
Declaration
ChannelLayout ChannelLayout { get; set; }
Property Value
| Type | Description |
|---|---|
| ChannelLayout |
Remarks
The channel layout determines how audio channels are positioned and should match the number of channels and the codec in use.
Channels
Gets the number of audio channels for the current codec parameters.
Declaration
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 sample location for video data.
Declaration
ChromaLocation ChromaLocation { get; set; }
Property Value
| Type | Description |
|---|---|
| ChromaLocation |
CodecId
Gets or sets the codec identifier specifying the codec type (e.g., H264, AAC).
Declaration
CodecID CodecId { get; set; }
Property Value
| Type | Description |
|---|---|
| CodecID |
CodecTag
Gets or sets the codec tag, a four-character code or integer identifying the codec.
Declaration
FourCC CodecTag { get; set; }
Property Value
| Type | Description |
|---|---|
| FourCC |
ColorPrimaries
Gets or sets the color primaries used for color interpretation in video streams.
Declaration
ColorPrimaries ColorPrimaries { get; set; }
Property Value
| Type | Description |
|---|---|
| ColorPrimaries |
ColorRange
Gets or sets the color range (e.g., limited or full) for video data.
Declaration
ColorRange ColorRange { get; set; }
Property Value
| Type | Description |
|---|---|
| ColorRange |
ColorSpace
Gets or sets the color space for video data.
Declaration
ColorSpace ColorSpace { get; set; }
Property Value
| Type | Description |
|---|---|
| ColorSpace |
ColorTransferCharacteristic
Gets or sets the color transfer characteristic for video data.
Declaration
ColorTransferCharacteristic ColorTransferCharacteristic { get; set; }
Property Value
| Type | Description |
|---|---|
| ColorTransferCharacteristic |
ExtraData
Gets a span containing codec-specific extra data, such as headers or tables.
Declaration
Span<byte> ExtraData { get; }
Property Value
| Type | Description |
|---|---|
| Span<byte> |
FieldOrder
Gets or sets the field order for interlaced video (e.g., top field first).
Declaration
FieldOrder FieldOrder { get; set; }
Property Value
| Type | Description |
|---|---|
| FieldOrder |
FrameRate
Gets or sets the frame rate for video streams.
Declaration
Rational FrameRate { get; set; }
Property Value
| Type | Description |
|---|---|
| Rational |
FrameSize
Gets or sets the frame size, such as the number of audio samples per frame.
Declaration
int FrameSize { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Height
Gets or sets the height of the video frame in pixels.
Declaration
int Height { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
InitialPadding
Gets or sets the initial padding for audio data, in samples.
Declaration
int InitialPadding { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Level
Gets or sets the codec level, which may indicate the complexity or feature set.
Declaration
int Level { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
MediaType
Gets or sets the media type (e.g., audio, video, subtitle) for the stream.
Declaration
MediaType MediaType { get; set; }
Property Value
| Type | Description |
|---|---|
| MediaType |
PixelFormat
Gets or sets the pixel format, which specifies how video frames are stored and processed.
Declaration
PixelFormat PixelFormat { get; set; }
Property Value
| Type | Description |
|---|---|
| PixelFormat |
Remarks
Ensure the assigned value is compatible with the codec and video stream.
Profile
Gets or sets the codec profile, which defines the feature set and restrictions for the codec.
Declaration
Profile Profile { get; set; }
Property Value
| Type | Description |
|---|---|
| Profile |
SampleAspectRatio
Gets or sets the sample aspect ratio for video frames.
Declaration
Rational SampleAspectRatio { get; set; }
Property Value
| Type | Description |
|---|---|
| Rational |
SampleFormat
Gets or sets the sample format, which specifies how audio samples are stored and processed.
Declaration
SampleFormat SampleFormat { get; set; }
Property Value
| Type | Description |
|---|---|
| SampleFormat |
Remarks
Ensure the assigned value is compatible with the codec and audio stream.
SampleRate
Gets or sets the audio sample rate in Hz.
Declaration
int SampleRate { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
SeekPreroll
Gets or sets the seek preroll, which is the number of samples to discard before playback starts.
Declaration
int SeekPreroll { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
TrailingPadding
Gets or sets the trailing padding for audio data, in samples.
Declaration
int TrailingPadding { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
VideoDelay
Gets or sets the video delay, which is the number of frames of delay for video decoding.
Declaration
int VideoDelay { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Width
Gets or sets the width of the video frame in pixels.
Declaration
int Width { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
View SourceCopyFrom(CodecContext)
Copies all codec parameters from a CodecContext instance.
Declaration
void CopyFrom(CodecContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| CodecContext | context | The source codec context to copy from. |
CopyFrom(ICodecParameters)
Copies all codec parameters from another ICodecParameters instance.
Declaration
void CopyFrom(ICodecParameters other)
Parameters
| Type | Name | Description |
|---|---|---|
| ICodecParameters | other | The source codec parameters to copy from. |
CopyTo(CodecContext)
Copies all codec parameters to a CodecContext instance.
Declaration
void CopyTo(CodecContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| CodecContext | context | The destination codec context to copy to. |
GetAudioFrameDuration(int)
Calculates the duration of an audio frame based on the number of bytes in the frame.
Declaration
int GetAudioFrameDuration(int frameBytes)
Parameters
| Type | Name | Description |
|---|---|---|
| int | frameBytes | The number of bytes in the audio frame. |
Returns
| Type | Description |
|---|---|
| int | The duration of the frame in samples. |
SetExtraData(ReadOnlySpan<byte>)
Sets the codec-specific extra data from the provided byte span.
Declaration
void SetExtraData(ReadOnlySpan<byte> data)
Parameters
| Type | Name | Description |
|---|---|---|
| ReadOnlySpan<byte> | data | A read-only span containing the extra data to set. |