[FFmpeg-devel] [PATCH 09/11] fftools/ffmpeg_enc: split off encoder flushing in encoder_thread() into a separate function
James Almer
jamrial at gmail.com
Tue Feb 18 15:08:11 EET 2025
Preparation work for the following commits.
Signed-off-by: James Almer <jamrial at 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
More information about the ffmpeg-devel
mailing list