FFMPEG用C ++编码从PCM到AAC的音频 [英] FFMPEG encodin audio from PCM to AAC in C++

查看:682
本文介绍了FFMPEG用C ++编码从PCM到AAC的音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好



我正在寻找能够将PM音频转换为AAC的代码。我写了一个尝试,但在尝试进行经理时我一直收到错误-22。代码如下。



非常感谢任何帮助!

Hi There

I am looking for some code that will allow me to to convert PM audio to AAC. I have written an attempt at it but I keep getting error -22 when trying to do the econding. Code is written below.

Any help would be greatly appreciated!

while( res = av_read_frame( pFormatCtx, &packet ) >=0 )
{
   if ( packet.stream_index == audioStream )
   {
  avcodec_get_frame_defaults(pFrame);
      ret = avcodec_decode_audio4(dec_ctx, pFrame, &got_frame, &packet);

      if (ret < 0) 
      {
     return ret;
  }

      /* Set frame pts */
      pFrame->pts = av_frame_get_best_effort_timestamp(pFrame);

      if (got_frame) 
      {

         AVPacket audioEncodedPacket;
         av_init_packet(&audioEncodedPacket);


         ret = avcodec_encode_audio2(out_fmt_ctx->streams[0]->codec, 
                                     &audioEncodedPacket, 
                                     pFrame, &got_packet);

         if ( ret < 0 )
         {
            //THIS IS WHERE I AM GOING WITH ERROR -22
         }
      }
 ...... // more code
 }

推荐答案

我有一个特定的建议:构建实用程序ffmpeg.exe并为其提供命令行参数,如

I have one specific advice for you: build the utility ffmpeg.exe and give it the command-line arguments like
ffmpeg -i someInputFile.wav outputFile.aac



在调试器下运行它,看看会发生什么。这是一个很棒的库和实用程序,但由于有多个补丁和更新,它非常大并且有一些遗留的噪音。也许有一些错误条件被简单地忽略,或只是发出警告,条件本身是不可避免的或取决于输入,类似的东西。



-SA


您可以通过搜索 ffmpeg联系人获得更多机会直接。



看起来这里有一些样本代码可用。
you have better chances by searching ffmpeg contacts direct.

Looks like here is some sample code available.


这篇关于FFMPEG用C ++编码从PCM到AAC的音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆