1.
AVPacket简介
AVPacket用于存放压缩后的数据。
通常是解复用的输出,解码的输入;或者是编码的输出,复用的输入。
对于视频数据,AVPacket通常包含一帧视频压缩数据;对于音频数据数据,AVPacket则通常包含了数帧的音频压缩数据。
其大小是public ABI的一部分,因此可以在栈上分配。
其数据有效期取决于“buf”或“destruct”,如果字段设置了,数据包的管理由ffmpeg负责,数据包在avt_free_packet(内部调用avt_buffer_unref)调用前都有效;如果字段未设置,数据包由调用者管理。
2. AVPacket定义
-
typedef struct AVPacket {
-
/**
-
* A reference to the reference-counted buffer where the packet data is
-
* stored.
-
* May be NULL, then the packet data is not reference-counted.
-
*/
-
AVBufferRef* buf;
-
/**
-
* Presentation timestamp in AVStream->time_base units; the time at which
-
* the decompressed packet will be presented to the user.
-
* Can be AV_NOPTS_VALUE if it is not stored in the file.
-
* pts MUST be larger or equal to dts as presentation cannot happen before
-
* decompression, unless one wants to view hex dumps. Some formats misuse
-
* the terms dts and pts/cts to mean something different. Such timestamps
-
* must be converted to true pts/dts before they are stored in AVPacket.
-
*/
-
int64_t pts;
-
/**
-
* Decompression timestamp in AVStream->time_base units; the time at which
-
* the packet is decompressed.
-
* Can be AV_NOPTS_VALUE if it is not stored in the file.
-
*/
-
int64_t dts;
-
uint8_t* data;
-
int size;
-
int stream_index;
-
/**
-
* A combination of AV_PKT_FLAG values
-
*/
-
int flags;
-
/**
-
* Additional packet data that can be provided by the container.
-
* Packet can contain several types of side information.
-
*/
-
AVPacketSideData* side_data;
-
int side_data_elems;
-
-
/**
-
* Duration of this packet in AVStream->time_base units, 0 if unknown.
-
* Equals next_pts - this_pts in presentation order.
-
*/
-
int duration;
-
#if FF_API_DESTRUCT_PACKET
-
attribute_deprecated
-
void (*destruct)(struct AVPacket *);
-
attribute_deprecated
-
void* priv;
-
#endif
-
int64_t pos; ///< byte position in stream, -1 if unknown
-
-
/**
-
* Time difference in AVStream->time_base units from the pts of this
-
* packet to the point at which the output from the decoder has converged
-
* independent from the availability of previous frames. That is, the
-
* frames are virtually identical no matter if decoding started from
-
* the very first frame or from this keyframe.
-
* Is AV_NOPTS_VALUE if unknown.
-
* This field is not the display duration of the current packet.
-
* This field has no meaning if the packet does not have AV_PKT_FLAG_KEY
-
* set.
-
*
-
* The purpose of this field is to allow seeking in streams that have no
-
* keyframes in the conventional sense. It corresponds to the
-
* recovery point SEI in H.264 and match_time_delta in NUT. It is also
-
* essential for some types of subtitle streams to ensure that all
-
* subtitles are correctly displayed after seeking.
-
*/
-
int64_t convergence_duration;
-
} AVPacket;
3.
AVPacket字段说明
AVBufferRef* buf : data的引用计数结构体,可能为NULL。不为NULL时,数据管理由ffmpeg负责,为NULL时由调用者自己负责。
int64_t pts : 压缩数据显示时间戳。比较关键的数据,在做seek和播放进度的时候都要用到它,pts只是一个数量,对应于AVStream->time_base,要根据time_base才能转换为具体的时间,音频和视频一般有不同的time_base,所以在做音视频同步一定要做转换,不能直接拿pts做。
int64_t dts : 压缩数据解码时间戳。
uint8_t* data :压缩数据。
int size :压缩数据大小。
int stream_index :所属媒体流的索引。用来区分音频,视频,和字幕数据。
int flags : 标识域。其中为1表示该数据是一个关键帧,AV_PKT_FLAG_KEY 0x0001 关键帧
AVPacketSideData* side_data :附加数据。
int side_data_elems :附加数据大小。
int duration :压缩数据时长。
void (*destruct)(struct AVPacket *) :压缩数据释放函数指针。
void* priv :
int64_t pos :压缩数据在媒体流中的偏移量,未知为-1。
int64_t convergence_duration :
阅读(3147) | 评论(0) | 转发(0) |