Hello,
I recently want to use the last FFMPEG release version to decode video packets. 
avcodec_decode_video2 is deprecated so I want to use avcodec_send_packet and 
avcodec_receive_frame

I'm just not sure waht about doing when receiving eror like AVERROR(EAGAIN), 
AVERROR_EOF... my code is below.

int FFMpegImgDecode( AVCodecContext* lpCodecCtx, AVPacket* lpAVPacket, AVFrame* 
lpAVFrame)
{ int iResult       = 1;
  int iDecodeResult = 1;


  if ((lpCodecCtx!=NULL) && (lpAVFrame!=NULL) && (lpAVPacket!=NULL))
   { if (m_lpCodecCtx->codec_type == AVMEDIA_TYPE_VIDEO)
      { iResult = lpfnavcodec_send_packet( m_lpCodecCtx, &m_lpPacket);
        if (iResult == AVERROR_EOF)
         { iResult = 0;
         }
       if (iResult == 0) // success
         { iDecodeResult = lpfnavcodec_receive_frame(m_lpCodecCtx, m_lpFrame);
           // iDecodeResult == 0                => Success
          // iDecodeResult == AVERROR(EAGAIN)) => Need to feed the next input 
frame
          // else                              => Error
           if (iDecodeResult==AVERROR(EAGAIN))
            { printf("avcodec_receive_frame ERROR [AVERROR(EAGAIN)]\r\n");
            }
           if ((iDecodeResult!=0) && (iDecodeResult!=AVERROR(EAGAIN)))
            { char szErrorText[255];
              av_strerror( iResult, szErrorText, sizeof(szErrorText));
              printf("avcodec_receive_frame ERROR [%i][%s]\r\n", iResult, 
szErrorText);
            }
         }
       else
         { char szErrorText[255];
           av_strerror( iResult, szErrorText, sizeof(szErrorText));
           printf("avcodec_send_packet ERROR [%i][%s]\r\n", iResult, 
szErrorText);
           iDecodeResult = iResult;

        }
      }
   }
  return iDecodeResult;
}

Also sometimes I receive error : avcodec_send_packet ERROR 
[-1094995529][Invalid data found when processing input].
It is when I decompress a h264 video stream from a camera. Do you think it is 
possible that this error can arrive if I have some network trouble with the 
camera.

Regards,





_______________________________________________
Libav-user mailing list
[email protected]
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".

Reply via email to