[Libav-user] avcodec_encode_audio2 failing with error code -22 in C++ FFMPEG

Neerav Patel neeravpatel at hotmail.com
Thu Jun 19 07:09:14 CEST 2014


Hi There
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 } 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20140619/9a84335d/attachment.html>


More information about the Libav-user mailing list