AVFormatContext: 用来存储视音频封装格式(flv,mp4,rmvb,avi)中包含的全部信息 不少函数都要用到它做为参数。ide
AVFormatContext结构体以下所示(显示部分红员,后续深刻添加):函数
typedef struct AVFormatContext {
const AVClass *av_class; //包含AVCodecContext, AVFormatContext
/**
* The input container format.
*
* Demuxing only, set by avformat_open_input().
*/
ff_const59 struct AVInputFormat *iformat; //AVInputFormat:封装格式(flv、mkv、avi等),调用avformat_open_input()时,该成员就会被初始化
ff_const59 struct AVOutputFormat *oformat; //输入的封装格式(生成视频),调用avformat_write_header()时,该成员就会被初始化
unsigned int nb_streams; //AVFormatContext中的流个数,通常为2,若是要设置,则只能经过avformat_new_stream()来设置
AVStream **streams; //输入视频的AVStream流数组,经过avformat_open_input()来初始化流信息
#if FF_API_FORMAT_FILENAME
attribute_deprecated
char filename[1024]; //输入输出文件名路径,经过avformat_open_input()和avformat_write_header()来设置
#endif
char *url; //输入或输出URL,与filename字段不一样,此字段没有长度限制。经过avformat_open_input()和avformat_write_header()来设置
/**
* Position of the first frame of the component, in
* AV_TIME_BASE fractional seconds. NEVER set this value directly:
* It is deduced from the AVStream values.
*
* Demuxing only, set by libavformat.
*/
int64_t start_time; //第一帧的时间位置,通常为0
int64_t duration; //输入视频总时长,以微妙为单位,换算以秒为单位: duration/AV_TIME_BASE
/**
* Total stream bitrate in bit/s, 0 if not
* available. Never set it directly if the file_size and the
* duration are known as FFmpeg can compute it automatically.
*/
int64_t bit_rate; //输入视频的码率,单位为bit/s
unsigned int packet_size;
int max_delay;
const uint8_t *key;
int keylen;
unsigned int nb_programs;
AVProgram **programs;
enum AVCodecID video_codec_id; //须要强制设置的视频编码id,默认为0,自动设置
enum AVCodecID audio_codec_id; //须要强制设置的音频编码id,默认为0,自动设置
enum AVCodecID subtitle_codec_id;//须要强制设置的字幕编码id,默认为0,自动设置
AVDictionary *metadata; //整个文件的元数据,能够经过经过av_dict_get()函数得到视频的原数据,AVDictionary包含两个成员key和value
//使用循环读出
//(须要读取的数据,字段名称,前一条字段(循环时使用),参数)
//while(m=av_dict_get(pFormatCtx->metadata,"",m,AV_DICT_IGNORE_SUFFIX)){
// key.Format(m->key);
// value.Format(m->value);
// qDebug()<<"key-value:"<<key<<"\t:"+value+"\r\n" ;
//}
int64_t start_time_realtime; //流的实际启动时间,以微秒为单位
int probe_score; //格式探测得分,100是最大的分数,这意味着FFmpeg确信格式是真实的
AVCodec *video_codec; //用户设置的强制视频解码器,若是用户未设置,就为NULL
AVCodec *audio_codec; //用户设置的强制音频解码器
AVCodec *subtitle_codec; //用户设置的强制字幕解码器
... ...
} AVFormatContext;
其中iformat成员就是指向视频/音频流的封装格式(flv、mkv、avi等)具体结构体的指针.ui
该成员的AVInputFormat结构体以下所示(显示部分红员,后续深刻添加):this
typedef struct AVInputFormat
{
const char *name; // 封装格式的名字, 好比,“mov” “mp4” 等。
const char *long_name; ///封装格式的长名字
//标示具体的format对应的Context 的size,如:MovContext。
const char *extensions; //扩展名,若是定义了, 则不执行探测视频格式, 一般不使用扩展格式猜想,由于不可靠
//具体的操做函数
int(*read_probe)(AVProbeData*);
int(*read_header)(struct AVFormatContext *,AVFormatParameters *ap);
int(*read_packet)(struct AVFormatContext *, AVPacket *pkt);
int(*read_close)(struct AVFormatContext*);
struct AVInputFormat *next;
} AVInputFormat
分类:
ffmpeg、ffplay
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!