本篇FFMEPG实现对AAC解码,解码结果保存wav格式。对AAC编码文件来说,编码根据音频参数编码,解码根据音频参数重新构建声波,
FFMPEG构建的音频存储方式不一定支持播放, 所以需要重采样样本,例如新版ffmpeg解码AAC解码后得到AV_SAMPLE_FMT_FLTP,该格式SDKL播放不支持该格式
ffmpeg所支持的音频格式中:有的仅内部使用,有的可以外部作为音频文件格式
AVFormatContext * pFormatCtx = avformat_alloc_context();
avformat_open_input(&pFormatCtx,INPUT_FILE_NAME,NULL,NULL)‘
avformat_find_stream_info(pFormatCtx,NULL);
// Dump valid information onto standard error
av_dump_format(pFormatCtx, 0, INPUT_FILE_NAME, false);
// Find the first audio stream👉👉int audioStream
p_codec_par = p_fmt_ctx->streams[a_idx]->codecpar;
AVCodec *pCodec=avcodec_find_decoder(pCodecCtx->codec_id);
AVCodecContext *p_codec_ctx = avcodec_alloc_context3(p_codec);
avcodec_parameters_to_context(p_codec_ctx, p_codec_par);
// Open codec
avcodec_open2(pCodecCtx, pCodec,NULL);
uint64_t iInputLayout = av_get_default_channel_layout(pCodecCtx->channels);//使用默认声道分布
int iInputChans