[Ffmpeg-devel] libavcode won't release final frame of MPEG or H.264
Fri Nov 11 23:03:59 CET 2005
> -----Original Message-----
> From: Bob Forsman [mailto:thoth at purplefrog.com]
> Sent: den 11 november 2005 18:25
> To: ffmpeg-devel at mplayerhq.hu
> Subject: [Ffmpeg-devel] libavcode won't release final frame
> of MPEG or H.264
> I'm feeding self-contained blocks of MPEG2 and H.264 -encoded
> video into
> libavcodec, but I always get back one less frame than I expect.
> apiexample.c claims to have extra code which solves this
> problem, but it
> malfunctions the same as my code does (not surprising since my code is
> based on apiexample.c).
> (download http://www.purplefrog.com/~thoth/x/nal-confuses-libavcodec)
> libavcodec/apiexample /tmp/nal-confuses-libavcodec
> It only creates /tmp/test0.pgm .. test14.pgm . test15.pgm is missing.
> If I duplicate the byte sequence of the last frame, I can get the
> renderer to spit out the first copy, but that's a disgusting kludge.
> I will admit I am not a wizard at H.264, so I may have
> reconstructed the
> NAL stream a little screwy, but if that is the case I'm hoping one of
> you can help me straighten it out.
> How can I get libavcodec to give me the final frame of the MPEG or
> H.264 stream?
This could be caused by the parser I think. Had the same problem with
getting dvd menu stills out from ffmpeg. Problem is when ffmpeg repacks mpeg
frames, it's looking for the next startcode instead of endcode, and if there
is no new startcode, it doesn't release the frame. We ( XBMC ) used an uggly
hack to get around it, but I think the flag PARSER_FLAG_COMPLETE_FRAMES
should do the trick too ( from looking at the code ). Can't say how to set
that flag however, as I've never tried it. Should be in the
We had the problem when using the demuxer. And I'm not sure if the codecs
use the parser too, but as the code is in libavcodec and not in libavformat,
I would assume so. ( libavcodec/parser.c - mpegvideo_parse() )
More information about the ffmpeg-devel