[FFmpeg-cvslog] ffmpeg; check return code of avcodec_send_frame when flushing encoders

Marton Balint git at videolan.org
Sun Apr 23 00:31:07 EEST 2017


ffmpeg | branch: release/3.3 | Marton Balint <cus at passwd.hu> | Sat Apr 15 20:30:51 2017 +0200| [ed2ed4ac0f05c4139a3149cb59bf1717c797a620] | committer: Marton Balint

ffmpeg; check return code of avcodec_send_frame when flushing encoders

Fixes Coverity CID 1404841.

Signed-off-by: Marton Balint <cus at passwd.hu>
(cherry picked from commit c037f2f1ba3a2d3114575323550f456e66695edf)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ed2ed4ac0f05c4139a3149cb59bf1717c797a620
---

 ffmpeg.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index ea03179c21..a7524d94cf 100644
--- 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",



More information about the ffmpeg-cvslog mailing list