// 第一步 打开文件
avio_open(&c->pb, url, AVIO_FLAG_WRITE);
// 第二步 写入头
int avformat_write_header(AVFormatContext *s, AVDictionary **options);
// 第三步 写入帧
int av_write_frame(AVFormatContext *s, AVPacket *pkt);
// 第四步 写入尾
int av_write_trailer(AVFormatContext *s);
int avio_closep(AVIOContext *s);
控制播放进度
intav_seek_frame(AVFormatContext *s,int stream_index, int64_t timestamp,int flag);/*
stream_index:
if stream_index is (-1), a default
timestamp:
Timestamp in AVStream.time_base units
flags:
#define AVSEEK_FLAG_BACKWARD 1 // seek backward
#define AVSEEK_FLAG_BYTE 2 // seeking based on position in bytes
#define AVSEEK_FLAG_ANY 4 // seek to any frame, even non-keyframes
#define AVSEEK_FLAG_FRAME 8 // seeking based on frame number
*/
重封装实战
解封装流程
设置媒体文件路径:
constchar*url ="v1080.mp4";
解封装、解封装输入上下文
AVFormatContext *ic = nullptr;auto re =avformat_open_input(&ic, url,NULL,// 封装器格式,NULL 自动探测 根据后缀名或者文件头NULL</