雷神的https://blog.csdn.net/leixiaohua1020/article/details/26838535
文章后附的代码,报错:Cannot open video encoder for stream blabla...
需要修改一下,解决方法来自,烛龙一现,https://blog.csdn.net/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];
else
enc_ctx->pix_fmt = dec_ctx->pix_fmt;
/* video time_base can be set to whatever is handy and supported by encoder */
enc_ctx->time_base = dec_ctx->time_base;
enc_ctx->me_range = 16;
enc_ctx->max_qdiff = 4;
enc_ctx->qmin = 10;
enc_ctx->qmax = 51;
enc_ctx->qcompress = 0.6;
} else {
enc_ctx->sample_rate = dec_ctx->sample_rate;
enc_ctx->channel_layout = dec_ctx->channel_layout;
enc_ctx->channels = av_get_channel_layout_nb_channels(enc_ctx->channel_layout);
/* take first format from list of supported formats */
enc_ctx->sample_fmt = encoder->sample_fmts[0];
enc_ctx->time_base = (AVRational){1, enc_ctx->sample_rate};
}
--------------------- 作者:烛龙一现 来源:CSDN 原文:https://blog.csdn.net/w_z_z_1991/article/details/53002416?utm_source=copy 版权声明:本文为博主原创文章,转载请附上博文链接!
”
其中enc_ctx->qmax = 51; 可以改小提高转码后视频质量。
非常感谢!!!愿雷神彼生平安幸福唉