Browse code

ffmpeg: generate more specific error message in case of inconsistent filtering options

In particular, distinguish if the option was -filter or -filter_script.

Suggested-by: Nicolas George

Stefano Sabatini authored on 2013/11/04 18:05:24
Showing 1 changed files
... ...
@@ -1172,13 +1172,11 @@ static void check_streamcopy_filters(OptionsContext *o, AVFormatContext *oc,
1172 1172
 {
1173 1173
     if (ost->filters_script || ost->filters) {
1174 1174
         av_log(NULL, AV_LOG_ERROR,
1175
-               "Filtergraph '%s' or filter_script '%s' was defined for %s output stream "
1176
-               "%d:%d but codec copy was selected.\n"
1175
+               "%s '%s' was defined for %s output stream %d:%d but codec copy was selected.\n"
1177 1176
                "Filtering and streamcopy cannot be used together.\n",
1178
-               (char *)av_x_if_null(ost->filters, "(none)"),
1179
-               (char *)av_x_if_null(ost->filters_script, "(none)"),
1180
-               av_get_media_type_string(type),
1181
-               ost->file_index, ost->index);
1177
+               ost->filters ? "Filtergraph" : "Filtergraph script",
1178
+               ost->filters ? ost->filters : ost->filters_script,
1179
+               av_get_media_type_string(type), ost->file_index, ost->index);
1182 1180
         exit_program(1);
1183 1181
     }
1184 1182
 }
... ...
@@ -1573,14 +1571,15 @@ static void init_output_filter(OutputFilter *ofilter, OptionsContext *o,
1573 1573
     }
1574 1574
 
1575 1575
     if (ost->avfilter && (ost->filters || ost->filters_script)) {
1576
-            av_log(NULL, AV_LOG_ERROR,
1577
-                   "Filter graph '%s' or filter script '%s' was specified through the -filter/-filter_script/-vf/-af option "
1578
-                   "for output stream %d:%d, which is fed from a complex filtergraph.\n"
1579
-                   "-filter/-filter_script and -filter_complex cannot be used together for the same stream.\n",
1580
-                   (char *)av_x_if_null(ost->filters, "(none)"),
1581
-                   (char *)av_x_if_null(ost->filters_script, "(none)"),
1582
-                   ost->file_index, ost->index);
1583
-            exit_program(1);
1576
+        const char *opt = ost->filters ? "-vf/-af/-filter" : "-filter_script";
1577
+        av_log(NULL, AV_LOG_ERROR,
1578
+               "%s '%s' was specified through the %s option "
1579
+               "for output stream %d:%d, which is fed from a complex filtergraph.\n"
1580
+               "%s and -filter_complex cannot be used together for the same stream.\n",
1581
+               ost->filters ? "Filtergraph" : "Filtergraph script",
1582
+               ost->filters ? ost->filters : ost->filters_script,
1583
+               opt, ost->file_index, ost->index, opt);
1584
+        exit_program(1);
1584 1585
     }
1585 1586
 
1586 1587
     if (configure_output_filter(ofilter->graph, ofilter, ofilter->out_tmp) < 0) {