[Libav-user] H.264 codec frames lost

Gustav González xtingray at gmail.com
Fri Mar 1 07:29:42 EET 2019

I implemented a basic tool to convertt an array of images into a video
file, following some of the ffmpeg/libav examples available in several
The code works great using the MPEG4 codec, but when I try the H,264
something strange occurs: I lost 30% of the frames (usually the last ones).
Checking on the code, I found out that this instructions is related to the

*int ret = avcodec_encode_video2(c, &pkt, videoFrame, &got_output);*

The variable *got_output* gets NULL value in many of the iterations while I
am creating the video file:

*if (got_output) {*

*    if (c->coded_frame->key_frame)        pkt.flags |= AV_PKT_FLAG_KEY;*

*    pkt.stream_index = video_st->index;    ret =
av_interleaved_write_frame(oc, &pkt);     av_free_packet(&pkt); } else
{        ret = 0; }*

So I wonder what I could be missing related to the H,264 codec,
understanding that using exactly the same code, the codec MPEG4 works
Any codec settings that I should care about? Any suggestion?

  Gustav Gonzalez
  xtingray at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20190301/dba69be4/attachment.html>

More information about the Libav-user mailing list