请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

创建AAC编码器遇到Specified sample format s16 is not supported by the aac encoder这个问题

我在windows环境下,使用ffmpeg7.1遇到Specified sample format s16 is not supported by the aac encoder这个问题,
libfdk_aac已经编译
代码如下:
//打开编码器
const AVCodec *codec = avcodec_find_encoder(AV_CODEC_ID_AAC);
if (!codec)
cout << “avcodec_find_encoder NULL\n”;

//创建上下文
AVCodecContext * codec_ctx=avcodec_alloc_context3(codec);
if (!codec_ctx)
{
	cout << "avcodec_alloc_context3 NULL\n";
}

codec_ctx->sample_fmt = AV_SAMPLE_FMT_S16;            //输入音频采样大小  AAC要求必须是AV_SAMPLE_FMT_S16
codec_ctx->sample_rate = 44100;                        //输入音频的采样率        
codec_ctx->ch_layout = AV_CHANNEL_LAYOUT_STEREO;       //输入音频的channel 布局
codec_ctx->bit_rate = 0;                            //输入音频的比特率
codec_ctx->profile = FF_PROFILE_AAC_HE_V2;

ret=avcodec_open2(codec_ctx, codec, nullptr);
if (ret)
{
	av_strerror(ret, err, 1024);
	cout << ret << " : " << err << '\n';
}

我查了网上资料,说是这样
图片描述
图片描述

图片描述

正在回答

1回答

李超 2024-12-17 13:29:25

使用fdk_AAC你不能通过ID来查找,因为ffmpeg 自己也有一个AAC编解码器,你使用AAC ID找到的是ffmpeg 自己实现的,你要使用fdk_AAC,你应该通过编解码器名字来找的Fdk_AAC,要按照我课程中的方法来

0 回复 有任何疑惑可以回复我~
  • 提问者 邓丹俊 #1
    好的,谢谢老师
    回复 有任何疑惑可以回复我~ 2024-12-17 17:02:29
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号