【问题标题】:How to encode audio in AAC-LC, AAC-HE-V1, AAC-HE-V2 using libavcodec?如何使用 libavcodec 在 AAC-LC、AAC-HE-V1、AAC-HE-V2 中编码音频?
【发布时间】:2013-09-24 13:05:39
【问题描述】:

我正在尝试使用 libavcodec/ffmpeg API 对 AAC-LC、AAC-HE-V1、AAC-HE-V2 中的音频进行编码。

但是当我使用以下配置和 API 调用时,它显示“无效的 AAC 配置文件”。

AVCodecContext *encoder_ctx;
encoder_ctx->codec_id           =   AV_CODEC_ID_AAC;
encoder_ctx->sample_fmt         =   AV_SAMPLE_FMT_S16; 
encoder_ctx->profile            =   FF_PROFILE_AAC_HE;

encoder = avcodec_find_encoder(encoder_ctx->codec_id);
avcodec_open2(encoder_ctx, encoder, NULL);

你能解释一下这有什么问题吗?

【问题讨论】:

    标签: audio ffmpeg libavcodec transcoding libav


    【解决方案1】:

    除了使用 --enable-libfdk_aac 之外,您可能还必须使用

    --enable-encoder=libfdk_aac
    

    如果您有选择性并禁用了所有可用选项

    --disable-everything
    

    所以在配置之后检查你是否有外部库:

    External libraries:
    libfdk_aac
    

    和编码器:

    Enabled encoders:
    libfdk_aac
    

    【讨论】:

      【解决方案2】:

      首先看看这个 document:

      杜比数字:ac3

      杜比数字+:eac3

      MP2: libtolame, mp2

      Windows 媒体音频 1:wmav1

      Windows 媒体音频 2:wmav2

      LC-AAC:libfdk_aac、libfaac、aac、libvo_aacenc

      HE-AAC:libfdk_aac、libaacplus

      Vorbis: libvorbis, vorbis

      MP3:libmp3lame、libshine

      作品:libopus

      从上面的阅读中你会清楚,为了在 HE-AAC/HE-AAC-V2 中编码音频,你必须使用 libfdk_aac 或 libaacplus。

      我将解释如何使用 libfdk_aac:

      首先确保您配置了 ffmpeg 以及以下选项:

      --enable-libfdk_aac --enable-nonfree
      

      现在构建 ffmpeg 并尝试运行以下命令,看看它是否有效:

      ffmpeg -i <input file> -vcodec copy -acodec libfdk_aac -profile:a aac_he <output file>
      

      如果这可行,则意味着 libav 与 libfdk_aac 链接。

      现在为了在代码中使用它:

      使用以下说明打开编码器:

      AVCodecContext *encoder_ctx;
      encoder_ctx->codec_id           =   AV_CODEC_ID_AAC;
      encoder_ctx->sample_fmt         =   AV_SAMPLE_FMT_S16; 
      encoder_ctx->profile            =   FF_PROFILE_AAC_HE;
      
      encoder = avcodec_find_encoder_by_name("libfdk_aac");
      // if you still try to open it using avcodec_find_encoder it will open libfaac only.
      avcodec_open2(encoder_ctx, encoder, NULL);
      

      我们开始了,您已经打开了 libfdk_aac 编码器! 您可以使用的配置文件在此source

      中给出

      【讨论】:

        【解决方案3】:

        我想问题是这个编码器不支持 AAC-HE。您可能想在source code 中检查这一点。支持的可能是:

        • FF_PROFILE_AAC_MAIN
        • FF_PROFILE_AAC_LOW
        • FF_PROFILE_AAC_SSR
        • FF_PROFILE_AAC_LTP

        您可能需要使用支持 AAC-HE 的 libfdk_aac 编解码器。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2019-02-05
          • 1970-01-01
          • 1970-01-01
          • 2011-01-25
          • 1970-01-01
          • 2015-12-18
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多