[FFmpeg-devel] [RFC] On behaviour of unlabelled outputs in filtergraphs.

Nicolas George george at nsup.org
Fri May 11 12:38:17 EEST 2018

Gyan Doshi (2018-05-09):
> In the open ticket 7089, I reported that (terminal) filters with unlabelled
> output pads are automatically forwarded to the first output file and ordered
> before any expressly mapped streams. There's no warning issued.
> Is this behaviour intended?

Short answer: yes.

> In the section on filtergraph syntax @
> https://ffmpeg.org/ffmpeg-filters.html#Filtergraph-syntax-1,
> it says,
>     "If an output pad is not labelled, it is linked by default to the
>      first unlabelled input pad of the next filter in the filterchain."
> and
>     "In a complete filterchain all the unlabelled filter input and
>      output pads must be connected. A filtergraph is considered valid
>      if all the filter input and output pads of all the filterchains are
>      connected."
> There's no mention of unlabelled output pads being sent to an output file.

This section is about API use. The command-line tool is built around the
API and defines its own semantic. In this particular instance, the
semantic is that unconnected inputs are connected to input streams and
unconnected outputs are connected to output streams.

> If the present behaviour does not constitute a bug I'll modify the docs.

Do not hesitate to do that.

> In the section on Stream Selection @
> https://ffmpeg.org/ffmpeg.html#Stream-selection,
> it says,
>     "By default, ffmpeg includes only one stream of each type (video,
>      audio, subtitle) present in the input files and adds them to each
>      output file. It picks the "best" of each ... For full manual
>      control, use the -map option, which disables the defaults just
>      described."
> So, in the absence of any map directives, only one stream at most of each of
> the three stream types should be included, and these should be the 'best'
> streams from among the inputs. But all unlabelled output pads are included,
> however many they are, and none of them may be the 'best' stream since the
> stream(s) being filtered may not have been selected on the same criterion.
> And in the presence of the map option, by automatically including streams,
> "full manual control" is not true.

The behaviour you are observing is documented in the paragraph about the
-filter_complex option:

           Output link labels are referred to with -map. Unlabeled outputs are
           added to the first output file.

It could bear repeating at other logical places.

Note that the behaviour when explicit -map options are present: when
they are, automatic selection of "best" input streams is disabled, and
it would seem logical that automatic selection of unlabelled filter
outputs would be disabled too. I would not oppose adding a warning for
that case, and even in time changing the default.

But the case without -map is definitely intentional and need to stay,
because many people use it.


  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20180511/2bbf6bd5/attachment.sig>

More information about the ffmpeg-devel mailing list