1673 Commits

Author SHA1 Message Date
aa20294b31 fftools/ffmpeg_opt: Fix precedence issue in abs_start_seek calculation
This patch corrects a C operator precedence issue in fftools/ffmpeg_opt.c
where the abs_start_seek calculation did not yield the expected result
due to incorrect placement of parentheses.
2024-12-26 15:44:18 +05:30
8ad34e97b6 fftools/sync_queue: switch from AVFifo+ObjPool to AVContainerFifo
Remove now-unused objpool.
2024-12-15 14:05:34 +01:00
8e0cceffa0 fftools/thread_queue: switch from AVFifo+ObjPool to AVContainerFifo
The queue needs to track each frame/packet's stream index, this is
achieved by maintaining a parallel AVFifo instance for that purpose.
This is simpler than implementing custom AVContainerFifo callbacks.
2024-12-15 14:05:34 +01:00
90af8e07b0 fftools/ffprobe: add analyze_frames option for CC and grain detection
Currently, ffprobe has two stream-level fields that do not work,
closed_captions and film_grain).

Their value is always 0 because ffprobe cannot access the internal
codec properties when it is setting up its stream contexts.

In this commit, add the new option -analyze_frames to ffprobe,
allowing the user to read frames up to the interval they have defined
and fill these fields based on what is exposed in AVPacketSideData.

Additionally, in the same commit, don't write these fields to
the output unless analyze_frames is enabled. Finally, fix the
FATE test refs accordingly and update the docs.

Signed-off-by: Marth64 <marth64@proxyid.net>
2024-12-13 22:41:31 -06:00
433cf391f5 fftools/ffmpeg_sched: signal the main thread when a task fails
Avoids a useless -stats_period wait before exiting.

Reported-by: names_are_hard
2024-11-25 05:26:49 +01:00
785ffe67c8 fftools/ffmpeg_sched: rename mux_done_{lock,cond} into finish_*
Their semantics will be changed in the following commit to not be
limited to muxing.
2024-11-25 05:26:49 +01:00
a8375346eb fftools/ffplay_renderer: Fix a typo
The typo has no real effect except confusing.

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Reported-by: Chen Haibo
Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
2024-11-20 19:17:37 +08:00
fd0cacc472 fftools/ffplay: fix crash when vk renderer is null
When vulkan rendering is requested by the user and fails, ffplay should
exit graciously instead of crash due to a null pointer deref.

Signed-off-by: Leandro Santiago <leandrosansilva@gmail.com>
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-11-06 16:34:02 +08:00
0552238570 fftools/ffplay: use swapchain_colorspace_hint to get better HDR support
For example, the default surface configuration on macOS is:
VK_FORMAT_A2B10G10R10_UNORM_PACK32 + VK_COLOR_SPACE_PASS_THROUGH_EXT

With HDR10 content and swapchain_colorspace_hint, the surface
configuration updated to:
VK_FORMAT_A2B10G10R10_UNORM_PACK32 + VK_COLOR_SPACE_HDR10_ST2084_EXT

Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
2024-10-27 11:34:01 +08:00
242ee7b0a2 fftools/ffmpeg_sched: be smarter about flushing the pre-muxing queues
These per-stream FIFOs hold the packets before every stream is
initialized and the header can be written. Once that happens, current
code will flush each stream's queue one after the other. However, in
case we buffered a lot of data for multiple streams, this may cause the
muxer to overflow max_interleave_delta, resulting in worse interleaving
than necessary.

Change the code to interleave packets from all the queues by DTS.
2024-10-17 10:57:18 +02:00
6d6bd86f2b fftools/opt_common: stop accessing a private field
Stops printing the 'C' flag in -filters output, but it carries no
actionable information anyway.
2024-10-17 10:56:33 +02:00
e79ac9312f fftools/ffmpeg_filter: use proper logging contexts 2024-10-17 10:56:30 +02:00
ad50254ee1 fftools/ffmpeg_demux: use proper logging contexts everywhere 2024-10-17 10:52:02 +02:00
9e2a231236 fftools/ffmpeg_filter: treat apad filter as a source
Ideally lavfi should have a dedicated API for detecting this.

Fixes #11168 and #11061
2024-10-15 10:38:48 +02:00
0f5592cfc7 fftools/ffmpeg: supply hw device context to probe-filtergraphs
I.e. those that are only used to figure out input/output counts, since
some filters might expect a valid hw device in init and refuse to
initalize otherwise.

This requires complex filtergraphs to be created in a separate step
after parsing global options, after all hw devices are guaranteed to
exist.
2024-10-10 09:09:29 +02:00
84c2ca6fa0 fftools/ffmpeg_filter: do not leak graph_desc on fg_create() failure
fg_create() is passed a malloced string and assumed to always take
ownership of it.
2024-10-10 09:09:29 +02:00
181c204145 fftools/ffmpeg_opt: add a struct to be passed as opaque to global-option handlers
Will be useful in following commits.
2024-10-10 09:09:29 +02:00
840b95bcc2 fftools/cmdutils: do not treat single '-' as an option in locate_option()
Fixes early parsing of trailing -v/-loglevel while using '-' to output
to stdout.
2024-10-10 09:09:29 +02:00
e56d676050 fftools/cmdutils: group related calls together
For readability only, should have no functional effect.
2024-10-10 09:09:29 +02:00
496b8d7a13 fftools/ffmpeg_filter: stop setting a no-op option 2024-10-07 10:53:13 +02:00
f25c9cc213 fftools: log unconnected filter output label 2024-10-04 14:27:20 +02:00
5beeb3a1f9 fftools: do not access out of bounds filtergraph
The log message was logged for `filtergraphs[j]` which would cause a
heap buffer overflow in certain circumstances.

Correctly it should be logged for the current filtergraph, so just
use `fg` here.
2024-10-04 14:27:20 +02:00
faa366003b fftools/ffmpeg_mux_init: consolidate connecting source to mux stream 2024-09-30 09:29:18 +02:00
ba06c7b08f fftools/ffmpeg_mux_init: move the ost_get_filters() call to ost_bind_filter()
That is a more appropriate place for it.
2024-09-30 09:29:18 +02:00
71916aa107 fftools/ffmpeg_mux_init: move the check for filtering+streamcopy
To streamcopy_init().

This will allow to simplify the control flow in ost_add() by moving the
ost_get_filters() call (which previously had to handle both encoding and
streamcopy streams) to ost_bind_filter() (which is only called for
audio/video encoding).

Also, return EINVAL rather than ENOSYS, as trying to combine filtering
with streamcopy is a parameter error.
2024-09-30 09:29:18 +02:00
e83b5b2cc8 fftools/ffmpeg_mux_init: do not export forced_keyframes_const_names[]
It is only used in this file.
2024-09-30 09:29:18 +02:00
c27b1e6c59 fftools/ffmpeg: drop unused OSTFinished 2024-09-30 09:29:18 +02:00
64f3feb849 fftools/ffmpeg_mux: move OutputStream.enc_ctx to Encoder
The encoding AVCodecContext is a part of the encoder, and so should live
there.
2024-09-30 09:29:18 +02:00
434377a764 fftools/ffmpeg_enc: split Encoder into a private and public part
Similar to what was previously done for other components, e.g. decoders
(see 3b84140a1bb5a5b3044915888a40a7b619921633).

Start by moving {samples,frames}_encoded into the public struct.
2024-09-30 09:29:18 +02:00
f295b4d8a0 fftools/ffmpeg_demux: drop ist_output_add()
It is now a trivial wrapper over ist_use(), so export that directly.
2024-09-30 09:29:18 +02:00
8e805b9c3c fftools/ffmpeg_demux: drop InputStream.[nb_]outputs
It is write-only after d119ae2fd82a494d9430ff4d4fc262961a68c598.
2024-09-30 09:29:18 +02:00
b97ccc537d fftools/ffplay: switch to new buffersink options 2024-09-30 09:14:04 +02:00
577708a70a fftools/ffplay: stop using avfilter_graph_create_filter() incorrectly
This function creates AND initializes a filter, so setting any filter
options after it is wrong. It happens to work when the filter's init
function does not touch the options in question, but is forbidden by the
API and is not guaranteed to remain functional.

Instead, use avfilter_graph_alloc_filter(), followed by setting the
options, and avfilter_init_dict().
2024-09-28 17:04:33 +02:00
53c71777e1 fftools/ffmpeg_filter: stop using avfilter_graph_create_filter() incorrectly
This function creates AND initializes a filter, so setting any filter
options after it is wrong. It happens to work when the filter's init
function does not touch the options in question, but is forbidden by the
API and is not guaranteed to remain functional.

Instead, use avfilter_graph_alloc_filter(), followed by setting the
options, and avfilter_init_dict().
2024-09-28 17:04:33 +02:00
d103b61cd8 fftools/ffmpeg_filter: remove remaining OutputStream usage in init_simple_filtergraph()
With this, nothing in ffmpeg_filter acesses OutputStream anymore, thus
there are no more direct ties between filtering and muxing.

Rename init_simple_filtergraph() to fg_create_simple() for consistency.
2024-09-26 18:29:40 +02:00
72cd0c20da fftools/ffmpeg_filter: drop the OutputStream parameter to ofilter_bind_ost()
It is no longer used for anything besides a sanity-checking assert.
Rename the function to ofilter_bind_enc(), as it no longer has any
assumptions about the target being an output stream.
2024-09-26 18:29:40 +02:00
addc29f67a fftools/ffmpeg_filter: stop accessing OutputStream.[max_]frame_rate
Pass them to ofilter_bind_ost() via OutputFilterOptions, as is done for
most other data it needs. OutputStream.[max_]frame_rate/force_fps are no
longer used outside of ffmpeg_mux*, and so can be made private.

This is a step toward decoupling encoders from muxers.
2024-09-26 18:29:40 +02:00
ac578ccb8e fftools/ffmpeg_filter: drop a redundant check
OutputFilterOptions.frame_rates are always NULL if the conditional is
true.
2024-09-26 18:29:40 +02:00
cefc7d1ff4 fftools/ffmpeg_filter: clarify error message 2024-09-26 18:29:38 +02:00
e3e66b14af fftools/ffmpeg_enc: don't write frame rate/SAR to AVStream directly
Have the muxer code read them out of the encoder context in
of_stream_init() instead.

This is a step towards decoupling encoders from muxers.
2024-09-26 18:25:21 +02:00
7f7fe2a10b fftools/ffmpeg_enc: move set_encoder_id() to ffmpeg_mux_init
This code uses no encoder properties or state besides its name, and is
mostly muxer logic, and thus belongs more properly into the muxer.

The results of several test change due to different metadata tag order
(the "encoder" tag is now set first).
2024-09-26 18:25:21 +02:00
6525fe4e77 fftools/ffmpeg_enc: remove unnecessary pointer references from enc_open() 2024-09-26 18:25:21 +02:00
78038d51c5 fftools/ffmpeg_enc: do not set output stream codec parameters directly
Have the muxer code read them out of the encoder context in
of_stream_init() instead.

OutputStream.par_in no longer needs to be public, so can be moved to
MuxStream.

This is a step towards decoupling encoders from muxers.
2024-09-26 18:25:21 +02:00
238f439992 fftools/ffmpeg_enc: do not set AVStream timebase directly
Instead, pass the encoder context to of_stream_init() and have the muxer
take the timebase from there. Note that the muxer can currently access
the codec context directly, but that will change in future commits.

This is a step towards decoupling encoders from muxers.
2024-09-26 18:25:21 +02:00
1ebd521a4e fftools/ffmpeg_enc: stop using OutputStream in hw_device_setup_for_encode()
The only variable accessed from it is AVCodecContext, which we can
pass directly.

Also, this function currently logs into the AVCodecContext, which is
wrong. Log to Encoder instead.
2024-09-26 18:25:21 +02:00
70f7bbeade fftools/ffmpeg_enc: add an AVClass to Encoder
Log decoder messages to the encoder rather than OutputStream.

This is a step towards decoupling encoders from muxers, similarly to
what was previously done to decoders and demuxers.
2024-09-26 18:25:21 +02:00
da420ac6e1 fftools/ffmpeg: add support for multiview video
This extends the syntax for specifying input streams in -map and complex
filtergraph labels, to allow selecting a view by view ID, index, or
position. The corresponding decoder is then set up to decode the
appropriate view and send frames for that view to the correct
filtergraph input(s).
2024-09-23 17:15:02 +02:00
68c198fae2 fftools/ffmpeg_sched: allow decoders to have multiple outputs
Will be useful for multilayer video.
2024-09-23 17:15:02 +02:00
6940a6de2f lavu/frame: add side data storing view ID for multi-view video 2024-09-23 17:11:38 +02:00
a48eba0021 fftools/ffmpeg_filter: ensure that the inserted filters exist
If not, report it as a bug. avfilter_graph_create_filter() will return ENOMEM if the
passed filter argument is NULL, which is misleading.

Signed-off-by: James Almer <jamrial@gmail.com>
2024-09-23 09:02:23 -03:00