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

Arthur Muller muller at vki.com
Tue Feb 9 18:35:54 CET 2016

> You have to flush the encoder (or disable B-frames).

To ensure I'm flushing the encoder I call avcodec_encode_video2 at the very end where the 3rd argument - the frame - is set to NULL.

My guess is that to disable B-frames I need to set

AVCodecContext *c;

c = ...
c->max_b_frames = 0;

When I do both of the above, I end up with a much larger file (around 2MB as opposed to 200K) - which I believe is a good thing for my purposes. However, I put 36 images on the video. If I play the video with Windows Media it only shows 18 of them; if I play it with VLC Media Player it only shows the first.

Interestingly enough, if I add each frame 3 times, then Windows Media Player goes further than before (with a 10MB file!) - but still doesn't display the last image.

I'm hoping this behavior is a good clue to what I'm doing incorrectly. Any help is truly appreciated.

Thanks for the help.


Libav-user mailing list
Libav-user at ffmpeg.org

More information about the Libav-user mailing list