1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-11-23 21:54:53 +02:00
Commit Graph

2488 Commits

Author SHA1 Message Date
Gyan Doshi
00c23bafb0 doc/filters: add link to rendered doc of drawvg 2025-10-30 15:35:14 +05:30
Ayose
016d767c8e lavfi: add drawvg video filter.
The drawvg filter can draw vector graphics on top of a video, using libcairo. It
is enabled if FFmpeg is configured with `--enable-cairo`.

The language for drawvg scripts is documented in `doc/drawvg-reference.texi`.

There are two new tests:

- `fate-filter-drawvg-interpreter` launch a script with most commands, and
  verify which libcairo functions are executed.
- `fate-filter-drawvg-video` render a very simple image, just to verify that
  libcairo is working as expected.

Signed-off-by: Ayose <ayosec@gmail.com>
2025-10-25 13:21:50 +00:00
Michael Yang
e8213f766f libavfilter/vf_nlmeans_vulkan: amend doc 2025-10-16 21:32:43 +00:00
Niklas Haas
6f1ab828d3 libavfilter/vf_libplacebo: add temperature option 2025-10-09 20:45:09 +00:00
Niklas Haas
b80f28fcbc avfilter/vf_libplacebo: introduce fit_sense option
This allows choosing whether the `fit_mode` merely controls the placement
of the image within the output resolution, or whether the output resolution
is also adjusted according to the given `fit_mode`.
2025-09-30 15:39:39 +00:00
Niklas Haas
12d696cff4 avfilter/vf_libplacebo: introduce fit_mode option
The semantics of these keywords are well-defined by the CSS 'object-fit'
property. This is arguably more user-friendly and less obtuse than the
existing `normalize_sar` and `pad_crop_ratio` options. Additionally, this
comes with two new (useful) behaviors, `none` and `scale_down`, neither of
which map elegantly to the existing options.

One additional benefit of this option is that, unlike `normalize_sar`, it
does *not* also imply `reset_sar`; meaning that users can now choose to
have an anamorphic base layer and still have the overlay images scaled to fit
on top of it according to the chosen strategy.

See-Also: https://drafts.csswg.org/css-images/#the-object-fit
2025-09-30 15:39:39 +00:00
Drew Dunne
76471fb143 vf_colorspace: Add an option to clamp trc LUT output
Add a new flag to the vf_colorspace filter which provides the user an
option to clamp the linear and delinear transfer characteristics LUT
values to the [0, 1] represented range. This helps constrain the
potential value range when converting between colorspaces.

Certain colors when going through the conversion can result in out of
gamut colors after the rotation. The colorspace filter allows that with
the extended range. The added clamping just keeps the colors within the
[0, 1) range rather than using that extended range. I'm not enough of a
color scientist to say which is correct, but there are certain
situations where we would prefer to keep the colors in gamut.

The example I have is:

A solid color image of 8-bit YUV: Y=157, U=164, V=98.

Specify the input as:

Input range: MPEG
In color matrix: BT470BG
In color primaries: BT470M
In color transfer characteristics: Gamma 28

Output as:
Out color range: JPEG
Out color matrix: BT.709
Out color primaries: BT.709
Out color transfer characteristics: BT.709

During the calculation you get:

Input YUV:                             y=157,      u=164,      v-98
Post-yuv2rgb BT.470BG:                 r=0.456055, g=0.684152, b=0.928606
Post-apply gamma28 linear LUT:         r=0.110979, g=0.345494, b=0.812709
Post-color rotation BT.470M to BT.709: r=-0.04161, g=0.384626, b=0.852400
Post-apply Rec.709 delinear LUT:       r=-0.16382, g=0.615932, b=0.923793
Post-rgb2yuv Rec.709 matrix:           y=120,      u=190,      v=25

Where with this change, the delinear LUT output would be clamped to 0,
so the result would be:
r=0.000000, g=0.612390, b=0.918807 and a final output of
y=129, u=185, v=46

As for the long and av_clip64, this was just because lrint returned a
long, so I left it as that and then used av_clip64 to the [0,1) range to
avoid overflow. But re-reading, it looks like av_clip_int16 would
downcast that long to int anyway so the possibility of overflow already
existed there. I've put it back to int just to match the existing
behavior.
2025-09-15 14:39:09 +00:00
Timo Rothenpieler
6e63b978d3 doc/filters: fix missed reference to outdated option name 2025-09-14 15:33:31 +02:00
Timo Rothenpieler
36e374efb0 avfilter: add gfxcapture, Windows.Graphics.Capture based window/monitor capture 2025-09-14 11:45:11 +00:00
Niklas Haas
dfc3256da1 avfilter/af_afade: support multiple inputs
Instead of just 2 files, generalize this filter to support crossfading
arbitrarily many files. This makes the filter essentially operate similar
to the `concat` filter, chaining multiple files one after another.

Aside from just adding more input pads, this requires rewriting the
activate function. Instead of a finite state machine, we keep track of the
currently active input index; and advance it only once the current input is
fully exhausted.

This results in arguably simpler logic overall.
2025-09-04 23:12:34 +00:00
Niklas Haas
6f3eddbedd avfilter/vf_overlay: configure alpha mode on the link
And use the link-tagged value instead of the hard-coded parameter.
2025-09-02 17:06:25 +02:00
Niklas Haas
1c8ca56a88 avfilter/vf_libplacebo: add an alpha_mode setting
Chooses the desired output alpha mode. Note that this depends on
an upstream version of libplacebo new enough to respect the corresponding
AVFrame field in pl_map_avframe_ex.
2025-09-02 17:06:25 +02:00
Niklas Haas
dc02514f6b avfilter/vf_setparams: add alpha_mode parameter 2025-09-02 17:06:25 +02:00
Niklas Haas
2b1ef029eb avfilter/vf_format: add alpha_modes parameter 2025-09-02 17:06:25 +02:00
Niklas Haas
de297ae2fc avfilter/buffersrc: add alpha_mode parameter 2025-09-02 17:06:25 +02:00
Niklas Haas
c39a67e64f avfilter/vf_premultiply: add dynamic variant of this filter
We need a filter that can premultiply and unpremultiply the alpha channel
dynamically, on demand, in response to the negotiated alpha mode, analogous
to how vf_scale operates. Introduce a new filter "vf_premultiply_dynamic"
that accomplishes this.
2025-09-02 17:06:09 +02:00
Niklas Haas
6825f6f1e2 avfilter/vf_libplacebo: add bwdif option
See-Also: https://code.videolan.org/videolan/libplacebo/-/merge_requests/737
2025-08-21 15:34:03 +00:00
Niklas Haas
8e0de5d811 avfilter/setpts: also preserve duration when not stripping fps
It makes sense to treat the presence of a frame duration and the presence
of frame rate metadata identically - because both convey effectively the same
amount of information.

In f121d95 and fa110c3 respectively, this information was stripped by default,
originally to work-around bugs when changing the PTS information of a stream
being fed to some encoders. (See https://trac.ffmpeg.org/ticket/10886)

Later, commit 959b799c restored the ability to preserve the frame rate
medatata via the `strip_fps` option, but this option did not extend to also
include the frame duration.

This commit resolves the scenario by making `frame_rate` and `duration`
handled in a consistent manner, so that the frame rate information is
generally preserved unless explicitly stripped by the user.

While it does regress the exact invocation presented in the trac ticket unless
using `strip_fps=yes`, I consider this an acceptable trade-off, especially in
light of the fact that the `fps` filter also exists and is arguably the better
tool for the task at hand.
2025-08-21 14:55:12 +02:00
Niklas Haas
67c15cf541 avutil/hwcontext_vulkan: add debug option to avoid host ptr imports
In some environments, these are prohibitively slow. Add a debug option
to prefer memcpy instead of importing host pointers.
2025-08-20 15:05:41 +00:00
Niklas Haas
9b8b78a815 avfilter/vf_colordetect: detect fully opaque alpha planes
It can be useful to know if the alpha plane consists of fully opaque
pixels or not, in which case it can e.g. safely be stripped.

This only requires a very minor modification to the AVX2 routines, adding
an extra AND on the read alpha value with the reference alpha value, and a
single extra cheap test per line.

detect_alpha_8_full_c:                                2849.1 ( 1.00x)
detect_alpha_8_full_avx2:                              260.3 (10.95x)
detect_alpha_8_full_avx512icl:                         130.2 (21.87x)
detect_alpha_8_limited_c:                             8349.2 ( 1.00x)
detect_alpha_8_limited_avx2:                           756.6 (11.04x)
detect_alpha_8_limited_avx512icl:                      364.2 (22.93x)
detect_alpha_16_full_c:                               1652.8 ( 1.00x)
detect_alpha_16_full_avx2:                             236.5 ( 6.99x)
detect_alpha_16_full_avx512icl:                        134.6 (12.28x)
detect_alpha_16_limited_c:                            5263.1 ( 1.00x)
detect_alpha_16_limited_avx2:                          797.4 ( 6.60x)
detect_alpha_16_limited_avx512icl:                     400.3 (13.15x)
2025-08-18 18:50:00 +00:00
Gyan Doshi
9895c4222c doc/filters: correct psnr option name (#20199)
Correct doc entry from stats_add_max to output_max
2025-08-10 11:02:22 +05:30
Vittorio Palmisano
13ce36fef9 libavfilter: Whisper audio filter
It adds a new audio filter for running audio transcriptions with the whisper model.
Documentation and examples are included into the patch.
2025-08-08 21:59:56 +02:00
Lynne
d3288013ab vf_libplacebo: add support for specifying a LUT for the input
This makes it possible to apply Adobe .cube files to inputs.
2025-08-05 23:51:13 +09:00
Timo Rothenpieler
262d41c804 all: fix typos found by codespell 2025-08-03 13:48:47 +02:00
Niklas Haas
545f721b44 avfilter/vf_colordetect: add new color range detection filter
This filter can detect various properties about the image, including
whether or not there are out-of-range values, or whether the input appears
to use straight or premultiplied alpha.

Of course, these can only be heuristics, with "undetermined" as the base
case. While we can definitely prove the existence of full range or
straight alpha colors, we can never infer the opposite.
2025-07-21 18:10:25 +02:00
Jorge Estrada
ad0a44028d avfilter: add pad_cuda filter
This patch adds the pad_cuda video filter. A filter similar to the existing pad filter but accelerated by CUDA.

The filter shares the same options as the software pad filter.

Example usage:
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i input.mp4 -vf "pad_cuda=w=iw+100:h=ih+100:x=-1:y=-1:color=red" out.mp4

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
2025-07-04 01:32:27 +02:00
Niklas Haas
7039a37e35 avfilter/vf_libplacebo: add reset_sar option
This was requested by users of `vf_libplacebo`, to mirror the existing
option on the other `vf_scale_*` family of filters. While we have
`vf_normalize`, it was not as useful in the event that the content
stretching was actually desired.

Bridges an important usability gap between `vf_scale` and `vf_libplacebo`
that made mixing and matching the filters needlessly difficult.
2025-06-20 15:13:25 +02:00
Clément Péron
90424a4475 various: fix typos
usefull -> useful
seperately -> separately
reciever -> receiver

Signed-off-by: Clément Péron <peron.clem@gmail.com>
2025-06-15 21:00:38 +05:30
Niklas Haas
0894cfb168 avfilter/blackdetect_vulkan: add hw accelerated blackdetect filter
Like vf_blackdetect but better, faster, stronger, harder.

Signed-off-by: Niklas Haas <git@haasn.dev>
Sponsored-by: nxtedition
2025-05-28 12:21:27 +02:00
Niklas Haas
7e783fac5b avfilter/vf_blackdetect: add alpha option
Check the alpha plane for (almost) transparent frames, instead of checking
the luma channel for almost black frames.

Signed-off-by: Niklas Haas <git@haasn.dev>
Sponsored-by: nxtedition
2025-05-28 12:21:27 +02:00
Niklas Haas
559317cc13 avfilter/vf_libplacebo: add shader_cache option
Useful to speed up shader compilation. May significantly lower startup
times, in particular with large or complex shaders.

Sponsored-by: nxtedition
2025-05-23 14:05:16 +02:00
Niklas Haas
4f623b4c59 avfilter/vf_libplacebo: implement rotation option
Flipping can already be accomplished by setting the crop_w/h expressions to
their negative values, so together these options can implement any of the
common frame orientations.
2025-05-23 14:02:45 +02:00
Michael Niedermayer
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
Niklas Haas
853e66a072 doc/filters: fix "ewa_lanczos" filter description 2025-04-20 14:32:18 +02:00
Zhao Zhili
6995372ea2 doc/filters: Fix video size of mptestsrc
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
2025-04-16 19:33:55 +08:00
Danil Iashchenko
1015ea2ba1 doc/filters: add thumbnail_cuda entry
Also update thumbnail_cuda filter description.
2025-03-31 18:48:01 +05:30
Danil Iashchenko
a1c6ca1683 doc/filters: Shift CUDA-based filters to own section. 2025-03-17 12:38:51 +05:30
Niklas Haas
5944c4b20a avfilter/vf_libplacebo: remove deprecated options
These were removed upstream and no longer have had any effect for
a while now.

Signed-off-by: Niklas Haas <git@haasn.dev>
2025-02-27 18:56:19 +01:00
Niklas Haas
27814dc3b6 avfilter/libplacebo: add option for outputting separate fields
cf. the other deinterlacing-aware filters.
2025-02-27 18:55:33 +01:00
Niklas Haas
794cba812e avfilter/libplacebo: add deinterlacing options
These were introduced in libplacebo API version 220. We actually already
map the field by default, but deinterlacing was never enabled unless the user
explicitly forced it using extra_ops.
2025-02-27 18:55:33 +01:00
Niklas Haas
cd81f08491 avfilter/libplacebo: use a transparent default fillcolor
This will leave the background transparent when the target format
contains an alpha channel, without affecting the behavior on formats
without one.
2025-02-19 18:33:21 +01:00
Niklas Haas
4dc2ae69e7 avfilter/interlace_vulkan: add interlace_vulkan filter
This is a Vulkan-accelerated version of the existing interlace filter.
2025-02-17 17:16:25 +01:00
Gyan Doshi
7ee4936e0a avfilter/vpp_amf: add option reset_sar
4b77a0a681 added a new consumer of ff_scale_adjust_dimensions
which was recently modified to allow for square pixel output.

This commit extends the new option to vpp_amf, and unbreaks the building
of vf_amf_common.c
2025-02-10 19:59:26 +05:30
Gyan Doshi
a28dc06869 avfilter/scale*: add option reset_sar
For anamorphic videos, enabling this option leads to adjustment of
output dimensions to obtain square pixels when the user requests
proportional scaling through either of the w/h expressions or
force_original_aspect_ratio.

Output SAR is always reset to 1.

Option added to scale, scale_cuda, scale_npp & scale_vaapi.

libplacebo already has a similar option with different semantics,
scale_vt and scale_vulkan don't implement force_oar, so for these
three filters, I've made minimal changes needed to not break building
or change output.
2025-02-10 16:25:23 +05:30
Evgeny Pavlov
1f94cc4588 doc/filters: Add documentation for AMF filters
Signed-off-by: Evgeny Pavlov <lucenticus@gmail.com>
2025-02-04 00:14:14 +01:00
Gyan Doshi
221816456a doc/filters: fix typo in format filter
The inline example for option color_ranges used 'color_spaces'

Fixes #11441
2025-01-31 23:15:40 +05:30
Gyan Doshi
959b799c8d avfilter/setpts: add option strip_fps to decide framerate handling
In f121d95, the outlink framerate was unconditionally unset.
This breaks/bloats outputs from CFR muxers unless the user explicitly
sets a sane framerate. And the most common invocation for setpts seen in
workflows, our docs and across the web is `PTS-STARTPTS` or others of the
general form `PTS+constant` which preserves the input framerate.

Default value is false, which restores old behaviour.

Fixes #11428
2025-01-27 15:40:09 +05:30
Niklas Haas
b7a2333357 avfilter/vf_scale: add colorspace and transfer property options
In the long run, it would be ideal if we could add these to the avfilter
negotiation as well, but for now, this is a good start.
2024-12-23 12:33:43 +01:00
Niklas Haas
45f0a7ad33 swscale: add ICC intent enum and option
This setting can be used to infuence the type of tone and gamut mapping used
internally when color space conversions are required. As discussed at VDD'24,
the default was set to relative colorimetric clipping, which is approximately
associative, surjective and idempotent. As such, it roundtrips well, although
it is strictly speaking not associative on out-of-gamut colors.
2024-12-23 12:33:43 +01:00
James Almer
d2c90abab7 doc/filters: add an entry for vf_lcevc
Signed-off-by: James Almer <jamrial@gmail.com>
2024-12-02 12:53:54 -03:00