AVPacket
public final class AVPacket
This structure stores compressed data. It is typically exported by demuxers and then passed as input to decoders, or received as output from encoders and then passed to muxers.
For video, it should typically contain one compressed frame. For audio it may contain several compressed frames. Encoders are allowed to output empty packets, with no compressed data, containing only side data (e.g. to update some stream parameters at the end of encoding).
The semantics of data ownership depends on the buffer field.
If it is set, the packet data is dynamically allocated and is valid indefinitely
until a call to unref() reduces the reference count to 0.
If the buffer field is not set, ref(from:) would make a copy instead of increasing the reference count.
The side data is always allocated with AVIO.malloc(size:), copied by ref(from:) and freed unref().
-
Create an
AVPacketand set its fields to default values.Note
This only allocates theAVPacketitself, not the data buffers. Those must be allocated through other means such asav_new_packet.Declaration
Swift
public init() -
A reference to the reference-counted buffer where the packet data is stored. May be
nil, then the packet data is not reference-counted.Declaration
Swift
public var buffer: AVBuffer? { get set } -
Presentation timestamp in
AVStream.timebaseunits; the time at which the decompressed packet will be presented to the user.Can be
AVTimestamp.noPTSif it is not stored in the file.Declaration
Swift
public var pts: Int64 { get set } -
Decompression timestamp in
AVStream.timebaseunits; the time at which the packet is decompressed.Can be
AVTimestamp.noPTSif it is not stored in the file.Declaration
Swift
public var dts: Int64 { get set } -
Undocumented
Declaration
Swift
public var data: UnsafeMutablePointer<UInt8>? { get set } -
Undocumented
Declaration
Swift
public var size: Int { get set } -
Undocumented
Declaration
Swift
public var streamIndex: Int { get set } -
Undocumented
Declaration
Swift
public var flags: Flag { get set } -
Duration of this packet in
AVStream.timebaseunits, 0 if unknown. Equalsnext_pts - this_ptsin presentation order.Declaration
Swift
public var duration: Int64 { get set } -
Byte position in stream, -1 if unknown.
Declaration
Swift
public var position: Int64 { get set } -
Convert valid timing fields (timestamps / durations) in a packet from one timebase to another. Timestamps with unknown values (
AVTimestamp.noPTS) will be ignored.Declaration
Swift
public func rescaleTimestamp(from src: AVRational, to dst: AVRational)Parameters
srcsource timebase, in which the timing fields in pkt are expressed.
dstdestination timebase, to which the timing fields will be converted.
-
Setup a new reference to the data described by a given packet.
If src is reference-counted, setup dst as a new reference to the buffer in src. Otherwise allocate a new buffer in dst and copy the data from src into it.
All the other fields are copied from src.
Throws
AVerrorDeclaration
Swift
public func ref(from src: AVPacket) throwsParameters
srcthe source packet
-
Wipe the packet.
Unreference the buffer referenced by the packet and reset the remaining packet fields to their default values.
Declaration
Swift
public func unref() -
Move every field in src to dst and reset src.
Declaration
Swift
public func moveRef(from src: AVPacket)Parameters
srcthe source packet
-
Create a new packet that references the same data as src.
This is a shortcut for
init() + ref(from:).Declaration
Swift
public func clone() -> AVPacket?Return Value
newly created
AVPacketon success,nilon error. -
Create a writable reference for the data described by a given packet, avoiding data copy if possible.
Throws
AVErrorDeclaration
Swift
public func makeWritable() throws
-
Undocumented
See moreDeclaration
Swift
public struct Flag : OptionSet
View on GitHub
Install in Dash
AVPacket Class Reference