[Libav-user] avcodec_decode_video2 returns 0 in third parameter
francesco at bltitalia.com
francesco at bltitalia.com
Mon Jan 9 17:51:34 CET 2012
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 ?
More information about the Libav-user
mailing list