]> git.sesse.net Git - ffmpeg/commitdiff
ffmpeg; check return code of avcodec_send_frame when flushing encoders
authorMarton Balint <cus@passwd.hu>
Sat, 15 Apr 2017 18:30:51 +0000 (20:30 +0200)
committerMarton Balint <cus@passwd.hu>
Sat, 22 Apr 2017 20:56:51 +0000 (22:56 +0200)
Fixes Coverity CID 1404841.

Signed-off-by: Marton Balint <cus@passwd.hu>
ffmpeg.c

index 143322c32113dde3aec29d95dd7386f6f2136944..75f5e592a96aa50bbb52b3e9c38f79b03e18851c 100644 (file)
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1904,8 +1904,6 @@ static void flush_encoders(void)
         if (enc->codec_type != AVMEDIA_TYPE_VIDEO && enc->codec_type != AVMEDIA_TYPE_AUDIO)
             continue;
 
-        avcodec_send_frame(enc, NULL);
-
         for (;;) {
             const char *desc = NULL;
             AVPacket pkt;
@@ -1927,7 +1925,17 @@ static void flush_encoders(void)
                 pkt.size = 0;
 
                 update_benchmark(NULL);
-                ret = avcodec_receive_packet(enc, &pkt);
+
+                while ((ret = avcodec_receive_packet(enc, &pkt)) == AVERROR(EAGAIN)) {
+                    ret = avcodec_send_frame(enc, NULL);
+                    if (ret < 0) {
+                        av_log(NULL, AV_LOG_FATAL, "%s encoding failed: %s\n",
+                               desc,
+                               av_err2str(ret));
+                        exit_program(1);
+                    }
+                }
+
                 update_benchmark("flush_%s %d.%d", desc, ost->file_index, ost->index);
                 if (ret < 0 && ret != AVERROR_EOF) {
                     av_log(NULL, AV_LOG_FATAL, "%s encoding failed: %s\n",