aboutsummaryrefslogtreecommitdiffstats
path: root/fftools/ffmpeg_mux_init.c
Commit message (Collapse)AuthorAgeFilesLines
* fftools/ffmpeg_mux_init: Fix double-free on errorAndreas Rheinhardt2024-03-261-2/+7
| | | | | | | | | | | | | | | | | | | | | MATCH_PER_STREAM_OPT iterates over all options of a given OptionDef and tests whether they apply to the current stream; if so, they are set to ost->apad, otherwise, the code errors out. If no error happens, ost->apad is av_strdup'ed in order to take ownership of this pointer. But this means that setting it originally was premature, as it leads to double-frees when an error happens lateron. This can simply be reproduced with ffmpeg -filter_complex anullsrc -apad bar -apad:n baz -f null - This is a regression since 83ace80bfd80fcdba2c65fa1d554923ea931d5bd. Fix this by using a temporary variable instead of directly setting ost->apad. Also only strdup the string if it actually is != NULL. Reviewed-by: Marth64 <marth64@proxyid.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avutil: remove deprecated FF_API_OLD_CHANNEL_LAYOUTJames Almer2024-03-071-18/+3
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* fftools/ffmpeg: remove options deprecated before 6.0Anton Khirnov2024-03-011-74/+2
|
* fftools/ffmpeg: declare loop indices inside loopsAnton Khirnov2024-02-241-6/+3
|
* fftools/ffmpeg_mux_init: Fix attachment_filename use-after-freeAndreas Rheinhardt2024-02-181-1/+9
| | | | | | | | | | | | | | The filename is freed with the OptionsContext and therefore there will be a use-after-free when reporting the filename in print_stream_maps(). So create a copy of the string. This is a regression since 8aed3911fc454e79697e183660bf30d31334a64b. fate-lavf-mkv_attachment exhibits it (and reports a random nonsense filename here), but this does not make the test fail (not even with valgrind; only with ASAN, as it aborts on use-after-free). Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* all: use designated initializers for AVOption.unitAnton Khirnov2024-02-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Makes it robust against adding fields before it, which will be useful in following commits. Majority of the patch generated by the following Coccinelle script: @@ typedef AVOption; identifier arr_name; initializer list il; initializer list[8] il1; expression tail; @@ AVOption arr_name[] = { il, { il1, - tail + .unit = tail }, ... }; with some manual changes, as the script: * has trouble with options defined inside macros * sometimes does not handle options under an #else branch * sometimes swallows whitespace
* fftools/ffmpeg: optimize inter-thread queue sizesAnton Khirnov2024-01-281-2/+1
| | | | | | | 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.
* fftools/ffmpeg_mux_init: don't free the AVDictionaryEntry until after it's ↵James Almer2024-01-221-1/+1
| | | | | | been used Signed-off-by: James Almer <jamrial@gmail.com>
* fftools/ffmpeg_mux_init: remove whitespaces from input arguments when ↵James Almer2024-01-221-1/+10
| | | | | | | | parsing stream groups If the arguments are read from a file, things like line breaks could be present Signed-off-by: James Almer <jamrial@gmail.com>
* Revert "all: Don't set AVClass.item_name to its default value"Anton Khirnov2024-01-201-0/+1
| | | | | | | Some callers assume that item_name is always set, so this may be considered an API break. This reverts commit 0c6203c97a99f69dbaa6e4011d48c331e1111f5e.
* fftools/ffmpeg: deprecate -filter_scriptAnton Khirnov2024-01-201-6/+30
| | | | It is equivalent to -/filter.
* all: Don't set AVClass.item_name to its default valueAndreas Rheinhardt2023-12-221-1/+0
| | | | | | | | Unnecessary since acf63d5350adeae551d412db699f8ca03f7e76b9; also avoids relocations. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* fftools/ffmpeg: mark -vsync for future removalAnton Khirnov2023-12-221-0/+4
| | | | It has already been deprecated over a year ago.
* fftools/ffmpeg: improve WARN_MULTIPLE_OPT_USAGE()Anton Khirnov2023-12-221-41/+0
| | | | | | | | | | | | 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-2/+2
| | | | | 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-18/+18
| | | | Significantly simplifies the code dealing with OPT_SPEC.
* ffmpeg_mux_init: use strtoll() to parse stream and group indexesJames Almer2023-12-211-6/+9
| | | | | | | | | | Long is 32 bits signed on Windows, and nb_stream{s,_groups} are both unsigned int. In a realistic scenario this wont make a difference, but it's still proper. Also ensure the parsed string is an integer while at it. Signed-off-by: James Almer <jamrial@gmail.com>
* ffmpeg: add support for muxing AVStreamGroupsJames Almer2023-12-181-0/+342
| | | | | | Starting with IAMF support. Signed-off-by: James Almer <jamrial@gmail.com>
* fftools/ffmpeg: use a mutex for enc_stats_write()Anton Khirnov2023-12-181-0/+5
| | | | | It may be called concurrently from different threads to write into the same file.
* fftools/ffmpeg: print keyframe information with -stats_*Anton Khirnov2023-12-181-0/+1
|
* fftools/ffmpeg_mux_init: change 1-bit bitfields from int to unsignedAnton Khirnov2023-12-181-3/+3
| | | | | | | They cannot store 1 as signed, only 0 and -1. Avoids warnings such as: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Wsingle-bit-bitfield-constant-conversion]
* fftools/ffmpeg_mux: move OutputStream.sq_idx_mux to private dataAnton Khirnov2023-12-141-6/+6
| | | | It should not be accessed outside of ffmpeg_mux*
* fftools/ffmpeg: replace OutputStream.file_index by a pointerAnton Khirnov2023-12-141-6/+6
| | | | Reduces the need to use the output_files global array.
* fftools/ffmpeg: replace InputStream.file_index by a pointerAnton Khirnov2023-12-141-5/+5
| | | | Reduces the need to use the input_files global array.
* fftools/ffmpeg: convert to a threaded architectureAnton Khirnov2023-12-121-65/+23
| | | | | | | | | | 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.
* fftools/ffmpeg: add thread-aware transcode scheduling infrastructureAnton Khirnov2023-12-121-11/+95
| | | | | | | | | | | | | | | 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.
* fftools/ffmpeg_mux_init: Restrict disabling automatic copying of metadataAndreas Rheinhardt2023-11-021-3/+3
| | | | | | | | Fixes ticket #10638 (and should also fix ticket #10482) by restoring the behaviour from before 3c7dd5ed37da6d2de06c4850de5a319ca9cdd47f. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* fftools/ffmpeg_enc: merge -force_key_frames source/source_no_dropAnton Khirnov2023-10-101-1/+5
| | | | | | | Always use the functionality of the latter, which makes more sense as it avoids losing keyframes due to vsync code dropping frames. Deprecate the 'source_no_drop' value, as it is now redundant.
* fftools/ffmpeg: stop using AVStream.side_dataJames Almer2023-10-061-10/+14
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* fftools/ffmpeg: deprecate the -top optionAnton Khirnov2023-09-181-0/+4
| | | | | | 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.
* fftools/ffmpeg_mux: stop rescaling timestamps in of_streamcopy()Anton Khirnov2023-08-301-2/+0
| | | | | | | | | | | | | | | | This function converts packet timestamps from the input stream timebase to OutputStream.mux_timebase, which may or may not be equal to the actual output AVStream timebase (and even when it is, this may not always be the optimal choice due to bitstream filtering). Just keep the timestamps in input stream timebase, they will be rescaled as needed before bitstream filtering and/or sending the packet to the muxer. Move the av_rescale_delta() call for audio (needed to preserve accuracy with coarse demuxer timebases) to write_packet. Drop now-unused OutputStream.mux_timebase.
* fftools/ffmpeg_mux_init: Fix leak on errorAndreas Rheinhardt2023-07-231-1/+1
| | | | | | | Fixes Coverity issue #1539098. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* fftools/cmdutils: add error handling to filter_codec_opts()Anton Khirnov2023-07-201-3/+8
|
* fftools: remove parse_time_or_die()Anton Khirnov2023-07-201-6/+24
| | | | | 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-2/+5
| | | | Rename the function to just parse_number().
* fftools/ffmpeg: return errors from find_codec_or_die() instead of abortingAnton Khirnov2023-07-201-1/+3
| | | | Rename the function to just find_codec().
* fftools/cmdutils: add error handling to GROW_ARRAY()Anton Khirnov2023-07-201-3/+12
|
* fftools/cmdutils: add error handling to allocate_array_elem()Anton Khirnov2023-07-201-2/+14
|
* fftools/ffmpeg_opt: reimplement -streamid using a dictionaryAnton Khirnov2023-07-201-3/+15
| | | | | | This does not require an arbitrary limit on the number of streams. Also, return error codes from opt_streamid() instead of aborting.
* fftools/ffmpeg_filter: return error codes from ofilter_bind_ost() instead of ↵Anton Khirnov2023-07-201-1/+3
| | | | aborting
* fftools/ffmpeg_mux_init: avoid invalid memory access in set_dispositions()Anton Khirnov2023-07-201-6/+7
| | | | | This function assumes AVMEDIA_* are always positive, while in fact it can also handle AVMEDIA_TYPE_UNKNOWN, which is -1.
* fftools/ffmpeg_filter: move "smart" pixfmt selection to ffmpeg_mux_initAnton Khirnov2023-07-201-0/+29
| | | | | This code works on encoder information and has no interaction with filtering, so it does not belong in ffmpeg_filter.
* fftools/ffmpeg_mux_init: handle pixel format endiannessAnton Khirnov2023-07-201-3/+52
| | | | | | | | | | When -pix_fmt designates a BE/LE pixel format, it gets translated into the native one by av_get_pix_fmt(). This may not always be the best choice, as the encoder might only support one endianness. In such a case, explicitly choose the endianness supported by the encoder. While this is currently redundant with choose_pixel_fmt() in ffmpeg_filter.c, the latter code will be deprecated in following commits.
* fftools/ffmpeg_mux_init: fix an array declarationAnton Khirnov2023-07-161-1/+1
| | | | | | | map_func is supposed to be an array of const pointer to function returning int, not an array of pointer to function returning const int. Reported-By: Martin Storsjö
* fftools/ffmpeg: rework -enc_time_base handlingAnton Khirnov2023-07-151-12/+19
| | | | | | | | | Read the timebase from FrameData rather than the input stream. This should fix #10393 and generally be more reliable. Replace the use of '-1' to indicate demuxing timebase with the string 'demux'. Also allow to request filter timebase with '-enc_time_base filter'.
* fftools/ffmpeg_mux_init: drop an obsolete assignmentAnton Khirnov2023-07-151-1/+0
| | | | | | | | This line was added in c30a4489b44 along with AVStream.sample_aspect_ratio. However, configuring SAR for video encoding is now done after this code (specifically in enc_open(), which is called when the first video frame to be encoded is obtained), so this line cannot have any meaningful effect.
* fftools/ffmpeg_mux_init: replace all remaining aborts with returning error codesAnton Khirnov2023-07-151-47/+79
| | | | Mainly concerns new_stream_*() and their callees.
* fftools/ffmpeg_mux_init: return error codes from metadata processing instead ↵Anton Khirnov2023-07-151-24/+39
| | | | of aborting
* fftools/ffmpeg_mux_init: improve of_add_programs()Anton Khirnov2023-07-151-56/+49
| | | | | | | | | Replace duplicated(!) and broken* custom string parsing with av_dict_parse_string(). Return error codes instead of aborting. * e.g. it treats NULL returned from av_get_token() as "separator not found", when in fact av_get_token() only returns NULL on memory allocation failure
* fftools/ffmpeg_mux_init: return error codes from validate_enc_avopt() ↵Anton Khirnov2023-07-151-3/+7
| | | | instead of aborting