[FFmpeg-devel] [PATCH 4/5] avformat/fifo: close IO in case header writing fails

Jan Ekström jeebjp at gmail.com
Mon Dec 7 12:08:44 EET 2020


From: Jan Ekström <jan.ekstrom at 24i.com>

Otherwise each new attempt will leave its connection open.

Signed-off-by: Jan Ekström <jan.ekstrom at 24i.com>
---
 libavformat/fifo.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/libavformat/fifo.c b/libavformat/fifo.c
index 9fc524adbdf..bc363e458cd 100644
--- a/libavformat/fifo.c
+++ b/libavformat/fifo.c
@@ -142,8 +142,14 @@ static int fifo_thread_write_header(FifoThreadContext *ctx)
         avf2->streams[i]->cur_dts = 0;
 
     ret = avformat_write_header(avf2, &format_options);
-    if (!ret)
-        ctx->header_written = 1;
+    if (ret < 0) {
+        av_log(avf2, AV_LOG_ERROR,
+               "Failed to write format header: %s\n", av_err2str(ret));
+        ff_format_io_close(avf2, &avf2->pb);
+        goto end;
+    }
+
+    ctx->header_written = 1;
 
     // Check for options unrecognized by underlying muxer
     if (format_options) {
-- 
2.29.2



More information about the ffmpeg-devel mailing list