[Libav-user] avcodec_decode_video2 missing the first 8 frames

wm4 nfxjfg at googlemail.com
Wed Jul 23 01:15:36 CEST 2014

On Mon, 21 Jul 2014 12:37:45 -0400
Matt Orlando <morlando616 at gmail.com> wrote:

> Hi folks,
> I'm having some trouble with the decoding of my h.264 movies.  I've tested
> with different videos, one 64 frames long and another 52 frames long.  In
> both cases, the first 8 frames (exactly 8) weren't decoding.  In other
> words, the call to avcodec_decode_video2 returns 0 for the got_picture

I think never libavcodec versions skip broken frames (frames that could
not be properly decoded, and which may contain garbage). You can set the
CODEC_FLAG2_SHOW_ALL flag to enable output of them.

Also keep in mind that the first frames may not produce any output,
because the decoder buffers them internally. This is needed for
B-frames (some frames can reference future frames, so you obviously
can get them until these future frames are decoded), or for
multithreading (each thread incurs an additional delay). When you have
no more packets, you need to send flush packets (data/size set to 0) to
get the last frames.

More information about the Libav-user mailing list