1636 Commits

Author SHA1 Message Date
0d6ef6f545 fftools/textformat: correctly propagate uninit error codes
This allows catching IO errors occuring at file close.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-05-16 20:43:58 +02:00
a124c9a580 Revert "fftools/textformat/avtextformat: Make close functions return void"
This reverts commit 7684243fbe6e84fecb4a039195d5fda8a006a2a4 and
a888975a3c25760027cd59932f5c1ad04368db8b.
2025-05-16 20:43:58 +02:00
79e2a845cd Revert "fftools/graphprint: Now, make it a Killer-Feature!"
This reverts commit 1f2b8d7238eff4ab8a4d8d6177e250b8180d51f4.
2025-05-16 10:37:29 +02:00
1f2b8d7238 fftools/graphprint: Now, make it a Killer-Feature!
remember this: -sg   <= means Show Graph

Signed-off-by: softworkz <softworkz@hotmail.com>
2025-05-15 23:11:08 +02:00
45926bc09a fftools/graphprint: Add execution graph printing
The key benefits are:

- Different to other graph printing methods, this is outputting:
  - all graphs with runtime state
    (including auto-inserted filters)
  - each graph with its inputs and outputs
  - all filters with their in- and output pads
  - all connections between all input- and output pads
  - for each connection:
    - the runtime-negotiated format and media type
    - the hw context
    - if video hw context, both: hw pixfmt + sw pixfmt
- Output can either be printed to stdout or written to specified file
- Output is machine-readable
- Use the same output implementation as ffprobe, supporting multiple
  formats

Signed-off-by: softworkz <softworkz@hotmail.com>
2025-05-15 23:09:17 +02:00
50fcc0ce5f fftools/ffmpeg_mux: Make ms_from_ost() inline
Signed-off-by: softworkz <softworkz@hotmail.com>
2025-05-15 23:08:05 +02:00
517a805565 fftools/resources: Add resource manager files with build-time compression
Compression requires zlib to be available, otherwise resources will
be included uncompressed - in either case via BIN2C.

It can also be disabled via

./configure --disable-resource-compression

Size figures:

graph.css         7752
graph.css.min     6655 (css is always minified)
graph.html        2153

No Compression

graph.css.c      40026
graph.css.o       9344 (6688)
graph.html.c     13016
graph.html.o      4848 (2186)

With Compression

graph.css.c      10206
graph.css.o       4368 (1718)
graph.html.c      5725
graph.html.o      3632 (971)

Numbers in brackets: .rodata size from 'size -Ax -d *.o'

Signed-off-by: softworkz <softworkz@hotmail.com>
2025-05-15 23:08:05 +02:00
34bb7f5d87 fftools/ffmpeg_filter: Move some declaration to new header file
to allow filtergraph printing to access the information.

Signed-off-by: softworkz <softworkz@hotmail.com>
2025-05-15 23:04:44 +02:00
b71b444a3a fftools/textformat: Add flags param to function avtext_print_integer()
Make this function work analog to avtext_print_string() which already
has a flags parameter.

Signed-off-by: softworkz <softworkz@hotmail.com>
2025-05-15 23:04:44 +02:00
bb3a14489e fftools/tf_internal: Use av_default_item_name
Reviewed-by: Stefano Sabatini <stefasab@gmail.com>
Signed-off-by: softworkz <softworkz@hotmail.com>
2025-05-15 23:04:44 +02:00
cee7b8a051 fftools/textformat: Introduce common header and deduplicate code
Also change writer_printf signature in AVTextWriter to use va_list,
so that it can be called by the new function writer_printf()
in tf_internal.h.

Reviewed-by: Stefano Sabatini <stefasab@gmail.com>
Signed-off-by: softworkz <softworkz@hotmail.com>
2025-05-15 23:04:44 +02:00
e4830b8c5e fftools/textformat: Introduce AVTextFormatOptions for avtext_context_open()
This allows future addition of options without
changes to the signature of avtext_context_open().

Reviewed-by: Stefano Sabatini <stefasab@gmail.com>
Signed-off-by: softworkz <softworkz@hotmail.com>
2025-05-15 23:04:44 +02:00
4ff90f05c7 fftools/avtextformat: Re-use BPrint in loop
Instead of initializing a new BPrint in case of UTF decode error,
re-use the same BPrint struct and just clear it
for each iteration.

Reviewed-by: Stefano Sabatini <stefasab@gmail.com>
Signed-off-by: softworkz <softworkz@hotmail.com>
2025-05-15 23:04:44 +02:00
d225928703 fftools/textformat: Rename name param to key for API consistency
Reviewed-by: Stefano Sabatini <stefasab@gmail.com>
Signed-off-by: softworkz <softworkz@hotmail.com>
2025-05-15 23:04:44 +02:00
4baeb9ffe9 fftools/textformat: Remove unused print_rational() pointer from AVTextFormatter
Reviewed-by: Stefano Sabatini <stefasab@gmail.com>
Signed-off-by: softworkz <softworkz@hotmail.com>
2025-05-15 23:04:44 +02:00
5f90eea8a8 fftools/textformat: Apply quality improvements
Perform multiple improvements to increase code robustness.
In particular:
- favor unsigned counters for loops
- add missing checks
- avoid possible leaks
- move variable declarations to inner scopes when feasible
- provide explicit type-casting when needed

Signed-off-by: softworkz <softworkz@hotmail.com>
2025-05-15 23:04:44 +02:00
8f42d90413 fftools/textformat: Apply formatting and whitespace changes
Reviewed-by: Stefano Sabatini <stefasab@gmail.com>
Signed-off-by: softworkz <softworkz@hotmail.com>
2025-05-15 23:04:44 +02:00
b18aaf209f fftools/ffmpeg_dec: Always receive frames from decoder
Up until now if avcodec_send_packet() returned an error,
no attempt to receive a frame from the decoder would be made.
Instead the decoder was presumed to be drained, so that more
packets could be sent to it. Yet this need not be so:
It can happen that a packet would decode to multiple frames
and that decoding the first of these (the one that is decoded
during the avcodec_send_packet() call) returns an error,
in which case the decoder is not yet ready to receive more
input as the remaining parts of the packet have not been decoded
yet. In this case, an AERROR_BUG is triggered.

This happens in ticket #11553 with VP9 (which uses a BSF
to split VP9 superframes and is therefore affected by this).

Fix this by always calling avcodec_receive_frame() unless
xerror is set.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-05-15 01:23:41 +02:00
4014784b62 fftools/ffmpeg: move elapsed time counter to the end of the status line
Elapsed time is much less important than the actual progress, and I am guessing
several ffmpeg CLI frontends use the existing status line for showing progress,
so putting a new field in the beginning is less optimal anyway.

Related to ticket #11582.

Signed-off-by: Marton Balint <cus@passwd.hu>
2025-05-11 18:41:55 +02:00
8c920c4c39 Remove libpostproc
Libpostproc will be available as source plugin at
https://github.com/michaelni/FFmpeg/tree/sourceplugin-libpostproc
OR
https://github.com/michaelni/libpostproc

whatever turns out more convenient to maintain

For the upcoming 8.0 release, libpostproc will be included, so as not to
cause delays or inconveniences

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2025-05-07 15:35:47 +02:00
1dbc5675c1 fftools/ffprobe: Disable stderr buffering on Windows
An identical call exists in ffmpeg.c

With POSIX/glibc, stderr is already unbuffered (or line-buffered when
a terminal is connected), but not in case of MSVCRT.
Explicitly calling setvbuf() like in this commit, makes the Windows
runtime behave like POSIX, giving the same “print immediately” behavior.

Signed-off-by: softworkz <softworkz@hotmail.com>
2025-05-03 07:58:08 +02:00
b322640b4f fftools/ffmpeg: Log exit code on exit
When viewing logs, there are situations where it is not entirely
clear whether ffmpeg CLI has exited gracefully. The two primary cases
are

- A crash/segfault has occured
  Windows for example doesn't output any message to the calling shell
- The process has been terminated (e.g. killed externally)

Printing a message on exit provides a reliable indication that the
process has exited normally.
Printing the exit code is useful as it usually remains invisible
and unnoticed by users running FFmpeg from a shell.

Signed-off-by: softworkz <softworkz@hotmail.com>
2025-05-03 07:57:27 +02:00
1a083a4d90 fftools/ffmpeg: Include elapsed-time in print_report()
It's a highly useful metric, both at runtime and when viewing logs.

Signed-off-by: softworkz <softworkz@hotmail.com>
2025-05-03 07:57:01 +02:00
7684243fbe fftools/textformat/avtextformat: Remove unused variable
Forgotten in a888975a3c25760027cd59932f5c1ad04368db8b.

Reviewed-by: softworkz . <softworkz-at-hotmail.com@ffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-17 01:49:04 +02:00
a888975a3c fftools/textformat/avtextformat: Make close functions return void
Just like normal close functions.

Reviewed-by: softworkz . <softworkz-at-hotmail.com@ffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-16 06:13:13 +02:00
37635d31cb fftools/textformat/avtextformat: Add missing AVERROR()
Reviewed-by: softworkz . <softworkz-at-hotmail.com@ffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-16 06:13:03 +02:00
f873734f84 fftools/textformat/avtextformat: Initialize stuff earlier
avtext_context_close() calls av_opt_free() on an AVTextFormatContext
as well as av_bprint_finalize() on the containing section_pbuf
AvBPrints, yet it can happen that the AVBPrints have not been
initialized (only zeroed) and that av_opt_set_defaults() has
not been called. This works, but it is not really documented to do so.
So ensure that the options and the AVBPrints have been initialized
when avtext_context_close() is called.

Reviewed-by: softworkz . <softworkz-at-hotmail.com@ffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-16 06:12:54 +02:00
50ef4b2a6b fftools/textformat/avtextformat: Fix segfault upon allocation error
Would happen if an AVTextFormatContext's private context
could not be allocated.

Reviewed-by: softworkz . <softworkz-at-hotmail.com@ffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-16 06:12:48 +02:00
7ee7632cb8 fftools/textformat/avtextformat: Fix segfault upon allocation error
Reviewed-by: softworkz . <softworkz-at-hotmail.com@ffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-16 06:12:41 +02:00
b9450583bc textformat/tw_avio: Remove close_on_uninit param from create_file
avtextwriter_create_file() creates an AVIOContext whose pointer
resides in its private context. If it were not always closed on
uninit, the AVIOContext would leak, so it makes no sense
to have this parameter.

Reviewed-by: softworkz . <softworkz-at-hotmail.com@ffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-16 06:12:09 +02:00
f73badbf47 fftools/textformat/tw_avio: Use avio_closep()
Avoids leaving dangling pointers behind.

Reviewed-by: softworkz . <softworkz-at-hotmail.com@ffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-16 06:12:05 +02:00
79fa31d159 fftools/textformat/tw_avio: Don't flush unnecessarily
avio_close() automatically flushes the AVIOContext.

Reviewed-by: softworkz . <softworkz-at-hotmail.com@ffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-16 06:11:58 +02:00
395c91347f fftools/textformat/tw_avio: Remove unused private class
This AVTextWriter does not have any options.

Reviewed-by: softworkz . <softworkz-at-hotmail.com@ffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-16 06:11:52 +02:00
c9dc6ca02b fftools/textformat: Use "", not <> for lavu headers
Also remove unused headers.

Reviewed-by: softworkz . <softworkz-at-hotmail.com@ffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-16 06:11:45 +02:00
2ab1021264 fftools/textformat/avtextformat: Simplify avtext_print_rational()
Use snprintf() directly instead of initializing an AVBPrint
just for this.

Reviewed-by: softworkz . <softworkz-at-hotmail.com@ffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-16 06:05:58 +02:00
93ae305ce1 fftools/ffprobe: Rename AVTextFormatContext variables (w => tfc)
Signed-off-by: softworkz <softworkz@hotmail.com>
2025-04-11 03:06:48 +02:00
15e99b2398 fftools/ffprobe: Rename writer_print_section_* and WriterContext
separated for better clarity of the preceding commit

Signed-off-by: softworkz <softworkz@hotmail.com>
ren
2025-04-11 03:06:47 +02:00
d7a3f68fea fftools/ffprobe: Change to use textformat api
Signed-off-by: softworkz <softworkz@hotmail.com>
2025-04-11 03:06:47 +02:00
97d680d450 fftools/textformat: Extract and generalize textformat api from ffprobe.c
Signed-off-by: softworkz <softworkz@hotmail.com>
2025-04-11 03:06:47 +02:00
9d543273fe fftools/ffprobe: Fix hypothetical stack buffer overflow
It can't really happen, because no currently used pixel format
has a name exceeding the size of the buffer.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-04-03 06:04:51 +02:00
efa0c6252f fftools/cmdutils: fix error message for "ffmpeg -init_hw_device list"
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>
2025-04-03 06:29:12 +08:00
f47c8bca2c fftools/ffprobe: Make pix_fmt output bitexact
It is currently not due to endianness. This forced to add
workarounds with sed in fate/mxf.mak (which are removed
in this commit).
This is supposed to fix the enhanced-flv-hevc-hdr10 test
on big endian systems.

Reviewed-by: Zhao Zhili <quinkblack-at-foxmail.com@ffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-30 08:24:39 +02:00
8b2372cac7 ffmpeg-filter: check for initialized graph
Don't drop frame if graph hasn't been initialized yet!
2025-03-25 01:06:03 +05:30
fee5b0a383 fftools/ffmpeg_filter: ensure ifp is set before dereferencing it
Fixes segfaults since cbbc927a67f142a02bfc5d047c03587599ee5b55.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-24 10:10:19 -03:00
cbbc927a67 ffmpeg: add per-stream input option drop_changed
This is a replacement in ffmpeg for the deprecated avcodec flag AV_CODEC_FLAG_DROPCHANGED.

This option is meant to be used when the filtergraph should not be
reinited upon input parameter changes as that leads to loss of state
in the filtergraph potentially leading to broken or aborted output,
e.g. inserting of silence with first_pts specified in aresample.

Generally useful to avoid corrupted yet decodable packets in live
streaming inputs.

This option when enabled takes precedence over reinit_filters
2025-03-24 16:18:17 +05:30
323cb8c61e ffmpeg_demux: set default for readrate_catchup to be 5% faster
The existing default value is the same as the primary readrate.
This maintains the flow rate as best as possible but does not
reduce the lag. This new value allows catchup to gradually happen
without overwhelming the receiver.

Addresses a concern brought up in #11469
2025-03-24 16:17:47 +05:30
a6c58450da all: Fix doxy comments wrongly designated as trailing ///<
The ///< or /**< form of doxygen comments are only to be used
when the documentation follows the member and the comment
block starts on the same line as the member. This commit
fixes wrong uses of them; in particular, this fixes the comment
for mb_height in H.264 SPS's structure which was wrongly added
to mb_width.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-12 17:00:24 +01:00
fcd5df5904 fftools/ffmpeg_opt: Remove unused alt_bsf
Forgotten in 6325aede08d5c7086b3798cb7041299e1d07f93a.

Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2025-03-12 16:58:16 +01:00
01f63ef0b4 fftools/ffmpeg_filter: also remove display matrix side data from buffered frames
Some frames may be buffered before a complex filtergraph can be configured.
This change ensures the side data removal in the cases where autorotation is
enabled also applies to them.

Fixes ticket #11487

Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-03 18:10:10 -03:00
848576b4df fftools/ffmpeg_dec: remove side data copy block
It's no longer needed now that lavc handles this.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-03-03 18:10:10 -03:00