Show / Hide Table of Contents

Class AVPacket

Managed wrapper for the FFmpeg FFmpeg.AutoGen._AVPacket structure. Provides managed access to packet data, timestamps, and operations for video and audio streaming.

Inheritance
object
AVPacket
Implements
IDisposable
IPacket
IAVPointer<_AVPacket>
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: FFmpeg.Utils
Assembly: FFmpeg.dll
Syntax
public class AVPacket : IDisposable, IPacket, IAVPointer<_AVPacket>

Properties

View Source

Data

Gets the raw data contained in the packet as a Span<T> of byte.

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

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

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

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

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

Position

Gets or sets the byte position of the packet in the stream.

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

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

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

Size

Gets or sets the size of the packet's data in bytes.

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

StreamIndex

Gets or sets the index of the stream this packet belongs to.

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

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 Source

Allocate()

Allocates a new instance of the AVPacket class without specifying a payload size.

Declaration
public static AVPacket Allocate()
Returns
Type Description
AVPacket

A newly allocated AVPacket instance.

Exceptions
Type Condition
OutOfMemoryException

Thrown when memory allocation for the FFmpeg.AutoGen._AVPacket fails.

View Source

Allocate(int)

Allocates a new instance of the AVPacket class with a specified payload size.

Declaration
public static AVPacket Allocate(int size)
Parameters
Type Name Description
int size

The size of the packet's payload, in bytes.

Returns
Type Description
AVPacket

A newly allocated AVPacket instance.

Exceptions
Type Condition
OutOfMemoryException

Thrown when memory allocation fails for either the FFmpeg.AutoGen._AVPacket or its payload.

View Source

Clone()

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.

View Source

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.

View Source

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.

View Source

Dispose()

Releases the unmanaged resources used by the AVPacket and frees the allocated memory.

Declaration
public void Dispose()
View Source

~AVPacket()

Finalizer to ensure that unmanaged resources are properly released when the object is garbage collected.

Declaration
protected ~AVPacket()
View Source

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.

View Source

RescaleTS(Rational)

Rescales the timing fields (timestamps and durations) of the current packet from its current time base to a new time base.
This operation modifies the packet's timing fields to express them in the new time base.

Declaration
public void RescaleTS(Rational newTimeBase)
Parameters
Type Name Description
Rational newTimeBase

The destination time base to which the timing fields of the packet will be converted.

Remarks

If any of the packet's timestamps have unknown values (such as FFmpeg.AutoGen.ffmpeg.AV_NOPTS_VALUE), they will be ignored during the conversion. The method also updates the packet's time base to the new time base after rescaling.

View Source

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.

View Source

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()

Implements

IDisposable
IPacket
IAVPointer<T>
  • View Source
In this article
Back to top Generated by DocFX