[ffmpeg] packet
API调用
常用API
AVPacket *av_packet_alloc(void); // 构建 packet 结构体
void av_packet_free(AVPacket **pkt); // 释放 packet 结构体
void av_packet_rescale_ts(AVPacket *pkt, AVRational tb_src, AVRational tb_dst); // pts,dts,duration 基于前后时间基进行转换
结构体介绍
typedef struct AVPacket {
AVBufferRef *buf; // data 实际保存的地方,通过 ref 控制是否真的释放
int64_t pts; // 渲染时间,基于 time_base 单位,必须 pts >= dts
int64_t dts; // 解码时间,基于 time_base 单位
uint8_t *data; // 指向 buf->data
int size;
int stream_index; // 流索引,和 avformat 上下文中的 stream 对应
int flags;
AVPacketSideData *side_data;
int side_data_elems;
int64_t duration; // 渲染时间,基于 time_base 单位。等于 next_pts - this_pts
int64_t pos; // 在流中的位置
void *opaque; // 私有数据
AVBufferRef *opaque_ref;
AVRational time_base; // 时间基,视频为 1/fps
} AVPacket;
struct AVBuffer {
uint8_t *data; /**< data described by this buffer */
size_t size; /**< size of data in bytes */
atomic_uint refcount;
void (*free)(void *opaque, uint8_t *data);
void *opaque;
int flags;
int flags_internal;
};
其他
AVPacket *av_packet_alloc(void);
AVPacket *av_packet_clone(const AVPacket *src);
void av_packet_free(AVPacket **pkt);
void av_init_packet(AVPacket *pkt);
int av_new_packet(AVPacket *pkt, int size);
void av_shrink_packet(AVPacket *pkt, int size);
int av_grow_packet(AVPacket *pkt, int grow_by);
int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size);
uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, size_t size);
int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type, uint8_t *data, size_t size);
int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type, size_t size);
uint8_t* av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, size_t *size);
const char *av_packet_side_data_name(enum AVPacketSideDataType type);
uint8_t *av_packet_pack_dictionary(AVDictionary *dict, size_t *size);
int av_packet_unpack_dictionary(const uint8_t *data, size_t size, AVDictionary **dict);
void av_packet_free_side_data(AVPacket *pkt);
int av_packet_ref(AVPacket *dst, const AVPacket *src);
void av_packet_unref(AVPacket *pkt);
void av_packet_move_ref(AVPacket *dst, AVPacket *src);
int av_packet_copy_props(AVPacket *dst, const AVPacket *src);
int av_packet_make_refcounted(AVPacket *pkt);
int av_packet_make_writable(AVPacket *pkt);
void av_packet_rescale_ts(AVPacket *pkt, AVRational tb_src, AVRational tb_dst);
原文地址:https://blog.csdn.net/dss875914213/article/details/142314312
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!