Preparation work for the following commits.

Signed-off-by: James Almer <jamr...@gmail.com>
---
 fftools/ffmpeg_enc.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index 8e68831ee8..acb0702385 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -862,6 +862,19 @@ fail:
     return AVERROR(ENOMEM);
 }
 
+static int flush_encoder(OutputStream *ost, EncoderThread *et)
+{
+    Encoder *e = ost->enc;
+    int ret;
+
+    ret = frame_encode(ost, NULL, et->pkt);
+    if (ret < 0 && ret != AVERROR_EOF)
+        av_log(e, AV_LOG_ERROR, "Error flushing encoder: %s\n",
+            av_err2str(ret));
+
+    return ret;
+}
+
 int encoder_thread(void *arg)
 {
     OutputStream *ost = arg;
@@ -927,12 +940,8 @@ int encoder_thread(void *arg)
     }
 
     // flush the encoder
-    if (ret == 0 || ret == AVERROR_EOF) {
-        ret = frame_encode(ost, NULL, et.pkt);
-        if (ret < 0 && ret != AVERROR_EOF)
-            av_log(e, AV_LOG_ERROR, "Error flushing encoder: %s\n",
-                   av_err2str(ret));
-    }
+    if (ret == 0 || ret == AVERROR_EOF)
+        ret = flush_encoder(ost, &et);
 
     // EOF is normal thread termination
     if (ret == AVERROR_EOF)
-- 
2.48.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to