Commit Graph

1165 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
Anton Khirnov 43a0004b5c fftools/ffmpeg_enc: apply -top to individual encoded frames
Fixes #9339.
2023-09-18 17:15:53 +02:00
Anton Khirnov 74b643a51e fftools/ffmpeg_enc: refactor setting encoding field_order
Merge three blocks with slightly inconsistent checks into one, treating
encoder input as interlaced when either:
* at least one of ilme/ildct flags is set
* the first frame in the stream is marked as interlaced
* the user specified the -top option

Stop modifying the frame passed to enc_open().
2023-09-18 17:15:53 +02:00
Anton Khirnov ced62a0c01 fftools/ffmpeg: do not fail on AVERROR(EAGAIN) from choose_output()
This is not an error condition, but would be treated like one if the
program terminates on the next transcode loop iteration because of a
signal or keyboard input.

Fixes #10504
Tested-by: https://github.com/0Ky
2023-09-14 10:44:05 +02:00
Andreas Rheinhardt 8238bc0b5e avcodec/defs: Add AV_PROFILE_* defines, deprecate FF_PROFILE_* defines
These defines are also used in other contexts than just AVCodecContext
ones, e.g. in libavformat. Furthermore, given that these defines are
public, the AV-prefix is the right one, so deprecate (and not just move)
the FF-macros.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-07 00:39:02 +02:00
Lynne 4acd08be6c
ffplay: port to lavu/tx 2023-09-01 23:59:11 +02:00
Leo Izen 60be62d293
fftools/ffmpeg_mux: replace monotonous with monotonic
The word "monotonous" means "spoken in a monotone" which is not what we
mean here. We mean "monotonic" i.e. nondecreasing.

Signed-off-by: Leo Izen <leo.izen@gmail.com>
2023-09-01 03:36:24 -04:00
Anton Khirnov 3c397a1d46 fftools/ffmpeg: move sending filtergraph commands to a separate function
Stop accessing filtergraph internals from keyboard reading code.
2023-08-30 11:53:50 +02:00
Anton Khirnov bff48e8d69 fftools/ffmpeg_mux: rename of_close() to of_free()
This function is primarily a destructor for OutputFile, the underlying
AVIOContext is normally closed earlier (right after writing the
trailer).
2023-08-30 11:53:50 +02:00
Anton Khirnov d55262704e fftools/ffmpeg_filter: shorten a variable name 2023-08-30 11:53:50 +02:00
Anton Khirnov fbcecdec8a fftools/ffmpeg_filter: reindent after previous commit 2023-08-30 11:53:50 +02:00
Anton Khirnov d9c862b57f fftools/ffmpeg_filter: factor processing a single frame out of reap_filters()
This is easier to read.
2023-08-30 11:53:50 +02:00
Anton Khirnov 82dd4dbe3f fftools/ffmpeg_filter: sanitize framerate retrieved from the filtergraph
Lavfi uses 1/0 to signal unknown/VFR, which should not be passed to
encoders.
2023-08-30 11:53:50 +02:00
Anton Khirnov d65d0f4df1 fftools/ffmpeg_enc: reindent after previous commit 2023-08-30 11:53:50 +02:00
Anton Khirnov 411ada649f fftools/ffmpeg_enc: only use fallback framerate when encoding CFR
When no output video framerate is specified by the user with -r or can
be inferred from the filtergraph, encoder setup will arbitrarily decide
that the framerate is 25fps. However, making up any framerate value for
VFR encoding is at best unnecessary.

Changes the results of the sub2video tests, where the input timebase is
now used instead of 1/25.
2023-08-30 11:53:50 +02:00
Anton Khirnov 8b6b2518fa fftools/ffmpeg_enc: reindent after previous commit 2023-08-30 11:53:50 +02:00
Anton Khirnov d1a2cd1e13 fftools/ffmpeg_enc: factor out setting encoder timebase
Mainly this fixes handling special values of -enc_time_base ('demux' or
'filter') for audio. It also prints a warning if -enc_time_base is
specified for subtitles, instead of ignoring it silently (current
subtitle encoding API only works with AV_TIME_BASE_Q).
2023-08-30 11:53:50 +02:00
Anton Khirnov 8ecbb1f9af fftools/ffmpeg_mux: stop rescaling timestamps in of_streamcopy()
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.
2023-08-30 11:53:46 +02:00
Anton Khirnov ed5caaaf22 fftools/ffmpeg_mux: use correct timebases for bitstream filtering
Bitstream filtering input timebase is not always necessarily equal to
OutputStream.mux_timebase. Also, set AVPacket.time_base correctly for
packets output by bitstream filters

Do not rescale at all in of_output_packet() when not doing bitstream
filtering, as it's unnecessary - write_packet() will rescale to the
actual muxer timebase.
2023-08-30 11:51:42 +02:00
Anton Khirnov b39b6b7456 fftools/ffmpeg: simplify handling input -t for streamcopy
Output stream will be closed implicitly after a NULL packet is sent to
it, there is no need to explicitly call close_output_stream().
2023-08-30 11:51:42 +02:00
Anton Khirnov 8f2e7e9dcf fftools/ffmpeg: stop explicitly closing output streams on input EOF
Sending an empty packet already does that implicitly.
2023-08-30 11:51:42 +02:00
Andreas Rheinhardt 9583a2c8eb fftools/ffprobe: Use proper enum type
This is a bit cleaner as int need not be the underlying type
of an enum if a smaller type can hold all its values.
Also declare the children_ids array as const as it never changes.

Reviewed-by: Stefano Sabatini <stefasab@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-08-08 20:20:36 +02:00
Andreas Rheinhardt 739f24d833 fftools/opt_common: Don't add unnecessary " "
Before:
D.AIL. smackaudio           Smacker audio (decoders: smackaud )
After:
D.AIL. smackaudio           Smacker audio (decoders: smackaud)

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-08-02 18:15:34 +02:00
Andreas Rheinhardt 41409405d4 fftools/opt_common: Use %c instead of %s to write single char
Also combine multiple printfs.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-08-02 18:15:34 +02:00
Andreas Rheinhardt 0e9956a06e fftools/ffprobe: Fix memleak
Fixes Coverity issue #1524491.
Regression since e6126abc69.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-08-01 16:31:13 +02:00
Anton Khirnov e8777221f2 fftools/ffprobe: fix handling parse_options() return value
Reviewed-by: James Almer <jamrial@gmail.com>
Reviewed-by: Marton Balint <cus@passwd.hu>
Signed-off-by: James Almer <jamrial@gmail.com>
2023-07-28 09:11:26 -03: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 0368ded1a9 fftools/opt_common: Fix leak on error
Fixes Coverity issue #743443.

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
Andreas Rheinhardt 2a44c4bc9e fftools/ffmpeg_mux_init: Fix leak on error
Fixes Coverity issue #1539098.

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 ccc6849932 fftools/ffmpeg: stop calling exit_program()
Remove exit_program() and register_exit(), as they are no longer used.
2023-07-20 20:47:46 +02:00
Anton Khirnov a81d9231b9 fftools/ffprobe: stop calling exit_program()
Inline the relevant part of ffprobe_cleanup() into main() and drop the
rest.
2023-07-20 20:47:46 +02:00
Anton Khirnov be49c48282 fftools/ffprobe: inline opt_output_file() into its only caller
There is no reason to keep them separate.

Also, replace exit_program() with returning an error code.
2023-07-20 20:47:46 +02:00
Anton Khirnov 411e183360 fftools/opt_common: replace report_and_exit() with returning an error code
Remove report_and_exit(), as it has no more users.
2023-07-20 20:47:46 +02:00
Anton Khirnov 78699923ac fftools/ffplay: replace report_and_exit() with returning an error code 2023-07-20 20:47:46 +02:00
Anton Khirnov 140cb5a742 fftools/ffprobe: replace report_and_exit() with returning error codes 2023-07-20 20:47:46 +02:00
Anton Khirnov 83ace80bfd fftools/ffmpeg: return an error from MATCH_PER_STREAM_OPT() instead of aborting 2023-07-20 20:47:46 +02:00
Anton Khirnov 2f155b18a1 fftools/ffmpeg: return an error from assert_avoptions() instead of aborting
Rename it to check_avoptions().
2023-07-20 20:47:46 +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 8173623e39 fftools/ffmpeg: consolidate exiting from main() on error 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 87f0333af1 fftools/cmdutils: add error handling to filter_codec_opts() 2023-07-20 20:47:46 +02:00
Anton Khirnov 6b8cf2505a fftools/cmdutils: constify the first parameter of filter_codec_opts() 2023-07-20 20:47:46 +02:00
Anton Khirnov 39d5104332 fftools: handle errors in 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 4adbe2d219 fftools/opt_common: replace exit_program() with returning error codes 2023-07-20 20:40:26 +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