AVPacket(avcodec.h)

AVPacket

AVPacket是存储压缩编码数据相关信息的结构体。

typedef struct AVPacket {
    /**
     * 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.
     */
    struct {
        uint8_t *data;
        int      size;
        enum AVPacketSideDataType type;
    } *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;
    void  (*destruct)(struct AVPacket *);
    void  *priv;
    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;

pts 表示该帧的呈现时间戳(Presentation Timestamp),以AVStream->time_base为单位。即解压后的帧将呈现给用户的时间。如果不在文件中存储,则可以是AV_NOPTS_VALUE。

dts:表示该帧的解压时间戳(Decompression Timestamp),以AVStream->time_base为单位。即该帧解压的时间。如果不在文件中存储,则可以是AV_NOPTS_VALUE。

data:指向数据缓冲区的指针。

size:数据缓冲区的大小。

stream_index:表示该帧所属的流在AVFormatContext中的索引。

flags:标志位的组合,表示AV_pKT_FLAG的值。

side_data:(AVPacketSideData结构体指针数组):指向可以由容器提供的附加包数据的指针数组。

duration:以AVStream->time_base为单位的该帧的持续时间。如果未知,则为0。

destruct:指向一个函数的指针,用于销毁AVPacket。

priv:私有数据指针。

pos:该帧在流中的字节位置,如果未知则为-1.

convergence_duration:表示从该帧的pts到解码器输出收敛的时间差。用AVStream->time_base单位表示。如果未知,则为AV_NOPTS_VALUE。这个字段在没有传统关键帧的流中进行定位非常重要。

posted @ 2024-03-09 17:55  不会笑的孩子  阅读(158)  评论(0)    收藏  举报