FFMpeg分析2:AVInputFormat和AVOutputFormat

192 篇文章 4 订阅 ¥19.90 ¥99.00
本文探讨了音视频播放器的数据源输入及文件格式解析器,重点介绍了FFmpeg中的AVInputFormat和AVOutputFormat。这两个结构在文件格式处理中起到关键作用,它们各自通过链表注册,并在av_open_input_file函数中被用于识别文件类型。文章提到了avformat_alloc_output_context2和avformat_open_input等关键函数的使用场景,但AVOutputFormat的详细讨论留待后续。
摘要由CSDN通过智能技术生成

我们先看一下音视频播放器的大概结构(个人想法,不保证正确):

1、数据源输入(Input)->

2、文件格式解析器(Demux)->

3、音视频解码(Decoder)->

4、颜色空间转换(仅视频)->

5、渲染输出(Render Output)。


前一篇介绍的几个struct是数据源输入模块里的内容,哪么这一帖所讲的就是第二个模块即文件格式解析器里用到的内容。

      AVInputFormat、AVOutputFormat与URLProtocol类似,每一种文件类型都有一个AVInputFormat和AVOutputFormat静态对像并通过av_register_input_format和av_register_output_format函数链成一个表,其表头在utils.c:

 

/** head of registered input format linked list */

AVInputFormat *first_iformat = NULL;

/** head of registered output format linked list */

AVOutputFormat *first_oformat = NULL;

 

AVInputFormat和AVOutputFormat的定义分别在avformat.h,代码很长,不贴出来浪费空间了。

当程序运行时,AVInputFormat对像的

 

int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,

                       AVInputFormat *fmt,

                       int buf_size,

                       AVFormatParameters *ap)

{

 

     fmt = av_probe_input_format(pd, 0);//返回该文件的AVInputFormat类型

}

至于AVOutputFormat嘛,下次再说吧,晚安!


1. AVOutputFormat  -- Mixer

avformat_alloc_output_context2(&avFormatContext, NULL, NULL, filename);










2. AVInputFormat -- DeMixer

2.1 filePath = “1.MP4”

avformat_open_input(&m_pFormatContext, filePath, NULL, &avdic);














2.2 filePath = “rtsp://192.168.5.147:8554/1"

avformat_open_input(&m_pFormatContext, filePath, NULL, &avdic);


















http://blog.csdn.net/cosmoslife/article/details/7646997

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值