[FFmpeg-cvslog] avconv: create simple filtergraphs earlier

Anton Khirnov git at videolan.org
Thu Aug 4 21:17:00 EEST 2016


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Sun May 22 19:57:36 2016 +0200| [73c6ec6d659bab11ac424a4ba6ce3a56246295ee] | committer: Anton Khirnov

avconv: create simple filtergraphs earlier

We already have all the necessary information in open_output_file().
This makes the information about the stream/filtergraph mappings
available earlier.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=73c6ec6d659bab11ac424a4ba6ce3a56246295ee
---

 avconv.c        |  9 ++++-----
 avconv.h        |  2 +-
 avconv_filter.c |  4 ++--
 avconv_opt.c    | 16 ++++++++++++++--
 4 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/avconv.c b/avconv.c
index 8cb8d14..e5a76b1 100644
--- a/avconv.c
+++ b/avconv.c
@@ -2008,11 +2008,10 @@ static int transcode_init(void)
                 exit_program(1);
 #endif
 
-            if (!ost->filter &&
-                (enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO ||
-                 enc_ctx->codec_type == AVMEDIA_TYPE_AUDIO)) {
-                    FilterGraph *fg;
-                    fg = init_simple_filtergraph(ist, ost);
+            if ((enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO ||
+                 enc_ctx->codec_type == AVMEDIA_TYPE_AUDIO) &&
+                 filtergraph_is_simple(ost->filter->graph)) {
+                    FilterGraph *fg = ost->filter->graph;
                     if (configure_filtergraph(fg)) {
                         av_log(NULL, AV_LOG_FATAL, "Error opening filters!\n");
                         exit_program(1);
diff --git a/avconv.h b/avconv.h
index be8ef23..78dbbdd 100644
--- a/avconv.h
+++ b/avconv.h
@@ -450,7 +450,7 @@ int configure_filtergraph(FilterGraph *fg);
 int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter, AVFilterInOut *out);
 int ist_in_filtergraph(FilterGraph *fg, InputStream *ist);
 int filtergraph_is_simple(FilterGraph *fg);
-FilterGraph *init_simple_filtergraph(InputStream *ist, OutputStream *ost);
+int init_simple_filtergraph(InputStream *ist, OutputStream *ost);
 int init_complex_filtergraph(FilterGraph *fg);
 
 int avconv_parse_options(int argc, char **argv);
diff --git a/avconv_filter.c b/avconv_filter.c
index 1d4aeb0..875ce10 100644
--- a/avconv_filter.c
+++ b/avconv_filter.c
@@ -76,7 +76,7 @@ DEF_CHOOSE_FORMAT(int, sample_rate, supported_samplerates, 0,
 DEF_CHOOSE_FORMAT(uint64_t, channel_layout, channel_layouts, 0,
                   GET_CH_LAYOUT_NAME)
 
-FilterGraph *init_simple_filtergraph(InputStream *ist, OutputStream *ost)
+int init_simple_filtergraph(InputStream *ist, OutputStream *ost)
 {
     FilterGraph *fg = av_mallocz(sizeof(*fg));
 
@@ -104,7 +104,7 @@ FilterGraph *init_simple_filtergraph(InputStream *ist, OutputStream *ost)
     GROW_ARRAY(filtergraphs, nb_filtergraphs);
     filtergraphs[nb_filtergraphs - 1] = fg;
 
-    return fg;
+    return 0;
 }
 
 static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
diff --git a/avconv_opt.c b/avconv_opt.c
index b760a18..9e90711 100644
--- a/avconv_opt.c
+++ b/avconv_opt.c
@@ -1469,7 +1469,7 @@ static int configure_complex_filters(void)
     int i, ret = 0;
 
     for (i = 0; i < nb_filtergraphs; i++)
-        if (!filtergraphs[i]->graph &&
+        if (!filtergraph_is_simple(filtergraphs[i]) &&
             (ret = configure_filtergraph(filtergraphs[i])) < 0)
             return ret;
     return 0;
@@ -1723,7 +1723,7 @@ loop_end:
     }
     av_dict_free(&unused_opts);
 
-    /* set the encoding/decoding_needed flags */
+    /* set the encoding/decoding_needed flags and create simple filtergraphs */
     for (i = of->ost_index; i < nb_output_streams; i++) {
         OutputStream *ost = output_streams[i];
 
@@ -1731,6 +1731,18 @@ loop_end:
         if (ost->encoding_needed && ost->source_index >= 0) {
             InputStream *ist = input_streams[ost->source_index];
             ist->decoding_needed = 1;
+
+            if (ost->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ||
+                ost->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
+                err = init_simple_filtergraph(ist, ost);
+                if (err < 0) {
+                    av_log(NULL, AV_LOG_ERROR,
+                           "Error initializing a simple filtergraph between streams "
+                           "%d:%d->%d:%d\n", ist->file_index, ost->source_index,
+                           nb_output_files - 1, ost->st->index);
+                    exit_program(1);
+                }
+            }
         }
     }
 



More information about the ffmpeg-cvslog mailing list