[Libav-user] avcodec_decode_video2 returns 0 in third parameter

francesco at bltitalia.com francesco at bltitalia.com
Tue Jan 10 12:01:42 CET 2012


At 17.51 09/01/2012 +0100, you wrote:
>Hi to all
>I can't decode a field because avcodec_decode_video2 returns 0 in the third
>parameter either if the stream is correct (i displayed it with other
>programs). Here is the code:
>
>  pCodec=avcodec_find_decoder(pCodecCtx->codec_id);
>  if(pCodec==NULL) {  str1.printf("Unsupported codec ! (type
>%d)",pCodecCtx->codec_id);Memo1->Lines->Add(str1); goto end_conv;}
>
>  // Allocate video frame
>  pFrame=avcodec_alloc_frame();
>
>  // Open codec
>  if(avcodec_open(pCodecCtx, pCodec)<0) {  Memo1->Lines->Add("Unable to open
>codec!"); goto end_conv;}
>
>  err = av_read_frame(pFormatCtx, &packet);
>  if(err<=0) Memo1->Lines->Add("Error or end of file during read_frame");
>  if(packet.stream_index==videoStream)
>  {
>  //    avcodec_get_frame_defaults(pFrame);
>      frameFinished = 0;
>
>      // Decode video frame
>      err = avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished,&packet);
> }
>
>at this point frameFinished is zero.  In the packet buffer the stream is
>correctly loaded, and the err value is exactly the number of bytes read from
>file (the file is composed of only one field).
>Any idea ?
>
>_______________________________________________
>Libav-user mailing list
>Libav-user at ffmpeg.org
>http://ffmpeg.org/mailman/listinfo/libav-user
>
>
>__________ Informazioni da ESET NOD32 Antivirus, versione del database
delle firme digitali 6777 (20120108) __________
>
>Il messaggio è stato controllato da ESET NOD32 Antivirus.
>
>www.nod32.it
>
>
>
>
Solved ! !  The code should loop until third parameter is !=0.



More information about the Libav-user mailing list