summaryrefslogtreecommitdiff
path: root/ffmpeg.c
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2017-04-15 20:30:51 +0200
committerMarton Balint <cus@passwd.hu>2017-04-22 22:56:51 +0200
commitc037f2f1ba3a2d3114575323550f456e66695edf (patch)
treeb590a2aecac5ee3af2b718e873353f0900a56400 /ffmpeg.c
parentfc8cff96ed45dfdb91ed03e9942845f28be0e770 (diff)
ffmpeg; check return code of avcodec_send_frame when flushing encoders
Fixes Coverity CID 1404841. Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'ffmpeg.c')
-rw-r--r--ffmpeg.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index 143322c321..75f5e592a9 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",