ffmpeg重要结构体之AVPacket

来源:互联网 发布:有些什么直播软件 编辑:程序博客网 时间:2024/06/05 09:24

ffmpeg重要结构体之AVFrame

ffmpeg重要结构体之AVFormatContext

ffmpeg重要结构体之AVCodecContext

ffmpeg重要结构体之AVCodec

ffmpeg重要结构体之AVIOContext

ffmpeg重要结构体之AVStream

ffmpeg重要结构体之AVPacket



AVPacket是ffmpeg中有关格式信息的结构体,在文件libavcodec/avcodec.h中。

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.     */    int64_t duration;    int64_t pos;                            ///< byte position in stream, -1 if unknown#if FF_API_CONVERGENCE_DURATION    /**     * @deprecated Same as the duration field, but as int64_t. This was required     * for Matroska subtitles, whose duration values could overflow when the     * duration field was still an int.     */    attribute_deprecated    int64_t convergence_duration;#endif} AVPacket;#define AV_PKT_FLAG_KEY     0x0001 ///< The packet contains a keyframe#define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corruptedenum AVSideDataParamChangeFlags {    AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT  = 0x0001,    AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002,    AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE    = 0x0004,    AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS     = 0x0008,};
其中有关视频解码的主要成员:

AVBufferRef *buf:提供给其他参考本packet的地址。

uint8_t *data:一个packet的数据,通常为一个完整的结构,比如对于AVC,就是一个nal(可以是pps或sps或一帧图像)

int   size:packet的大小。

int64_t duration:此packet的持续时间,对于一帧数据就是这帧图像的播放时长。

int dts:解码时间戳

int pts:显示时间戳

举个例子,解码某AVC码流,time_base = 1/1000(time_base见ffmpeg重要结构体之AVStream),duration = 42

换算成秒就是42*(1/1000)=0.042秒,相当于24帧每秒。


0 0
原创粉丝点击