[FFmpeg-devel] [PATCH 1/2] ffmpeg: Separated check_init_output_file() from, init_output_stream()

Aaron Levinson alevinsn at aracnet.com
Fri May 12 23:22:41 EEST 2017


Purpose: Separated the call to check_init_output_file() from
init_output_stream(), and now check_init_output_file() is called by
the parent after calling init_output_stream().  Additionally, moved
some static function declarations to the beginning of the file.

Signed-off-by: Aaron Levinson <alevinsn at aracnet.com>
---
 ffmpeg.c | 27 +++++++++++++++++++--------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index e798d92277..3cd45ba665 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -141,6 +141,9 @@ AVIOContext *progress_avio = NULL;
 
 static uint8_t *subtitle_out;
 
+static int init_output_stream(OutputStream *ost, char *error, int error_len);
+static int check_init_output_file(OutputFile *of, int file_index);
+
 InputStream **input_streams = NULL;
 int        nb_input_streams = 0;
 InputFile   **input_files   = NULL;
@@ -1400,8 +1403,6 @@ static void do_video_stats(OutputStream *ost, int frame_size)
     }
 }
 
-static int init_output_stream(OutputStream *ost, char *error, int error_len);
-
 static void finish_output_stream(OutputStream *ost)
 {
     OutputFile *of = output_files[ost->file_index];
@@ -1446,6 +1447,10 @@ static int reap_filters(int flush)
                        ost->file_index, ost->index, error);
                 exit_program(1);
             }
+
+            ret = check_init_output_file(of, ost->file_index);
+            if (ret < 0)
+                exit_program(1);
         }
 
         if (!ost->filtered_frame && !(ost->filtered_frame = av_frame_alloc())) {
@@ -1894,6 +1899,10 @@ static void flush_encoders(void)
                        ost->file_index, ost->index, error);
                 exit_program(1);
             }
+
+            ret = check_init_output_file(of, ost->file_index);
+            if (ret < 0)
+                exit_program(1);
         }
 
         if (enc->codec_type == AVMEDIA_TYPE_AUDIO && enc->frame_size <= 1)
@@ -3564,10 +3573,6 @@ static int init_output_stream(OutputStream *ost, char *error, int error_len)
 
     ost->initialized = 1;
 
-    ret = check_init_output_file(output_files[ost->file_index], ost->file_index);
-    if (ret < 0)
-        return ret;
-
     return ret;
 }
 
@@ -3629,11 +3634,17 @@ static int transcode_init(void)
 
     /* open each encoder */
     for (i = 0; i < nb_output_streams; i++) {
+        ost = output_streams[i];
         // skip streams fed from filtergraphs until we have a frame for them
-        if (output_streams[i]->filter)
+        if (ost->filter)
             continue;
 
-        ret = init_output_stream(output_streams[i], error, sizeof(error));
+        ret = init_output_stream(ost, error, sizeof(error));
+        if (ret < 0)
+            goto dump_format;
+
+        ret = check_init_output_file(output_files[ost->file_index],
+                                     ost->file_index);
         if (ret < 0)
             goto dump_format;
     }
-- 
2.12.2.windows.2



More information about the ffmpeg-devel mailing list