Commit Graph

214 Commits

Author SHA1 Message Date
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
Anton Khirnov
6c6f13baf3 fftools/ffmpeg: return errors from find_codec_or_die() instead of aborting
Rename the function to just find_codec().
2023-07-20 20:40:26 +02:00
Anton Khirnov
2e6afa799e fftools/cmdutils: add error handling to GROW_ARRAY() 2023-07-20 20:40:26 +02:00
Anton Khirnov
26e1e80152 fftools/ffmpeg_opt: reimplement -streamid using a dictionary
This does not require an arbitrary limit on the number of streams.

Also, return error codes from opt_streamid() instead of aborting.
2023-07-20 20:40:26 +02:00
Anton Khirnov
5ba7aa2ce8 fftools/ffmpeg_filter: return error codes from fg_create() instead of aborting 2023-07-20 20:40:26 +02:00
Anton Khirnov
8815adfe75 fftools/ffmpeg_filter: replace remaining exit_program() with error codes 2023-07-20 20:39:42 +02:00
Anton Khirnov
cce294638b fftools/ffmpeg: return errors from assert_file_overwrite() instead of aborting 2023-07-15 11:02:11 +02:00
Davy Durham
2ae16b05d6 fftools/ffmpeg: add ability to set a input burst time before readrate is enforced
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2023-05-07 15:48:15 +02:00
Anton Khirnov
5a04aae821 fftools/ffmpeg: deprecate -adrift_threshold
This option has had no effect since -async was removed in
3d86a13b47
2023-05-02 10:59:24 +02:00
Anton Khirnov
8b56480652 fftools/ffmpeg_filter: add a function for creating a filtergraph
Code creating a new filtergraph is currently duplicated in 3 places.
This commit unifies it and moves towards making filtergraphs more
self-contained.
2023-04-24 16:56:06 +02:00
Sil Vilerino
5ff1430452 fftools/ffmpeg_opt: Document VAAPI -device usage for DirectX Adapter
Initial review at https://github.com/intel-media-ci/ffmpeg/pull/619/

Signed-off-by: Sil Vilerino <sivileri@microsoft.com>
Reviewed-by: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
Reviewed-by: Wu, Tong1 <tong1.wu@intel.com>
2023-04-24 13:24:41 +08:00
Anton Khirnov
2f24290c8e fftools/ffmpeg: disable and deprecate -qphist
This option adds a long string of numbers to the progress line, where
i-th number contains the base-2 logarithm of the number of times a frame
with this QP value was seen by print_report().

There are multiple problems with this feature:
* despite this existing since 2005, web search shows no indication
  that it was ever useful for any meaningful purpose;
* the format of what is printed is entirely undocumented, one has to
  find it out from the source code;
* QP values above 31 are silently ignored;
* it only works with one video stream;
* as it relies on global state, it is in conflict with ongoing
  architectural changes.

It then seems that the nontrivial cost of maintaining this option is not
worth its negligible (or possibly negative - since it pollutes the
already large option space) value.
Users who really need similar functionality can also implement it
themselves using -vstats.
2023-04-13 15:11:56 +02:00
Anton Khirnov
2c4dcbd66b fftools/ffmpeg: rename -enc_stats* to -stats_enc*
This is consistent with -stats_mux*

As the options were added very recently, this should not break any
users.
2023-02-10 11:02:13 +01:00
Anton Khirnov
42a0dd6e7e fftools/ffmpeg: add an option for writing pre-muxing stats
Analogous to -enc_stats*, but happens right before muxing. Useful
because bitstream filters and the sync queue can modify packets after
encoding and before muxing. Also has access to the muxing timebase.
2023-02-09 15:24:15 +01:00
Marth64
25f31929b6 ffmpeg_opt: move help text for -ab/-b:a to audio category
Since at least 4.4.3, -ab/-b:a help text was in the video section
of ffmpeg -h, but these are audio options.

Signed-off-by: Marth64 <marth64@proxyid.net>
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2023-02-09 12:45:53 +01:00
Jan Ekström
9a820ec8b1 ffmpeg: add video heartbeat capability to fix_sub_duration
Splits the currently handled subtitle at random access point
packets that can be configured to follow a specific output stream.
Currently only subtitle streams which are directly mapped into the
same output in which the heartbeat stream resides are affected.

This way the subtitle - which is known to be shown at this time
can be split and passed to muxer before its full duration is
yet known. This is also a drawback, as this essentially outputs
multiple subtitles from a single input subtitle that continues
over multiple random access points. Thus this feature should not
be utilized in cases where subtitle output latency does not matter.

Co-authored-by: Andrzej Nadachowski <andrzej.nadachowski@24i.com>
Co-authored-by: Bernard Boulay <bernard.boulay@24i.com>

Signed-off-by: Jan Ekström <jan.ekstrom@24i.com>
2023-02-03 16:17:29 +02:00
Anton Khirnov
9b5036fabd fftools/ffmpeg: add an AVClass to MuxStream/OutputStream
Use it for logging. This makes log messages related to this output
stream more consistent.
2023-01-29 09:12:22 +01:00
Anton Khirnov
425b2c4a56 fftools/ffmpeg: add options for writing encoding stats
Similar to -vstats, but more flexible:
- works for audio as well as video
- frame and/or packet information
- user-specifiable format
2023-01-29 09:09:59 +01:00
Marvin Scholz
f1907faab4 fftools: use av_dict_iterate
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-12-01 11:21:14 +01:00
Anton Khirnov
fd8bf8d3b5 fftools/ffmpeg: remove the input_streams global
Replace it with an array of streams in each InputFile. This is a more
accurate reflection of the actual relationship between InputStream and
InputFile.

Analogous to what was previously done to output streams in
7ef7a22251.
2022-11-23 10:36:23 +01:00
Anton Khirnov
b58264217b fftools/ffmpeg_mux_init: drop an always-false check
It cannot be true since 1959351aec. Effectively reverts 6a3833e141.
2022-11-17 10:52:58 +01:00
Anton Khirnov
52380a055b fftools/ffmpeg_mux_init: move validating codec avoptions to a separate function 2022-11-17 10:52:58 +01:00
Anton Khirnov
c15eb2773a fftools/ffmpeg_[de]mux: constify all uses of OptionsContext 2022-11-16 08:41:14 +01:00
Gyan Doshi
5ccd4d3060 ffmpeg: fix implementation of updated input start time
The current adjustment of input start times just adjusts the tsoffset.
And it does so, by resetting the tsoffset to nullify the new start time.
This leads to breakage of -copyts, ignoring of input_ts_offset, breaking
of -isync as well as breaking wrap correction.

Fixed by taking cognizance of these parameters, and by correcting start times
just before sync offsets are applied.
2022-11-03 14:38:42 +05:30
Gyan Doshi
93faba449c ffmpeg: shift start time correction to ffmpeg_opt
In preparation for applying start time correction that accounts for all
factors such as copyts, input_ts_offset ..etc
2022-11-03 14:38:24 +05:30
Anton Khirnov
78efefa9a5 fftools/ffmpeg_opt: move opening input files to ffmpeg_demux.c
This is similar to what was done before for output files and will allow
introducing demuxer-private state in future commits

Unlike for muxing, the code is moved to existing ffmpeg_demux.c rather
than to a new file. The reason is just file size - the demuxing code is
much smaller than muxing.
2022-10-25 11:04:42 +02:00
Anton Khirnov
4cfffdd551 fftools/ffmpeg: rename read_file() to avoid conflict with libass
libass defines a non-static read_file() symbol, which causes conflicts
with static linking.
2022-10-21 10:13:16 +02:00
Jan Ekström
c889248647 ffmpeg: Add display_{rotation, hflip, vflip} options
This enables overriding the rotation as well as horizontal/vertical
flip state of a specific video stream on the input side.

Additionally, switch the singular test that was utilizing the rotation
metadata to instead override the input display rotation, thus leading
to the same result.
2022-10-19 11:53:52 +02:00
Andreas Rheinhardt
ff2c37d449 fftools/ffmpeg_opt: Move stuff only used by ffmpeg_mux_init to it
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-18 14:19:11 +02:00
Anton Khirnov
18d6c07267 fftools/ffmpeg_opt: move opening output files into a new file
ffmpeg_opt.c currently contains code for
- parsing the options provided on the command line
- opening and initializing input files based on these options
- opening and initializing output files based on these options

The code dealing with each of these is for the most part disjoint, so it
makes sense to move them to separate files. Beyond reducing the quite
considerable size of ffmpeg_opt.c, this will also allow exposing muxer
internals (currently private to ffmpeg_mux.c) to the initialization
code, thus removing the awkward separation currently in place.
2022-10-18 13:57:42 +02:00
Marvin Scholz
fed841f6f9 fftools/ffmpeg_opt: Use av_err2str
This simplifies the code as there is no other place the error buffer
is needed, so the av_err2str helper macro can be used.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2022-10-14 12:19:13 +02:00
Marvin Scholz
3ce1616106 ffmpeg: Make find_stream_info behave like a normal per-file option
Currently it would essentially change the find_stream_info setting for
the file it was specified for and all following files, which is unusual
and somewhat unexpected behaviour for a per-file option and not even
documented to behave like this.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2022-10-13 10:19:13 +02:00
Anton Khirnov
3d86a13b47 fftools/ffmpeg: drop the -async option
It has been deprecated in favor of the aresample filter for almost 10
years.

Another thing this option can do is drop audio timestamps and have them
generated by the encoding code or the muxer, but
- for encoding, this can already be done with the setpts filter
- for muxing this should almost never be done as timestamp generation by
  the muxer is deprecated, but people who really want to do this can use
  the setts bitstream filter
2022-10-04 11:55:03 +02:00
Andreas Rheinhardt
90aa2a88f9 fftools/ffmpeg_opt: Check creation of new program
Fixes Coverity issue #1512413.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-01 14:26:01 +02:00
Andreas Rheinhardt
601faaed92 fftools: Use report_error_then_exit_program() for allocation failures
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-09-01 14:26:00 +02:00
Anton Khirnov
0dd7347963 fftools/ffmpeg: drop OutputStream.fps_mode
It is only used within new_video_stream(), so make it a local variable
there.
2022-08-29 15:42:11 +02:00
Anton Khirnov
d0f767f81f fftools/ffmpeg: drop OutputStream.enc
It is either equal to OutputStream.enc_ctx->codec, or NULL when enc_ctx
is NULL. Replace the use of enc with enc_ctx->codec, or the equivalent
enc_ctx->codec_* fields where more convenient.
2022-08-29 15:42:11 +02:00
James Almer
f5a663f2a9 fftools/ffmpeg_opt: try to propagate the requested output channel layout
Don't silently replace it with the default layout for the amount of channels
from the requested layout.

Should fix ticket #9869

Signed-off-by: James Almer <jamrial@gmail.com>
2022-08-23 13:03:56 -03:00
Anton Khirnov
f23e3ce858 fftools/ffmpeg: call av_guess_frame_rate() when opening the file
It is currently called when configuring the filter, which races with the
demuxer thread.
2022-08-22 11:36:43 +02:00
Anton Khirnov
ab31473830 fftools/ffmpeg: store a separate copy of input codec parameters
Use it instead of AVStream.codecpar in the main thread. While
AVStream.codecpar is documented to only be updated when the stream is
added or avformat_find_stream_info(), it is actually updated during
demuxing. Accessing it from a different thread then constitutes a race.

Ideally, some mechanism should eventually be provided for signalling
parameter updates to the user. Then the demuxing thread could pick up
the changes and propagate them to the decoder.
2022-08-16 11:09:09 +02:00
Anton Khirnov
61d9f34c70 fftools/ffmpeg_demux: do not store demux packet in the context
Its use is local to input_thread().
2022-08-08 16:20:58 +02:00
Anton Khirnov
cc2b7f4625 fftools/ffmpeg: store the input file index in InputFile
Use it to simplify some code and fix two off-by-one errors.

Similar to what was previously done for OutputFile.
2022-08-08 16:20:58 +02:00