Struct AVPacket_ref
Managed wrapper for the FFmpeg FFmpeg.AutoGen._AVPacket structure. Provides managed access to packet data, timestamps, and operations for video and audio streaming.
Inherited Members
Namespace: FFmpeg.Utils
Assembly: FFmpeg.dll
Syntax
public readonly struct AVPacket_ref : IPacket, IAVPointer<_AVPacket>, IReference<AVPacket>
Properties
View SourceData
Declaration
public Span<byte> Data { get; }
Property Value
| Type | Description |
|---|---|
| Span<byte> |
DecompressionTime
Gets or sets the decompression timestamp (DTS) as a TimeSpan. The DecompressionTimestamp is calculated using the TimeBase.
Declaration
public TimeSpan DecompressionTime { get; set; }
Property Value
| Type | Description |
|---|---|
| TimeSpan |
DecompressionTimestamp
Gets or sets the decompression timestamp (DTS) of the packet, in stream time base units. This timestamp indicates when the packet should be decompressed.
Declaration
public long DecompressionTimestamp { get; set; }
Property Value
| Type | Description |
|---|---|
| long |
Duration
Gets or sets the duration of the packet in stream time base units.
Declaration
public long Duration { get; set; }
Property Value
| Type | Description |
|---|---|
| long |
Flags
Gets or sets the packet flags, which are a combination of PacketFlags values. These flags indicate specific characteristics of the packet (e.g., key frame, corrupted data).
Declaration
public PacketFlags Flags { get; set; }
Property Value
| Type | Description |
|---|---|
| PacketFlags |
Position
Gets or sets the byte position of the packet in the stream.
Declaration
public long Position { get; set; }
Property Value
| Type | Description |
|---|---|
| long |
PresentationTime
Gets or sets the presentation timestamp (PTS) as a TimeSpan. The PresentationTimestamp is calculated using the TimeBase.
Declaration
public TimeSpan PresentationTime { get; set; }
Property Value
| Type | Description |
|---|---|
| TimeSpan |
PresentationTimestamp
Gets or sets the presentation timestamp (PTS) of the packet, in stream time base units. This timestamp indicates when the packet should be presented to the user.
Declaration
public long PresentationTimestamp { get; set; }
Property Value
| Type | Description |
|---|---|
| long |
Size
Gets or sets the size of the packet's data in bytes.
Declaration
public int Size { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
StreamIndex
Gets or sets the index of the stream this packet belongs to.
Declaration
public int StreamIndex { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
TimeBase
Gets or sets the time base used for the packet's timestamps, represented as a Rational value. This value defines the unit of time for the PresentationTimestamp and DecompressionTimestamp.
Declaration
public Rational TimeBase { get; set; }
Property Value
| Type | Description |
|---|---|
| Rational |
Methods
View SourceClone()
Creates a new AVPacket that references the same data as this packet. This creates a shallow copy, meaning the new packet will point to the same underlying data buffer.
Declaration
public AVPacket Clone()
Returns
| Type | Description |
|---|---|
| AVPacket | A new AVPacket instance that references the same data. |
Exceptions
| Type | Condition |
|---|---|
| OutOfMemoryException | Thrown when the clone operation fails due to insufficient memory allocation. |
CloneTo(IPacket)
Clones the contents of this packet to the specified IPacket destination. This creates a deep copy of the packet, including its data and properties.
Declaration
public void CloneTo(IPacket dst)
Parameters
| Type | Name | Description |
|---|---|---|
| IPacket | dst | The destination packet to clone the data to. |
CopyProperties(IPacket)
Copies the properties of this packet, such as stream index and timestamps, to the specified IPacket destination without copying the actual data.
Declaration
public void CopyProperties(IPacket dst)
Parameters
| Type | Name | Description |
|---|---|---|
| IPacket | dst | The destination packet to copy the properties to. |
GetReferencedObject()
Gets the object currently being referenced. Or a copy if the type is nor reference counted.
Declaration
public AVPacket? GetReferencedObject()
Returns
| Type | Description |
|---|---|
| AVPacket | The referenced object of type AVPacket if available, or null if not. |
MoveTo(IPacket)
Moves the contents of this packet to the specified IPacket destination, effectively transferring ownership of the data without copying it.
Declaration
public void MoveTo(IPacket dst)
Parameters
| Type | Name | Description |
|---|---|---|
| IPacket | dst | The destination packet to move the data to. |
Resize(int)
Resizes the packet's data buffer to the specified size, either growing or shrinking it.
Declaration
public void Resize(int size)
Parameters
| Type | Name | Description |
|---|---|---|
| int | size | The new size of the packet's data buffer in bytes. |
Exceptions
| Type | Condition |
|---|---|
| OutOfMemoryException | Thrown if the packet cannot be resized due to insufficient memory during growth. |
SetReferencedObject(AVPacket?)
Sets the reference to a new object of type AVPacket or creates a copy if the type is not reference counted or unlinks the current reference.
Declaration
public void SetReferencedObject(AVPacket? packet)
Parameters
| Type | Name | Description |
|---|---|---|
| AVPacket | packet |
Unreference()
Unreferences the packet, decrementing the reference count and releasing associated resources if no references remain. This should be called when the packet is no longer needed.
Declaration
public void Unreference()