最简单的基于FFMPEG的转码程序 open_output_file函数报错“Cannot open video encoder for stream ...”

在尝试使用FFMPEG进行视频转码时遇到'Cannot open video encoder for stream'的问题。解决方案来源于烛龙一现的博客,需要在open_output_file函数中增加一行代码:enc_ctx->qmax = 51;调整该值可以改善转码后的视频质量。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

雷神的https://blog.youkuaiyun.com/leixiaohua1020/article/details/26838535

文章后附的代码,报错:Cannot open video encoder for stream blabla...

需要修改一下,解决方法来自,烛龙一现https://blog.youkuaiyun.com/w_z_z_1991/article/details/53002416

transcoding.c中的open_output_file函数中,修改的部分如下(只增加了13-17行):

if (dec_ctx->codec_type == AVMEDIA_TYPE_VIDEO) {
                enc_ctx->height = dec_ctx->height;
                enc_ctx->width = dec_ctx->width;
                enc_ctx->sample_aspect_ratio = dec_ctx->sample_aspect_ratio;
                /* take first format from list of supported formats */
                if (encoder->pix_fmts)
                    enc_ctx->pix_fmt = encoder->pix_fmts[0];
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值