0

I have the following code to encode an audio stream and everything seems to be working fine until I get to the avcodec_encode_audio2 function, I am failing with -22 error code, and I dont know what that error code means. I verified that pFrame and out_fmt_ctx are allocated. Does anyone have an idea of what the problem might be?

Thanks in advance!

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
 }
Godspped
  • 683
  • 4
  • 12
  • 31
  • Have you enabled debug logging to console? `av_log_set_level(AV_LOG_DEBUG);` – njahnke Jun 16 '14 at 14:25
  • Tried it, but the error is -22 and I do not know what it is.... Has anyone encountered it. I am trying to conver PCM to AAC but it doesnt want to work. – Godspped Jun 17 '14 at 03:31
  • I just ran over the same error. Did you find out what the error code "-22" means? – Hyndrix Jul 12 '14 at 10:40
  • I have a feeling that this post may help you. http://stackoverflow.com/questions/25033100/how-to-decode-aac-using-avcodec-decode-audio4 – Siyuan Jiang Dec 08 '15 at 16:36

0 Answers0