FFMPEG4 AVFormatContext结构体

AVFormatContext常用成员的含义

struct AVInputFormat *iformat;//输入数据的封装格式。仅解封装用,由avformat_open_input()设置。
struct AVOutputFormat *oformat;//输出数据的封装格式。仅封装用,调用者在avformat_write_header()之前设置。
AVIOContext *pb;// I/O上下文。
解封装:由用户在avformat_open_input()之前设置(然后用户必须手动关闭它)或通过avformat_open_input()设置。
封装:由用户在avformat_write_header()之前设置。 调用者必须注意关闭/释放IO上下文。
unsigned int nb_streams;//AVFormatContext.streams中元素的个数。
AVStream **streams;//文件中所有流的列表。
char filename[1024];//输入输出文件名。
int64_t start_time;//第一帧的位置。
int64_t duration;//流的持续时间
int64_t bit_rate;//总流比特率(bit / s),如果不可用则为0。 
int64_t probesize;
//从输入读取的用于确定输入容器格式的数据的最大大小。
仅封装用,由调用者在avformat_open_input()之前设置。
AVDictionary *metadata;//元数据
AVCodec *video_codec;//视频编解码器
AVCodec *audio_codec;//音频编解码器
AVCodec *subtitle_codec;//字母编解码器
AVCodec *data_codec;//数据编解码器
int (*io_open)(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags, AVDictionary **options);
//打开IO stream的回调函数。
void (*io_close)(struct AVFormatContext *s, AVIOContext *pb);
//关闭使用AVFormatContext.io_open()打开的流的回调函数。

AVFormatContext的初始化函数是avformat_alloc_context(),销毁函数是avformat_free_context()。

avformat_alloc_context()
avformat_alloc_context()调用av_malloc()为AVFormatContext结构体分配了内存,同时也给AVFormatContext中的internal字段分配内存。调用了一个avformat_get_context_defaults()函数设置AVFormatContext的字段的默认值

avformat_free_context()
avformat_free_context()调用了各式各样的销毁函数。这些函数分别用于释放不同种类的变量

有的时候做如下声明后调用,返回一个非空的fmt_ctx,是因为avformat_open_input函数中会检测fmt_ctx 是否为空,若空则调用avformat_alloc_context()

AVFormatContext *fmt_ctx = NULL;
avformat_open_input(&fmt_ctx, in_filename, NULL, NULL);

参考:
https://blog.csdn.net/leixiaohua1020/article/details/41181155
https://www.jianshu.com/p/a4d53b20e139

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值