Commit graph

1763 commits

Author SHA1 Message Date
Olivier Laflamme
711b69c615
fftools/ffprobe: Initialize data_dump_format_id
This was used uninitialized previously

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 10d36e5d3d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-15 00:49:55 +01:00
Lynne
c9a5f7c6ca
hwcontext_vulkan: deprecate AVVulkanDeviceContext.lock/unlock_queue
Without replacement, as VK_KHR_internally_synchronized_queues will be required.

(cherry picked from commit c102e89448)
2026-03-14 18:54:46 +01:00
nyanmisaka
b6db764c86
fftools/ffmpeg: fix read_key() always return 255 when there was no input
fixup 08d327e

When an uchar is set to -1, it will become 255 when read as an int.
Duplicate variables for two terminal types can also avoid unused variable warnings.

(cherry picked from commit 3f10a054dc)

Signed-off-by: nyanmisaka <nst799610810@gmail.com>
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-03-09 17:17:17 +01:00
James Almer
c6057f4d96 fftools/ffmpeg_mux_init: don't autoselect video codecs known to lack decoders
They should not be given priority even in a stream copy scenario.

Signed-off-by: James Almer <jamrial@gmail.com>
2026-03-07 19:21:44 -03:00
Michael Niedermayer
1e7d7c4f52
fftools/ffmpeg_demux: Check metadata provided filename
Fixes: path traversal with  -dump_attachment:t
Fixes: malicious.mkv

Based on code from libavformat/concatdec.c
This will be factored out possibly into libavutil once there is agreement on the API

Found-by: Shangzhi Xu <mxu490469@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-03-07 11:51:39 +01:00
Nicolas Gaullier
fe86fd07d3 fftools/ffprobe: do not show refs when not processing frames
refs does not belong to AVCodecParameters, so require a decoder:
it should only be showed when frames are actually processed by ffprobe.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
2026-03-05 13:49:59 +00:00
zhanghongyuan
e686f53424 fftools/ffplay: improve keyboard shortcut documentation
Clarify the behavior of seek keyboard shortcuts in both the
documentation and command-line help text. Specifically:
- left/right: mention custom interval option support
- page down/up: improve wording for chapter seeking fallback
2026-03-04 21:30:40 +00:00
Kacper Michajłow
4e32fb4c2a
fftools/cmdutils: constify string
Fixes:
warning: initializing 'char *' with an expression of type 'const char *'
discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2026-02-28 13:42:01 +01:00
Michael Niedermayer
0833dd3665 fftools/ffmpeg_opt: limit recursion of presets
Fixes: stack overflow

This should have limited security impact as it requires access to arbitrary
options.

Found-by: Zhenpeng (Leo) Lin from depthfirst
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2026-02-17 13:41:37 +00:00
Andreas Rheinhardt
bf44a683eb fftools/ffmpeg_mux_init: Improve type-safety
This makes fftools -fshort-enums compatible.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-02-10 16:36:58 +01:00
Niklas Haas
be88553fc8 fftools/ffmpeg_demux: mirror DemuxStream name to AVFormatContext
Results in basically the same name, except less ambiguous because
it includes the input index.
2026-02-09 14:01:14 +00:00
Marton Balint
75f5d79f6a fftools/ffprobe: add base64 data dump format
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-02-04 21:46:30 +01:00
Marton Balint
ca6f3f3c17 fftools/ffprobe: use an AVTextFormatOptions struct in AVTextFormatContext
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-02-04 21:46:30 +01:00
Marton Balint
b1f14cbd0e fftools/ffprobe: fatorize dumping hexdump as data dump
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-02-04 21:46:30 +01:00
Marton Balint
30be62b711 fftools/ffprobe: print AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL id and data
Data is only printed if -show_data is used.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-02-04 21:46:30 +01:00
zhanghongyuan
52f9e8c205 fftools/opt_common: Make -sources/-sinks options work without arguments
The -sources and -sinks options were defined with OPT_FUNC_ARG flag,
which requires an argument. This caused "Missing argument for option
'sources'" error when running ffprobe -sources without arguments.
Removing OPT_FUNC_ARG flag allows these options to work without
arguments, listing all available devices, while still supporting
optional device name argument for filtering specific devices.
2026-02-03 23:22:03 +00:00
Niklas Haas
8dc025c706 fftools/ffmpeg_sched: drop unneeded atomic
No longer needed now that this code is always locked.
2026-02-03 12:00:31 +01:00
Niklas Haas
41bd67b9fd fftools/ffmpeg_sched: fix race on SchFilterIn.send_finished
This logic was previously added to the scheduler. That commit added locking
(and rescheduling) when updating the corresponding `receive_finished` flag,
but missed doing the same for `send_finished`.

Fixes: fd1fd5850d
2026-02-03 12:00:31 +01:00
Andreas Rheinhardt
39661f9295 fftools/ffmpeg_{filter,mux_init}: Improve type-safety
Reviewed-by: Niklas Haas <ffmpeg@haasn.dev>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-30 15:20:08 +01:00
Gyan Doshi
fe0813d6e2 ffmpeg_demux: fix readrate to respect initial burst
Fixes #21510
2026-01-26 15:37:22 +05:30
Marton Balint
0ba9e272fa fftools/ffplay: add support for rendering without alpha
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-21 22:02:50 +00:00
Marton Balint
e76c73afaf fftools/ffplay: add video_bg and aspect ratio support to vulkan renderer
Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-21 22:02:50 +00:00
Marton Balint
50671a018d fftools/ffplay: add a new -video_bg option for transparent video
It allows controlling the background of a transparent video. Default is a
checker board pattern.

Signed-off-by: Marton Balint <cus@passwd.hu>
2026-01-21 22:02:50 +00:00
Werner Robitza
d25d133df3 avcodec/libx265: add pass and x265-stats option
Add support for standard -pass and -passlogfile options, matching the behavior
of libx264.
Add the -x265-stats option to specify the stats filename.
Update documentation.

Signed-off-by: Werner Robitza <werner.robitza@gmail.com>
2026-01-20 10:10:26 +00:00
Desmond Liu
48c9c38684 fftools/ffmpeg_demux: Fix readrate sleep calculation
Calculation of max_pts and limit_pts may overflow because adding
(int64_t + int64_t + float) results in a float that easily
overflows. This can trigger a very long av_usleep().
2026-01-09 01:28:45 +00:00
Andreas Rheinhardt
d595a18287 fftools/graph/graphprint: Replace always-false check by assert
This check makes no sense, as the pointer arithmetic involved
in &fg->graph_print_buf would be UB if fg were NULL.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-07 16:36:07 +01:00
Andreas Rheinhardt
9f77cb3a98 fftools/graph/graphprint: Remove always-false checks
init_graphprint() already returns an error upon allocation
failure.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-07 16:36:07 +01:00
Andreas Rheinhardt
9baf1b2f82 fftools/textformat/avtextformat: Move avtext_print_integers to ffprobe.c
This is its only user and because this function is so specialised
it is very likely to stay that way. So move it back to ffprobe.c
(where it already was before d7a3f68fea).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-07 16:36:07 +01:00
Andreas Rheinhardt
60684932fb fftools/textformat/avtextformat: Separate mutable and immutable data
Only two fields of AVTextFormatSection are ever modified:
entries_to_show and show_all_entries (they are only used
by ffprobe; the graph printing code always prints everything).
These fields do not belong into AVTextFormatSection, they are
more ffprobe-internal (and if the graph printing code ever
made use of them, these fields could very well be
per GraphPrintContext).

This commit therefore moves them out of AVTextFormatSection
and adds a callback to AVTextFormatContext to decide which
elements to discard. This also allows to make the AVTextFormatSections
const.

This also fixes a race when initializing the sections
for graphprint.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2026-01-07 16:36:07 +01:00
Zhao Zhili
ee2eb6ced8 fftools/ffmpeg_filter: fix access private API of libavcodec
Firstly, mathops.h is a private header of libavcodec and should not be used
in fftools. It may reference libavcodec internal symbols, causing link
error with dynamic library, e.g.,

fftools/ffmpeg_filter.c:2687: undefined reference to `ff_rv_zbb_supported'

Secondly, mid_pred operates on int types, while current use case is
int64_t.
2025-12-30 07:40:15 +00:00
James Almer
9c5a37388b fftools/ffprobe: print demixing_matrix in Projection mode ambisonic IAMF Audio Element groups
Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-29 12:02:40 -03:00
James Almer
64be23153e fftools/ffmpeg_sched: use av_unreachable instead of av_assert0(0) at the end of a non-void function
Fixes compilation with gcc-tsan and --disable-optimizations

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-24 12:21:39 -03:00
James Almer
2678482c10 fftools/ffmpeg_enc: use av_unreachable instead of av_assert0(0) at the end of a non-void function
Fixes compilation with gcc-tsan and --disable-optimizations

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-24 12:21:39 -03:00
Martin Storsjö
86f1ee1842 ffprobe: Include the RFC 4281 "mime codec string" in show_stream output 2025-12-12 18:40:01 +02:00
Cameron Gutman
45bf925d54 fftools/ffplay_renderer: use new Vulkan extension API
Signed-off-by: Cameron Gutman <aicommander@gmail.com>
2025-12-08 23:22:31 +00:00
James Almer
00caeba050 avcodec: rename avcodec_receive_frame2 to avcodec_receive_frame_flags
It's a name that communicates its functionality in a better way.
Since the function was introduced very recently, we can safely rename it.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-12-07 12:47:46 -03:00
Niklas Haas
929a2ced9b fftools/ffmpeg_dec: decode the first frame synchronously
In an ideal world, a filtergraph like `-i A -i B ... -filter_complex concat`
would only keep resources in memory related to the file currently being output
by the concat filter. So ideally, we'd open and fully decode A, then open and
fully decode B, and so on.

Practically, however, fftools wants to get one frame from each input file in
order to initialize the filter graph (buffersrc parameters). So what happens
currently is that fftools will request a single frame from each input A, B, etc
that is plugged into the filtergraph.

When using frame threading, the design of the decoder (ff_thread_receive_frame)
is that it will not output any frames until we have received enough packets to
saturate all threads. This, however, forces the decoder to buffer at least as
many frames for each input file as we have threads, before outputting anything.

By decoding the first frame synchronously, we avoid this issue and allow
configuring the filter graph more quickly and without wasting excess resources
on frames that will not (yet) be used.
2025-12-05 19:42:45 +01:00
Kacper Michajłow
3cc10b5ff6 fftools/cmdutils: use strcpy directly, the length is computed already
There is no need to scan for NULL, if we inject it ourselves.

Fixes: warning: 'strncat' specified bound 10 equals source length [-Wstringop-overflow=]
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-12-03 23:45:44 +00:00
Zhao Zhili
540aacf759 fftools/ffmpeg: add force key frame by scdet metadata support
For example:

./ffmpeg -hwaccel videotoolbox \
	-i input.mp4 -c:a copy \
	-vf scdet=threshold=10 \
	-c:v h264_videotoolbox \
	-force_key_frames scd_metadata \
	-g 1000 -t 30 output.mp4
2025-12-02 03:03:55 +00:00
Niklas Haas
38a5fcc02c fftools/ffmpeg_filter: close all no-longer needed inputs
Currently, the thread loop of ffmpeg_filter essentially works like this:

while (1) {
    frame, idx = get_from_decoder();
    err = send_to_filter_graph(frame);
    if (err) { // i.e. EOF
        close_input(idx);
        continue;
    }

    while (filtered_frame = get_filtered_frame())
        send_to_encoder(filtered_frame);
}

The exact details are not 100% correct since the actual control flow is a bit
more complicated as a result of the scheduler, but this is the general flow.

Notably, this leaves the possibility of leaving a no-longer-needed input
permanently open if the filter graph starts producing infinite frames (during
the second loop) *after* it finishes reading from an input, e.g. in a filter
graph like -af atrim,apad.

This patch avoids this issue by always querying the status of all filter graph
inputs and explicitly closing any that were closed downstream; after each round
of reading output frames. As a result, information about the filtergraph being
closed can now propagate back upstream, even if the filter is no longer
requesting any input frames (i.e. input_idx == fg->nb_inputs).

Fixes: https://trac.ffmpeg.org/ticket/11061
See-Also: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20457#issuecomment-6208
2025-11-26 13:15:16 +00:00
Ayose
efd6e85abb fftools/tf_mermaid: close subgraph header when there are no inputs.
Ensure that the fragment to close the header (`</div>\"]`) is written when the
function `mermaid_print_section_header` is called only once, which happens when
the filtergraph has no inputs.
2025-11-24 20:01:40 +00:00
Ayose
5717c5c1e1 fftools/tf_mermaid: logic to complete subgraphs in a reusable function.
`subgraph` blocks can be closed in different places. The logic to complete the
header is moved to a function, so it can be reused later.
2025-11-24 20:01:40 +00:00
Dmitrii Okunev
eccbbd528e fftools: Fix MediaCodec on Android15+
On Android15+ MediaCodec HAL backend was switched from HIDL to AIDL.
As a result, MediaCodec operations started to hang, see:

    https://trac.ffmpeg.org/ticket/11363
    https://github.com/termux/termux-packages/issues/21264
    https://issuetracker.google.com/issues/382831999

To fix that it is necessary to initialize binder thread pool.

Signed-off-by: Dmitrii Okunev <xaionaro@dx.center>
2025-11-23 12:53:43 +00:00
Romain Beauxis
c75ada5040 ffplay: print new metadata 2025-11-22 18:38:40 +00:00
Niklas Haas
133a0bcb13 fftools/ffmpeg_sched: prevent demuxers from getting stuck
When the furthest-behind stream is being fed by a demuxer that is also
feeding packets to a choked filter graph, we need to unchoke that filter
graph to prevent the demuxer from getting stuck trying to write packets to
the choked filter graph.

This situation can also apply recursively - if the demuxer is also writing
to a filtergraph that is also reading from a choked demuxer, there is a
similar deadlock.

Solve all such deadlocks by just brute-force recursively unchoking all
nodes that can somehow prevent this demuxer from writing packets. This
should normally not result in any change in behavior, unless audio/video
streams are badly desynchronized, in which case it may result in extra
memory usage from the too-far-ahead stream buffering packets inside the
muxer. (But this is, of course, preferable to a deadlock)

Fixes: https://code.ffmpeg.org/FFmpeg/FFmpeg/issues/20611
2025-11-10 09:55:40 +00:00
Kacper Michajłow
08d327e92c
fftools/ffmpeg: suppress unused variable warning, but using it
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
2025-11-05 19:04:00 +01:00
James Almer
492310ec6e fftools/ffmpeg_demux: fix memory leak when creating tile grid filtergraphs
If av_packet_side_data_to_frame() fails, graph_str will leak.

Fixes CID 1668266.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-01 12:41:23 -03:00
James Almer
acd2cfe2eb fftools/ffmpeg: make fg_create{_simple,} clear the input string pointer
The graph string is either freed or attached to the filtergraph, so it's best to
not leave a dangling pointer with the caller.

Signed-off-by: James Almer <jamrial@gmail.com>
2025-11-01 12:41:23 -03:00
James Almer
5ff8395e78 fftools/ffmpeg_demux: create a filtegraph to merge HEIF tiles automatically
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 11:02:01 -03:00
James Almer
433d18a1d9 fftools/ffmpeg_filter: handle metadata from stream group in relevant the filtergraphs
Signed-off-by: James Almer <jamrial@gmail.com>
2025-10-30 11:02:01 -03:00