AVFormatContext是在整个媒体流的处理流程中都会用到的对象。
AVFormatContext必须初始化为NULL或者用avformat_alloc_context()进行初始化。原因在于:
av_regeister_all()中:
if (!s && !(s = avformat_alloc_context()))
return AVERROR(ENOMEM);
下面看一下是怎么初始化该对象的。
AVFormatContext *avformat_alloc_context(void)
{
AVFormatContext *ic;
ic = av_malloc(sizeof(AVFormatContext));
if (!ic)
return ic;
avformat_get_context_defaults(ic);
ic->internal = av_mallocz(sizeof(*ic->internal));
if (!ic->internal) {
avformat_free_context(ic);
return NULL;
}
return ic;
}
static size_t max_alloc_siz
ffmpeg源码分析:avformat_alloc_context详解

本文深入探讨了AVFormatContext在ffmpeg中的重要角色,解释了为何需要使用avformat_alloc_context()进行初始化,并阐述了其在媒体流处理过程中的应用。
最低0.47元/天 解锁文章
4423

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



