上一篇文章说了一下媒体文件解码的流程,在该基础上再对其中的第一个过程Demux在ffmpeg中是如何实现的进行说明。
ffmpeg中用来进行Demux的关键函数是avformat_open_input,这里先贴一下源码中的定义:
头文件:avformat.h
<span style="font-size:18px;"><span style="font-size:18px;">/**
* Open an input stream and read the header. The codecs are not opened.
* The stream must be closed with av_close_input_file().
*
* @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 sp

本文深入探讨ffmpeg中的Demux过程,重点解析关键函数avformat_open_input。该函数在avformat.h头文件中定义,负责媒体文件的解复用。通过分析,当函数执行成功,会填充AVFormatContext结构,否则将释放内存。文章还提及了函数参数的作用,如媒体文件名、指定格式和额外选项,并预告后续会介绍重要数据结构AVFormatContext。
最低0.47元/天 解锁文章
612

被折叠的 条评论
为什么被折叠?



