本文简单分析FFmpeg中1个经常使用的函数:avformat_open_input()。该函数用于打开多媒体数据并且取得1些相干的信息。它的声明位于libavformatavformat.h,以下所示。
/**
* Open an input stream and read the header. The codecs are not opened.
* The stream must be closed with avformat_close_input().
*
* @param ps Pointer to user-supplied AVFormatContext (allocated by avformat_alloc_context).
* May be a pointer to NULL, in which case an AVFormatContext is allocated by this
* function and written into ps.
* Note that a user-supplied AVFormatContext will be freed on failure.
* @param filename Name of the stream to open.
* @param fmt If non-NULL, this parameter forces a specific input format.
* Otherwise the format is autodetected.
* @param options A dictionary filled with AVFormatContext and demuxer-private options.
* On return this parameter will be destroyed and replaced with a dict containing
* options that were not found. May be NULL.
*
* @return 0 on success, a negative AVERROR on failure.
*
* @note If you want to use custom IO, preallocate the format context and set its pb field.
*/
int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options);
* Open an input stream and read the header. The codecs are not opened.
* The stream must be closed with avformat_close_input().
*
* @param ps Pointer to user-supplied AVFormatContext (allocated by avformat_alloc_context).
* May be a pointer to NULL, in which case an AVFormatContext is allocated by this
* function and written into ps.
* Note that a user-supplied AVFormatContext will be freed on failure.
* @param filename Name of the stream to open.
* @param fmt If non-NULL, this parameter forces a specific input format.
* Otherwise the format is autodetected.
* @param options A dictionary filled with AVFormatContext and demuxer-private options.
* On return this parameter will be destroyed and replaced with a dict containing
* options that were not found. May be NULL.
*
* @return 0 on success, a negative AVERROR on failure.
*
* @note If you want to use custom IO, preallocate the format context and set its pb field.
*/
int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options);
代码中的英文注释写的已比较详细了,在这里拿中文简单叙述1下。
ps:函数调用成功以后处理过的AVFormatContext结构体。
file:打开的视音频流的URL。
fmt:强迫指定AVFormatContext中AVInputFormat的。这个参数1般情况下可以设置为NULL,这样FFmpeg可以自动检测AVInputFormat。dictionay:附加的1些选项,1般情况下可以设置为NULL。
函数履行成功的话,其返回值大于等于0。
该函数最典型的例子可以参考: 最简单的基于FFMPEG+SDL的视频播放器 ver2 (采取SDL2.0)
此前已粗略写了1篇关于avformat_open_input()的文章《 图解FFMPEG打开媒体的函数avformat_open_input》,还转载了1篇注释比较详细的文章《FFMPEG源码分析:avformat_open_input()(媒体打开函数)》。但是个人感觉这个函数确切太重要了,可以算作FFmpeg的“灵魂”,所以打算再写1篇文章分析1下它的结构。
函数调用关系图
函数调用结构图以下所示。
波比源码 – 精品源码模版分享 | www.bobi11.com
1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解!
5. 如有链接无法下载、失效或广告,请联系管理员处理!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
7. 本站源码并不保证全部能正常使用,仅供有技术基础的人学习研究,请谨慎下载
8. 如遇到加密压缩包,请使用WINRAR解压,如遇到无法解压的请联系管理员!
波比源码 » FFmpeg源代码简单分析:avformat_open_input()
波比源码 » FFmpeg源代码简单分析:avformat_open_input()
Sampling was carried out using the medical records of female patients belonging to both groups buy cialis non prescription
CBC is the most common malignancy among breast cancer survivors, accounting for nearly 40 of all second cancers 2 cialis online generic Although briefly mentioned by the AHA Peberdy et al, 2010, other inotropes and vasopressors are recommended in the management of post cardiac arrest patients
An antiproliferative effect was also evident in mammary gland and anterior pituitary where both toremifene and tamoxifen suppressed tumor incidence in comparison to the control group levitra indicaciones Anderson, John M
buy cialis online cheap However, a newer group of drugs, called aromatase inhibitors, have more recently been developed and appear to be more active than tamoxifen in postmenopausal women
Doxy Denk and Doxy Denk CAP are indicated for treatment of Rocky Mountain spotted fever, typhus fever and the typhus group, Q fever, rickettsial pox, and tick fevers caused by Rickettsiae buy cialis 20mg