FFmpeg AVDictionary结构体使用

简介
AVDictionary是FFmpeg的键值对存储工具,FFmpeg经常使用AVDictionary设置/读取内部参数

使用
avformat_open_input和avformat_find_stream_info函数都提供了AVDictionary参数,该参数可以在打开码流之前指定各种参数,比如:探测码流格式的时间,最大延时,超时时间,以及支持的协议的白名单等等

代码
AVInputFormat pInputFormat = NULL;
AVFormatContext
pFormatContext = avformat_alloc_context();
AVDictionary *pOptions = NULL;
av_dict_set(&pOptions, "probesize", "4096", 0);
av_dict_set(&pOptions, "max_delay", "100", 0);//指定最大延时100毫秒
if (avformat_open_input(&pFormatContext, "", pInputFormat, &pOptions) < 0)

类似的也可以通过指定pFormatContext的参数来指定探测数据格式的数据大小和最大的延时
pFormatContext->probesize = 4 *1024;
pFormatContext->max_delay = 100;

问题
实际上通过设置探测码流格式的时间以及码流数据的大小,一定程度上,减少了探测的时间,但是也会导致探测码流格式失败,因此这种方式仅用于码流格式不明确的时候,要求点播延时不苛刻的情况下
通过设置了AVDictionary的max_delay参数值无效,并且pFormatContext->max_delay也设置无效

参考
http://blog.csdn.net/encoder1234/article/details/54582676