[FFmpeg-devel] [PATCH 11/47] fftools/ffmpeg_enc: return errors from enc_flush() instead of aborting

Anton Khirnov anton at khirnov.net
Sat Jul 15 13:45:35 EEST 2023


---
 fftools/ffmpeg.c     | 2 +-
 fftools/ffmpeg.h     | 2 +-
 fftools/ffmpeg_enc.c | 6 ++++--
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 27c4e7ef26..926fdea23a 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1250,7 +1250,7 @@ static int transcode(int *err_rate_exceeded)
         } else if (err_rate)
             av_log(ist, AV_LOG_VERBOSE, "Decode error rate %g\n", err_rate);
     }
-    enc_flush();
+    ret = err_merge(ret, enc_flush());
 
     term_exit();
 
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 38f2b1ef66..7329df6607 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -816,7 +816,7 @@ void enc_free(Encoder **penc);
 int enc_open(OutputStream *ost, AVFrame *frame);
 int enc_subtitle(OutputFile *of, OutputStream *ost, const AVSubtitle *sub);
 int enc_frame(OutputStream *ost, AVFrame *frame);
-void enc_flush(void);
+int enc_flush(void);
 
 /*
  * Initialize muxing state for the given stream, should be called
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index 72ba56a03d..728c09dcad 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -1151,7 +1151,7 @@ int enc_frame(OutputStream *ost, AVFrame *frame)
            do_video_out(of, ost, frame) : do_audio_out(of, ost, frame);
 }
 
-void enc_flush(void)
+int enc_flush(void)
 {
     int ret;
 
@@ -1172,6 +1172,8 @@ void enc_flush(void)
 
         ret = submit_encode_frame(of, ost, NULL);
         if (ret != AVERROR_EOF)
-            exit_program(1);
+            return ret;
     }
+
+    return 0;
 }
-- 
2.40.1



More information about the ffmpeg-devel mailing list