Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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!
C++
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
 }
Posted

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

Run it under the debugger and see what happens. This is a great library and utility, but it's very big and have some legacy "noise" in it, due to multiple patches and updates. Maybe there are some error conditions which are simply ignored, or just the warning is issued and the condition itself is unavoidable or depends on input, something like that.

—SA
 
Share this answer
 
you have better chances by searching ffmpeg contacts direct.

Looks like here is some sample code available.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900