[Libav-user] Keeping all frames in mp4 with h264 codec

Dirr Bernhard Bernhard.Dirr at newtec.de
Wed Feb 10 19:15:03 CET 2016

Hi Arthur,

after real frames are handled did you call avcodec_encode_video2 with NULL as frame as many times as got_packet returns true?

Depending on codec you have to "flush" encoder several times, until all frames have gone to output.


Von: Libav-user [mailto:libav-user-bounces at ffmpeg.org] Im Auftrag von Arthur Muller
Gesendet: Mittwoch, 10. Februar 2016 18:24
An: 'This list is about using libavcodec, libavformat, libavutil, libavdevice and libavfilter.'
Betreff: Re: [Libav-user] Keeping all frames in mp4 with h264 codec

First of all, thanks to Max and Salsaman for the responses. I truly appreciate it.
>As long as I remember I solved a similar problem after providing the last frame of the sequence by calling avcodec_encode_video2  with frame parameter being NULL in a loop while got_packet returns true.
I am passing a NULL frame after calling calling avcodec_encode_video2  for all my 36 frames. But I only pass the NULL frame once, when I’m done, to make sure everything that has not been flushed is actually flushed.
>Also, just a guess but 18 is half of 36. Is it possible you need to set some interlacing option ?
I have to admit my knowledge of this is very limited. But this is what I know:
1) I am sending down 36 non-trivial frames, plus one NULL frame, for a total of 37 frames.
2) After sending down the first 18 frames by calling avcodec_encode_video2 the value of got_packet is 0 for all of them.
3) When sending frames 19-36, the value of got_packet is 1.
4) When displaying my video, the only images I see are the first 18. I know this for a fact because the images are very similar, but each has a label with a time stamp 0, 10, 20, etc. So I know which ones are missing. Interestingly enough, the missing ones are the ones for which got_packet=1 (!).
If the issue is “interlacing”, can somebody suggest what I need to do in my code to try to correct this?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20160210/b0042f8b/attachment.html>

More information about the Libav-user mailing list