Commit Graph

255 Commits

Author SHA1 Message Date
Anton Khirnov 3d01996b24 fftools/ffmpeg_filter: change processing order in fg_finalise_bindings()
First bind all inputs in all filtergraphs, only then check that all
outputs are bound.

Needed by the following commit.
2024-04-09 10:34:18 +02:00
Andreas Rheinhardt 790f793844 avutil/common: Don't auto-include mem.h
There are lots of files that don't need it: The number of object
files that actually need it went down from 2011 to 884 here.

Keep it for external users in order to not cause breakages.

Also improve the other headers a bit while just at it.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-31 00:08:43 +01:00
Andreas Rheinhardt 1faafe738d fftools/ffmpeg_opt: Check before accessing union member
OptionDef.u is only an offset (i.e. its off member) iff OPT_FLAG_OFFSET
is true. Otherwise, the pointer arithmetic can be undefined behaviour.
UBSan warns about this (on 32bit arches):
src/fftools/ffmpeg_opt.c:102:15: runtime error: pointer index expression with base 0xffa4db10 overflowed to 0x56059a50

This commit fixes this by checking for OPT_FLAG_OFFSET first.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-17 15:10:05 +01:00
Anton Khirnov a9193f7b7d fftools/ffmpeg: add loopback decoding
This allows to send an encoder's output back to decoding and feed the
result into a complex filtergraph.
2024-03-13 08:01:27 +01:00
Anton Khirnov 7b51523f12 fftools/ffmpeg_opt: merge init_complex_filters() and check_filter_outputs()
The first of these binds inputs of complex filtergraphs to demuxer
streams (with a misleading comment claiming it *creates* complex
filtergraphs).

The second ensures that all filtergraph outputs are connected to an
encoder.

Merge them into a single function, which simplifies the ffmpeg_filter
API, is shorter, and will also be useful in following commits.

Also, rename misleadingly-named init_input_filter() to
fg_complex_bind_input().
2024-03-13 08:01:15 +01:00
Anton Khirnov e48055fdce fftools/ffmpeg: remove options deprecated before 6.0 2024-03-01 16:51:11 +01:00
Anton Khirnov e0da916b8f fftools/ffmpeg: optimize inter-thread queue sizes
Use 8 packets/frames by default rather than 1, which seems to provide
better throughput.

Allow -thread_queue_size to set the muxer queue size manually again.
2024-01-28 13:34:56 +01:00
Anton Khirnov 344d3a7d45 fftools/ffmpeg_opt: improve wording in option descriptions 2024-01-20 10:37:32 +01:00
Anton Khirnov 0b95e71aa0 fftools/ffmpeg_opt: briefly mention stream specifier syntax in help output 2024-01-20 10:37:32 +01:00
Anton Khirnov 43323c3802 fftools/ffmpeg_opt: add more structure to long help output
Split the "Per-file main options" section into
* per-file input and output
* per-file input-only
* per-file output-only
* per-stream
2024-01-20 10:37:32 +01:00
Anton Khirnov 67529ad8a4 fftools/cmdutils: drop alt_flags parameter from show_help_options()
No user sets it to more than one flag, so it is redundant with
req_flags.
2024-01-20 10:37:32 +01:00
Anton Khirnov 03aedbdd40 fftools/cmdutils: add a flag for per-stream options
Not all OPT_SPEC options are per-stream, this will allow identifying
those that are, which will be useful in following commits.
2024-01-20 10:37:32 +01:00
Anton Khirnov d8173cfcaf fftools/cmdutils: hide some information listing options from basic help
They are for advanced usage only and should not clutter basic output.
2024-01-20 10:37:32 +01:00
Anton Khirnov 08bebeb1be Revert "all: Don't set AVClass.item_name to its default value"
Some callers assume that item_name is always set, so this may be
considered an API break.

This reverts commit 0c6203c97a.
2024-01-20 10:34:48 +01:00
Anton Khirnov a8bc79c3fd fftools/ffmpeg: deprecate -filter_script
It is equivalent to -/filter.
2024-01-20 10:23:24 +01:00
Anton Khirnov c316c4c77b fftools/ffmpeg: deprecate -filter_complex_script
It is equivalent to -/filter_complex.
2024-01-20 10:23:24 +01:00
Anton Khirnov 6d17991b7e fftools/cmdutils: add option syntax for loading arbitrary arguments from a file
Aligned with analogous feature for filter options in ffmpeg CLI.
2024-01-20 10:23:24 +01:00
Anton Khirnov 8aed3911fc fftools/ffmpeg: make attachment filenames dynamically allocated
Do not store the supplied arg pointer directly. While that is valid for
now, it will become ephemeral in the future commits.
2024-01-20 10:23:24 +01:00
Anton Khirnov 568dfed06f fftools/ffmpeg_opt: mark -stream_group as expert option 2024-01-19 17:54:10 +01:00
Anton Khirnov ae06111d74 fftools/ffmpeg_demux: implement -bsf for input
Previously bitstream filters could only be applied right before muxing,
this allows to apply them right after demuxing.
2024-01-19 17:54:10 +01:00
Andreas Rheinhardt 0c6203c97a all: Don't set AVClass.item_name to its default value
Unnecessary since acf63d5350adeae551d412db699f8ca03f7e76b9;
also avoids relocations.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-12-22 15:12:33 +01:00
Anton Khirnov 6325aede08 fftools/ffmpeg: remove deprecated -[av]bsf
They were marked as deprecated over 10 years ago.
2023-12-22 11:39:57 +01:00
Anton Khirnov 7f982065a8 fftools/ffmpeg: mark -vsync for future removal
It has already been deprecated over a year ago.
2023-12-22 11:39:57 +01:00
Anton Khirnov 8d8c2b410f fftools/ffmpeg_opt: fix -dn flags
It's a data, not video option.
2023-12-22 11:39:57 +01:00
Anton Khirnov 84352c9891 fftools/ffmpeg_opt: print a section for data-stream options
Only show it with show_advanced (triggered by -h long), since data
streams themselves are an advanced topic.
2023-12-22 11:39:57 +01:00
Anton Khirnov 74df1b73d4 fftools/ffmpeg_opt: refine printing type-specific options
* filter subtitle/data options out of main, video and audio sections
* add filters that were missing entirely from the subtitle section
* add a missing section for advanced subtitle options
2023-12-22 11:39:57 +01:00
Anton Khirnov 0125cab385 fftools/ffmpeg_opt: mark more options as OPT_EXPERT
Reduces the basic help output to a reasonable size and stops confusing
users with options the vast majority will not need.
2023-12-22 11:39:57 +01:00
Anton Khirnov 86e8439994 fftools/ffmpeg_opt: update program description to match manpage
Cf. 2244722f1f
2023-12-22 11:39:57 +01:00
Anton Khirnov 41716214c2 fftools/ffmpeg: improve WARN_MULTIPLE_OPT_USAGE()
Currently it requires every single OPT_SPEC option to be accompanied by
an array of alternate names for this option. The vast majority of
options have no alternate names, resulting in a large numbers of
unnecessary single-element arrays that merely contain the option name.

Extend the option parsing API to allow marking options as having
alternate names, or as being the canonical name for some existing
alternatives. Use this new information to avoid the need for
abovementioned unnecessary single-element arrays.
2023-12-22 11:39:57 +01:00
Anton Khirnov 148fac277a fftools/ffmpeg: change the MATCH_PER_TYPE_OPT macro into a function
There is no reason for it to be a macro anymore, this makes the code
using it cleaner and simpler.
2023-12-22 11:39:57 +01:00
Anton Khirnov 0ba70a6792 fftools/cmdutils: add a struct for a list of SpecifierOpt
Significantly simplifies the code dealing with OPT_SPEC.
2023-12-22 11:39:57 +01:00
Anton Khirnov 2f1bc3b424 fftools/cmdutils: include OPT_PERFILE in OPT_OFFSET
And analogously OPT_OFFSET in OPT_SPEC. Previously the inclusion would
be implicit and required all code to remember this.
2023-12-22 11:39:57 +01:00
Anton Khirnov 5b1b132072 fftools/cmdutils: rename HAS_ARG to OPT_FUNC_ARG
For consistent namespacing with other option flags. Also, document and
enforce that it can only be set for func-type options.
2023-12-22 11:39:57 +01:00
Anton Khirnov d2e479a429 fftools: split off option types from other flags
These values are not actually flags, as only one of them can be
meaningfully set.
2023-12-22 11:39:57 +01:00
Anton Khirnov 074abeb57e fftools/ffmpeg_opt: move deprecated options to the end of the list
This way they don't clutter this already-cluttered code even further.
2023-12-22 11:39:57 +01:00
Anton Khirnov b472c46a70 fftools/cmdutils: simplify handling of the HAS_ARG option flag
This option flag only carries nontrivial information for options that
call a function, in all other cases its presence can be inferred from
the option type (bool options do not have arguments, all other types do)
and is thus nothing but useless clutter.

Change the option parsing code to infer its value when it can, and drop
the flag from options where it's not needed.
2023-12-22 11:39:57 +01:00
Anton Khirnov 25c98566e8 fftools/ffmpeg_opt: drop HAS_ARG from auto{scale,rotate}
It causes those options to be parsed as either
* -autofoo 0/1 (with an argument)
* -noautofoo   (without an argument)
This is unnecessary, confusing, and against the documentation; these are
also the only two bool options that take an argument.

This should not affect the users, as these options are on by default,
and are supposed to be used as -nofoo per the documentation.
2023-12-22 11:39:57 +01:00
James Almer ed670b9b98 ffmpeg: add support for muxing AVStreamGroups
Starting with IAMF support.

Signed-off-by: James Almer <jamrial@gmail.com>
2023-12-18 15:18:09 -03:00
Anton Khirnov 3dc319587f fftools/ffmpeg: deprecate -fps_mode/vsync drop
It depends on the ability of muxers to generate timestamps, which is
itself deprecated.
2023-12-18 08:50:02 +01:00
Anton Khirnov d119ae2fd8 fftools/ffmpeg: convert to a threaded architecture
Change the main loop and every component (demuxers, decoders, filters,
encoders, muxers) to use the previously added transcode scheduler. Every
instance of every such component was already running in a separate
thread, but now they can actually run in parallel.

Changes the results of ffmpeg-fix_sub_duration_heartbeat - tested by
JEEB to be more correct and deterministic.
2023-12-12 08:24:18 +01:00
Anton Khirnov 9b8cc36ce0 fftools/ffmpeg: add thread-aware transcode scheduling infrastructure
See the comment block at the top of fftools/ffmpeg_sched.h for more
details on what this scheduler is for.

This commit adds the scheduling code itself, along with minimal
integration with the rest of the program:
* allocating and freeing the scheduler
* passing it throughout the call stack in order to register the
  individual components (demuxers/decoders/filtergraphs/encoders/muxers)
  with the scheduler

The scheduler is not actually used as of this commit, so it should not
result in any change in behavior. That will change in future commits.
2023-12-12 08:24:18 +01:00
Anton Khirnov 5d58a35f98 fftools/ffmpeg: deprecate the -top option
It is badly named (should have been -top_field_first, or at least -tff),
underdocumented and underspecified, and (most importantly) entirely
redundant with the setfield filter.
2023-09-18 17:16:06 +02:00
Andreas Rheinhardt 071c625ad7 fftools/ffmpeg_opt: Reduce scope of variables for deprecated code
Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-07-23 17:55:38 +02:00
Andreas Rheinhardt 8bb1bcf47d fftools/ffmpeg_opt: Fix leak on error
Fixes Coverity id #1539096.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-07-23 17:55:38 +02:00
Andreas Rheinhardt 2654347d7a fftools/ffmpeg_opt: Fix leak on error
Fixes Coverity issue #1539097.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-07-23 17:55:38 +02:00
Anton Khirnov eda1fac27a fftools/cmdutils: return AVERROR_EXIT for OPT_EXIT options instead of aborting() 2023-07-20 20:47:46 +02:00
Anton Khirnov c56fabde27 fftools/ffmpeg_opt: consolidate printing errors in ffmpeg_parse_options() 2023-07-20 20:47:46 +02:00
Anton Khirnov 49ac7fc485 fftools: remove parse_time_or_die()
Replace it with calling av_parse_time() directly, which provides
graceful error handling and more accurate error messages.
2023-07-20 20:47:46 +02:00
Anton Khirnov 9cb47c78d6 fftools: return errors from parse_number_or_die() instead of aborting
Rename the function to just parse_number().
2023-07-20 20:47:40 +02:00
Anton Khirnov a50f90f1c2 fftools/ffmpeg_opt: replace exit_program() with returning error codes 2023-07-20 20:40:26 +02:00