This may seem like a strange question but... is it possible to do everything -filter can do using only -filter_complex filters? That is, is there anything that -filter can do, that is not possible with -filter_complex?
2 Answers
Yes. -filter
and -filter_complex / -lavfi
both set up a filtergraph. The difference is that the latter can be fed with multiple inputs and can supply multiple outputs. -filter
is limited to one input and one output stream. There is a hack to introduce additional inputs in -filter
using source filters but that is not advised. All filters that can be used in -filter
can be used in -filter_complex
.
Note that if you specify filtering for a conditionally mapped stream (-map 0:a:1?
), and that stream does not exist, the command will proceed with -filter
but not with -filter_complex
.
-
Very interesting, not clear from FFmpeg docs. So why was -filter not deprecated?– RopeySimApr 2, 2020 at 7:58
-
-filter is still useful and there's no reason for it to be deprecated. For many common use cases, a simple filterchain suffices.– GyanApr 2, 2020 at 11:09
-
Is there any reason that conditional streams aren't supported by
-filter_complex
? Nov 16, 2022 at 1:35 -
In a complex graph, filter outputs (and inputs) can interact with each other e.g. blend. So, it's not straightforward to redraw a graph where some inputs are missing. Can be done in a limited manner, in principle, but the logic would be convoluted.– GyanNov 16, 2022 at 6:32
No, -filter_complex is not a substitute for -filter. Specifically:
The point of -filter_complex is that there is no 1:1 map between input and output. Therefore there is no map to decide which metadata to copy.
Moreover, there is no simple workaround to this limitation. To preserve per-stream metadata, use -filter whenever possible. With -filter_complex, stream metadata would have to be mapped manually for all streams in the output file (using 1 -map_metadata:s per stream).
-
Upvoted because this is an enlightening answer, but it would make more sense to restate the first line, which is confusing - the real answer seems to be that it is mostly a substitute for
-filter
, except in the case of the one caveat that you've come across, and the one that Gyan mentions in his answer. Nov 16, 2022 at 1:34