[Libav-user] avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet) why most of the time frameFinished is zero ?

wm4 nfxjfg at googlemail.com
Tue May 27 17:28:14 CEST 2014


On Tue, 27 May 2014 17:10:55 +0530
sithruk sana <get2jils at gmail.com> wrote:

> thanks for the reply.
> 
> I am doing the same by queueing the packet  as described in dranger
> tutorial http://dranger.com/ffmpeg/ffmpegtutorial_all.html

This tutorial is prehistoric, and following it will cause you more pain
than not. Many things in it are just wrong or uses deprecated APIs. I
recommend pretending that this tutorial doesn't exist.

Normally, libavcodec decodes one frame for one packet. But you need
to deal with "codec delay": at first you won't get any decoded frames,
even if you put in some packets. Only later (when enough frames are
queued internally), you will get 1 decoded frame for 1 packet. (You also
need to feed it null-packets at the end of the video to get the last
frames.)

There are others reasons why it wouldn't output a frame. If the video
frame is "damaged", you may need to set CODEC_FLAG2_SHOW_ALL or
CODEC_FLAG_OUTPUT_CORRUPT (forgot which one) to make lavc output them.
Also, it's possible to drop frames by setting skip_frame, but you
probably don't use this.

> The behaviour is somewhat different if i do not queue the packet. Are there
> any quirk i need to be aware of while pusing/pulling from queue ?
> 
> Kindly help me.
> 
> 
> 
> 
> On Tue, May 27, 2014 at 4:12 PM, cyril poulet
> <cyril.poulet at centraliens.net>wrote:
> 
> > a packet rarely contains an entire frame. You have to feed the decoder
> > packets until a frame is finished.
> > frameFinished is the flag that tells you that a complete frame has been
> > gathered and decoded, and that you can now work on it
> >
> > However, seeing the number of messages you left recently, you might want
> > to find a tutorial instead of posting very simple questions...
> >
> >
> > 2014-05-27 12:34 GMT+02:00 cyril poulet <xenosender at gmail.com>:
> >
> > a packet rarely contains an entire frame. You have to feed the decoder
> >> packets until a frame is finished.
> >> frameFinished is the flag that tells you that a complete frame has been
> >> gathered and decoded, and that you can now work on it
> >>
> >>
> >> 2014-05-26 10:36 GMT+02:00 sithruk sana <get2jils at gmail.com>:
> >>
> >>> Dear all,
> >>>
> >>> I received a packet from rtsp by av_read_frame and decode it through
> >>>
> >>>  avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet)
> >>>
> >>> After decoding i am checking  the value of frameFinished.
> >>>
> >>> Most of the time i get the value of frameFinished is zero.  May be around
> >>> 50% of the packet.
> >>>
> >>>
> >>> Can u hint me what could be the reason ?
> >>>
> >>> It is any way related to 'I', 'P', 'B' packet types ?
> >>>
> >>>
> >>>
> >>>
> >>> _______________________________________________
> >>> Libav-user mailing list
> >>> Libav-user at ffmpeg.org
> >>> http://ffmpeg.org/mailman/listinfo/libav-user
> >>>
> >>>
> >>
> >
> > _______________________________________________
> > Libav-user mailing list
> > Libav-user at ffmpeg.org
> > http://ffmpeg.org/mailman/listinfo/libav-user
> >
> >



More information about the Libav-user mailing list