diff mbox series

[FFmpeg-devel,12/28] ffmpeg: write the header for stream-less outputs when initializing the muxer

Message ID 20220111095830.31542-12-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/28] ffmpeg: pass the muxer context explicitly to some functions | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished
andriy/make_aarch64_jetson success Make finished
andriy/make_fate_aarch64_jetson success Make fate finished
andriy/make_armv7_RPi4 success Make finished
andriy/make_fate_armv7_RPi4 success Make fate finished

Commit Message

Anton Khirnov Jan. 11, 2022, 9:58 a.m. UTC
There is no reason to delay this.
---
 fftools/ffmpeg.c     | 11 -----------
 fftools/ffmpeg_mux.c |  7 +++++++
 2 files changed, 7 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index d856b5b38f..f28cc17f51 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3313,7 +3313,6 @@  static void report_new_stream(int input_index, AVPacket *pkt)
 static int transcode_init(void)
 {
     int ret = 0, i, j, k;
-    AVFormatContext *oc;
     OutputStream *ost;
     InputStream *ist;
     char error[1024] = {0};
@@ -3387,16 +3386,6 @@  static int transcode_init(void)
         }
     }
 
-    /* write headers for files with no streams */
-    for (i = 0; i < nb_output_files; i++) {
-        oc = output_files[i]->ctx;
-        if (output_files[i]->format->flags & AVFMT_NOSTREAMS && oc->nb_streams == 0) {
-            ret = of_check_init(output_files[i]);
-            if (ret < 0)
-                goto dump_format;
-        }
-    }
-
  dump_format:
     /* dump the stream mapping */
     av_log(NULL, AV_LOG_INFO, "Stream mapping:\n");
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 6c3052ebe1..3b322ecb71 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -354,6 +354,13 @@  int of_muxer_init(OutputFile *of, int64_t limit_filesize)
     if (strcmp(of->format->name, "rtp"))
         want_sdp = 0;
 
+    /* write the header for files with no streams */
+    if (of->format->flags & AVFMT_NOSTREAMS && of->ctx->nb_streams == 0) {
+        int ret = of_check_init(of);
+        if (ret < 0)
+            return ret;
+    }
+
     return 0;
 }