[Libav-user] av_probe_input_format fails the second time

francesco at bltitalia.com francesco at bltitalia.com
Wed Jan 11 16:52:50 CET 2012


Hi to all
I am writing a routine that decode a mpeg2 frame stored in a buffer.
The code is the subsequent:



AnsiString str1;
unsigned long i, loopCnt;
AVCodec         *pCodec;
AVFrame         *pFrame;
AVPacket        avpkt;
AVFormatContext *pFormatCtx;
AVCodecContext  *pCodecCtx;
ByteIOContext   ByteIOCtx;
AVProbeData     pd;
int             frameFinished;
AVPacket        packet;
int             err;


  av_init_packet(&packet);

 // Allocate buffer => Not Necessary, because the buffer is static 
// InputCompressed[0x400000];  // 4M buffer

  pd.buf = InputCompressed;
  pd.buf_size = inputSize; // This parameter is passed to the routine, 
                           // is the size of the frame
  pd.filename = "";

  bufPnt = 0;              // Pointer to the InputCompressed buffer 
                           // (used in read and seek function) 
  AVInputFormat* pAVInputFormat = av_probe_input_format(&pd, 1);
  if(!pAVInputFormat)
    {Memo1->Lines->Add("Error on probing input format"); goto end_conv;}

  pAVInputFormat->flags |= AVFMT_NOFILE;

  if(init_put_byte(&ByteIOCtx, InputCompressed, inputSize, 0, this,
myReadFunction, myWriteFunction, mySeekFunction) < 0)
     {Memo1->Lines->Add("Error on init_put_byte"); goto end_conv;}

  if(av_open_input_stream(&pFormatCtx,&ByteIOCtx, "", pAVInputFormat, NULL)<0)
     {Memo1->Lines->Add("Error opening input stream"); goto end_conv;}


  if(av_find_stream_info(pFormatCtx)>0)
     {Memo1->Lines->Add("Error reading stream info"); goto end_conv;}


This code works well for the first frame, in the second frame the 
function av_probe_input_format fails.  Any idea ?
best regards
/*******************************************************************\
*    ing. Francesco  Cuzzocrea
*    company:    BLT Italia srl        web:  http://www.blt.it
*    address:    via Rosselli, 91     city:  Lido di CAMAIORE
*    country:    ITALY                 zip:  55043-i
*      Tel. :    +39 0584 904788       Fax:  +39 0584 904789  
*     e-mail:   francesco at bltitalia.com
\*******************************************************************/




More information about the Libav-user mailing list