1

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 2

3

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.

4
  • Very interesting, not clear from FFmpeg docs. So why was -filter not deprecated?
    – RopeySim
    Apr 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.
    – Gyan
    Apr 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.
    – Gyan
    Nov 16, 2022 at 6:32
2

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).

1
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.