aboutsummaryrefslogtreecommitdiffstats
path: root/fftools/cmdutils.c
Commit message (Collapse)AuthorAgeFilesLines
* fftools/cmdutils: Add av_freep() to avoid memory leakJiasheng Jiang2025-07-201-2/+5
| | | | | | | | Add av_freep() to free new_elem to avoid memory leak. Fixes: 3ca1e31e63 ("fftools/cmdutils: Atomically add elements to list of pointers, fix crash") Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* fftools/cmdutils: don't try to load arguments from file if not neededKacper Michajłow2025-07-051-2/+3
| | | | | | | | | | | | CLI option parser checks if argument exists when needed, but in this case only OPT_TYPE_BOOL where checked, so OPT_TYPE_FUNC without argument where trying to load a file from `arg` which is NULL in this case. Fixes crash on `ffmpeg -/version` Fixes: 6d17991b7e1bf1a5d104c8a6261709f7e6640d97 Signed-off-by: Kacper Michajłow <kasper93@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* fftools/cmdutils: fix error message for "ffmpeg -init_hw_device list"Jun Zhao2025-04-031-3/+5
| | | | | | | | | | | | When running 'ffmpeg -init_hw_device list' to display available hardware devices, it incorrectly shows an error message: "Failed to set value 'list' for option 'init_hw_device': Immediate exit requested" This is a regression introduced by commit a50f90f1c23. The command is actually working as intended - it should exit after listing devices, but shouldn't display an error message. Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* fftools/cmdutils: do not treat single '-' as an option in locate_option()Anton Khirnov2024-10-101-1/+2
| | | | | Fixes early parsing of trailing -v/-loglevel while using '-' to output to stdout.
* fftools/cmdutils: group related calls togetherAnton Khirnov2024-10-101-1/+2
| | | | For readability only, should have no functional effect.
* fftools/ffmpeg: add support for multiview videoAnton Khirnov2024-09-231-1/+1
| | | | | | | | This extends the syntax for specifying input streams in -map and complex filtergraph labels, to allow selecting a view by view ID, index, or position. The corresponding decoder is then set up to decode the appropriate view and send frames for that view to the correct filtergraph input(s).
* fftools/cmdutils: extend stream specifiers to match by dispositionAnton Khirnov2024-09-181-0/+41
|
* fftools/cmdutils: tighten condition for media type stream specifiersAnton Khirnov2024-09-151-2/+9
| | | | | | | Require the character indicating media type to be followed by a non-alphanumeric character (or end of string). Needed by future syntax extensions.
* fftools/cmdutils: fix variable shadowingMarvin Scholz2024-09-131-3/+3
|
* fftools/ffmpeg: use new stream specifier API in opt_match_per_stream*()Anton Khirnov2024-08-131-0/+8
| | | | Removes a lot of error checking code, as matching cannot fail.
* fftools/cmdutils: split stream specifier parsing and matchingAnton Khirnov2024-08-131-173/+265
| | | | | | | | | | | | | | | | | | | | | | | | | This approach has the major advantage that only parsing can fail (due to a malformed specifier or memory allocation failure). Since parsing is done generically, while matching is per-option, this will allow to remove substantial amounts of error checking code in following commits. The new code also explicitly allows stream specifiers to be followed by additional characters, which should allow cleaner handling of optional maps, i.e. -map <stream_specifier>?, which is currently implemented in a hacky way that breaks when the stream specifier itself contains the '?' character (this can happen when matching metadata). It will also allow further extending the syntax, which will be useful in following commits. This introduces some minor behaviour changes: * Matching metadata tags now requires the ':' character in keys or values to be escaped. Previously it could not be present in keys, and would be used verbatim in values. The change is required in order to know where the value terminates. * Multiple stream types in a single specifier are now rejected - such a specifier makes no sense. * Non-existent stream group ID or index is now ignored with a warning rather than causing a failure. This is consistent with program handling and is required to make matching fail-free.
* fftools/cmdutils: put stream specifier handling back into cmdutilsAnton Khirnov2024-08-131-1/+210
| | | | | | | | | | | | | | Stream specifiers were originally designed exclusively for CLI use and were not intended to be public API. Handling them in avformat places major restrictions on how they are used. E.g. if ffmpeg CLI wishes to override some stream parameters, it has to change the demuxer fields (since avformat_match_stream_specifier() does not have access to anything else). However, such fields are supposed to be read-only for the caller. Furthermore having this code in avformat restricts extending the specifier syntax. An example of such an extension will be added in following commits.
* fftools/ffmpeg: replace MATCH_PER_STREAM_OPT(.., str, ..) with a functionAnton Khirnov2024-08-131-1/+5
| | | | | | | | | | | | | | | | | | | | | This has multiple advantages: * The macro has multiple parameters that often have similar or identical values, yet very different meanings (one is the name of the OptionsContext member where the parsed options are stored, the other the name of the variable into which the result is written); this change makes each of these explicit. * The macro returns on failure, which may cause leaks - this was the reason for adding MATCH_PER_STREAM_OPT_CLEAN(), also ost_add() currently leaks encoder_opts. The new function returns failure to its caller, which decides how to deal with it. While that adds a lot of error checks/forwards for now, those will be reduced in following commits. * new code is type- and const- correct Invocations of MATCH_PER_STREAM_OPT() with other types will be converted in following commits.
* fftools/ffmpeg: rewrite checking whether codec AVOptions have been usedAnton Khirnov2024-07-031-5/+12
| | | | | | Share the code between encoding and decoding. Instead of checking every stream's options dictionary (which is also used for other purposes), track all used options in a dedicated dictionary.
* fftools/cmdutils: Add protective () to FLAGSMichael Niedermayer2024-06-071-1/+1
| | | | | | | issue found while reviewing CID1452612 Free of array-typed value Sponsored-by: Sovereign Tech Fund Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* fftools: move check_avoptions and remove_avoptions to cmdutilsMarton Balint2024-05-271-0/+20
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* fftools: Fix implicit-const-int-float-conversion warningZhao Zhili2024-04-231-1/+1
| | | | Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
* avutil/common: Don't auto-include mem.hAndreas Rheinhardt2024-03-311-4/+1
| | | | | | | | | | | 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>
* fftools/cmdutils: do not use a random codec's private optionsAnton Khirnov2024-03-281-4/+0
| | | | | | | There is only a single caller of filter_codec_opts() that passes a NULL codec to it, which is streamcopy in ffmpeg CLI. In that case we only want generic AVCodecContext options, not private options of any specific encoder.
* fftools/ffmpeg: add loopback decodingAnton Khirnov2024-03-131-1/+1
| | | | | This allows to send an encoder's output back to decoding and feed the result into a complex filtergraph.
* fftools/cmdutils: fix printing group name in split_commandline()Anton Khirnov2024-03-131-4/+5
|
* fftools/cmdutils: Inline print_error()Andreas Rheinhardt2024-03-041-5/+0
| | | | | | | | It is only used by ffprobe (once) and ffplay (twice); inlining it avoids including it unnecessarily into ffmpeg. Reviewed-by: Stefano Sabatini <stefasab@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* fftools/cmdutils: remove harmful variable shadowingAnton Khirnov2024-02-241-2/+0
| | | | It causes write_option() to return 0 when calling func_arg() fails.
* fftools/cmdutils: Don't cast const awayAndreas Rheinhardt2024-02-091-1/+1
| | | | | Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* fftools/cmdutils: surround option arguments by <> in help outputAnton Khirnov2024-01-201-4/+3
| | | | Makes it more clear that they are placeholders for actual values.
* fftools/cmdutils: indicate specifiers in option syntax in help outputAnton Khirnov2024-01-201-0/+6
|
* fftools/cmdutils: drop alt_flags parameter from show_help_options()Anton Khirnov2024-01-201-2/+1
| | | | | No user sets it to more than one flag, so it is redundant with req_flags.
* fftools/cmdutils: add option syntax for loading arbitrary arguments from a fileAnton Khirnov2024-01-201-16/+83
| | | | Aligned with analogous feature for filter options in ffmpeg CLI.
* fftools/ffmpeg: improve WARN_MULTIPLE_OPT_USAGE()Anton Khirnov2023-12-221-5/+8
| | | | | | | | | | | | 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.
* fftools/ffmpeg: change the MATCH_PER_TYPE_OPT macro into a functionAnton Khirnov2023-12-221-1/+5
| | | | | There is no reason for it to be a macro anymore, this makes the code using it cleaner and simpler.
* fftools/cmdutils: add a struct for a list of SpecifierOptAnton Khirnov2023-12-221-6/+4
| | | | Significantly simplifies the code dealing with OPT_SPEC.
* fftools/cmdutils: check valid flags for OPT_TYPE_FUNCAnton Khirnov2023-12-221-0/+3
| | | | SPEC and OFFSET do not make sense for functions.
* fftools/cmdutils: include OPT_PERFILE in OPT_OFFSETAnton Khirnov2023-12-221-3/+3
| | | | | And analogously OPT_OFFSET in OPT_SPEC. Previously the inclusion would be implicit and required all code to remember this.
* fftools/cmdutils: rename HAS_ARG to OPT_FUNC_ARGAnton Khirnov2023-12-221-2/+6
| | | | | For consistent namespacing with other option flags. Also, document and enforce that it can only be set for func-type options.
* fftools: split off option types from other flagsAnton Khirnov2023-12-221-24/+27
| | | | | These values are not actually flags, as only one of them can be meaningfully set.
* fftools/cmdutils: simplify handling of the HAS_ARG option flagAnton Khirnov2023-12-221-4/+15
| | | | | | | | | | 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.
* fftools/cmdutils: only set array size after allocation succeededAnton Khirnov2023-11-091-2/+2
|
* fftools/ffmpeg: stop calling exit_program()Anton Khirnov2023-07-201-15/+0
| | | | Remove exit_program() and register_exit(), as they are no longer used.
* fftools/opt_common: replace report_and_exit() with returning an error codeAnton Khirnov2023-07-201-6/+0
| | | | Remove report_and_exit(), as it has no more users.
* fftools/cmdutils: return AVERROR_EXIT for OPT_EXIT options instead of aborting()Anton Khirnov2023-07-201-1/+1
|
* fftools/cmdutils: add error handling to filter_codec_opts()Anton Khirnov2023-07-201-13/+28
|
* fftools/cmdutils: constify the first parameter of filter_codec_opts()Anton Khirnov2023-07-201-1/+1
|
* fftools: handle errors in parse_options()Anton Khirnov2023-07-201-5/+10
|
* fftools: remove parse_time_or_die()Anton Khirnov2023-07-201-13/+6
| | | | | Replace it with calling av_parse_time() directly, which provides graceful error handling and more accurate error messages.
* fftools: return errors from parse_number_or_die() instead of abortingAnton Khirnov2023-07-201-10/+29
| | | | Rename the function to just parse_number().
* fftools/cmdutils: add error handling to GROW_ARRAY()Anton Khirnov2023-07-201-10/+34
|
* fftools/cmdutils: add error handling to grow_array()Anton Khirnov2023-07-201-7/+12
|
* fftools/cmdutils: add error handling to allocate_array_elem()Anton Khirnov2023-07-201-1/+1
|
* fftools/cmdutils: return error codes from setup_find_stream_info_opts() ↵Anton Khirnov2023-07-201-9/+21
| | | | instead of aborting
* fftools/cmdutils: constify the argument of get_rotation()Anton Khirnov2023-05-221-1/+1
|