Packets

class av.packet.Packet(input=None)

Bases: Buffer

A packet of encoded data within a Stream.

This may, or may not include a complete object within a stream. decode() must be called to extract encoded data.

decode()

Send the packet’s data to the decoder and return a list of AudioFrame, VideoFrame or SubtitleSet.

dts

The decoding timestamp in time_base units for this packet.

Type:

int | None

duration

The duration in time_base units for this packet.

Returns None if it is not known.

Type:

int

get_sidedata(str dtype: str) PacketSideData

get a copy of the side data

Parameters:

dtype (str) – side data type (:method:`~av.packet.PacketSideData.sidedata_types` for the full list of options)

Returns:

newly created copy of the side data if the side data of the requested type is found in the packet, else an empty object

Return type:

PacketSideData

has_sidedata(str dtype: str) bool

True if this packet has the specified side data

Parameters:

dtype (str) – side data type

is_corrupt
is_discard
is_disposable
is_keyframe
is_trusted
iter_sidedata() Iterator[PacketSideData]

iterate over side data of this packet.

Yield:

PacketSideData object

opaque
pos

The byte position of this packet within the Stream.

Returns None if it is not known.

Type:

int | None

pts

The presentation timestamp in time_base units for this packet.

This is the time at which the packet should be shown to the user.

Type:

int | None

set_sidedata(PacketSideData sidedata: PacketSideData, bool move: cython.bint = False)

copy or move side data to this packet

Parameters:
  • sidedata (PacketSideData) – Source packet side data

  • move (bool) – If True, move the data from sidedata object, defaults to False

size

The size in bytes of this packet’s data.

Type:

int

stream

The Stream this packet was demuxed from.

stream_index
time_base

The unit of time (in fractional seconds) in which timestamps are expressed.

Type:

fractions.Fraction