avformat_alloc_output_context2函数用于设置输出context,其函数原型如下:
/**
* Allocate an AVFormatContext for an output format.
* avformat_free_context() can be used to free the context and
* everything allocated by the framework within it.
*
* @param *ctx is set to the created format context, or to NULL in
* case of failure
* @param oformat format to use for allocating the context, if NULL
* format_name and filename are used instead
* @param format_name the name of output format to use for allocating the
* context, if NULL filename is used instead
* @param filename the name of the filename to use for allocating the
* context, may be NULL
* @return >= 0 in case of success, a negative AVERROR code in case of
* failure
*/
int avformat_alloc_output_context2(AVFormatContext **ctx, const AVOutputFormat *oformat,
const char *format_name, const char *filename);
总共4个参数,其中第一个参数是输出,其他都是输入。
第二个参数和第三个参数都是封装格式,第二个是结构体类型,第三个是字符串类型,比如format_name为mp4时,其对应的AVOutputFormat结构(第二个参数)详情如下:
const AVOutputFormat ff_mp4_muxer = {
.name = "mp4",
.long_name = NULL_IF_CONFIG_SMALL("MP4 (MPEG-4 Part 14)")

avformat_alloc_output_context2函数用于创建输出context,它接受4个参数,包括输出的AVFormatContext指针和用于指定封装格式的信息。当第二个参数为NULL时,会根据第三个参数的格式名称或第四个参数的文件名来确定封装格式。示例中展示了如何设置mp4和flv两种封装格式,并且提到在实际使用中,文件名的后缀可以用来指定封装格式。
最低0.47元/天 解锁文章
5182

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



