[FFmpeg-trac] #9750(avfilter:new): overlay filter alpha premultiplied performs brighter on transparent images
FFmpeg
trac at avcodec.org
Tue Apr 26 06:54:43 EEST 2022
#9750: overlay filter alpha premultiplied performs brighter on transparent images
------------------------------------+------------------------------------
Reporter: windowsair | Owner: (none)
Type: defect | Status: new
Priority: important | Component: avfilter
Version: git-master | Resolution:
Keywords: | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
------------------------------------+------------------------------------
Changes (by windowsair):
* priority: normal => important
Old description:
> == Summary of the bug:
>
> I'm using ffmpeg's overlay filter with alpha premultiplied parameter. I
> noticed that when a completely transparent image was overlay to the
> background video, the output video was much brighter.
>
> In the following demo, I will use RGBA8888 format images for overlay. Its
> use of RGBA (255,255,255,0) indicates full transparency (aka completely
> transparent white), and the result demonstrates a very noticeable
> brightening (the expected result should be unchanged, since the image is
> completely transparent).
>
> ps: Using RGBA (0,0,0,0) (aka completely transparent black) also results
> in a brightened image.
>
> == How to reproduce:
> {{{
> % ffmpeg.exe -loglevel debug -i a1.mp4 -i a1.png -filter_complex
> "[0:v][1:v]overlay=x=0:y=0:alpha=premultiplied[v]" -map "[v]" -c:v:0
> libx264 -f mp4 output.mp4
> }}}
>
> == ffmpeg output
> {{{
> ffmpeg version n5.0.1-3-gb655beb025-20220425 Copyright (c) 2000-2022 the
> FFmpeg developers
> built with gcc 11.2.0 (crosstool-NG 1.24.0.533_681aaef)
> configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static
> --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64
> --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug
> --enable-shared --disable-static --disable-w32threads --enable-pthreads
> --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype
> --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig
> --enable-libvorbis --enable-opencl --disable-libpulse --enable-libvmaf
> --disable-libxcb --disable-xlib --enable-amf --enable-libaom --enable-
> avisynth --enable-libdav1d --enable-libdavs2 --disable-libfdk-aac
> --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libgme
> --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus
> --enable-librist --enable-libtheora --enable-libvpx --enable-libwebp
> --enable-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-
> libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-
> libopenmpt --enable-librav1e --enable-librubberband --enable-schannel
> --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1
> --enable-libtwolame --enable-libuavs3d --disable-libdrm --disable-vaapi
> --enable-libvidstab --enable-vulkan --enable-libshaderc --enable-
> libplacebo --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-
> libxvid --enable-libzimg --enable-libzvbi --extra-
> cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread
> --extra-ldexeflags= --extra-libs=-lgomp --extra-version=20220425
> libavutil 57. 17.100 / 57. 17.100
> libavcodec 59. 18.100 / 59. 18.100
> libavformat 59. 16.100 / 59. 16.100
> libavdevice 59. 4.100 / 59. 4.100
> libavfilter 8. 24.100 / 8. 24.100
> libswscale 6. 4.100 / 6. 4.100
> libswresample 4. 3.100 / 4. 3.100
> libpostproc 56. 3.100 / 56. 3.100
> }}}
>
> The complete output is given in the file ffmpeg.log
New description:
== Summary of the bug:
I'm using ffmpeg's overlay filter with alpha premultiplied parameter. I
noticed that when a completely transparent image was overlay to the
background video, the output video was much brighter.
In the following demo, I will use RGBA8888 format images for overlay. Its
use of RGBA (255,255,255,0) indicates full transparency (aka completely
transparent white), and the result demonstrates a very noticeable
brightening (the expected result should be unchanged, since the image is
completely transparent).
ps: Using RGBA (0,0,0,0) (aka completely transparent black) also results
in a brightened image.
== How to reproduce:
{{{
% ffmpeg.exe -loglevel debug -i a1.mp4 -i a1.png -filter_complex
"[0:v][1:v]overlay=x=0:y=0:alpha=premultiplied[v]" -map "[v]" -c:v:0
libx264 -f mp4 output.mp4
}}}
== ffmpeg output
{{{
ffmpeg version n5.0.1-3-gb655beb025-20220425 Copyright (c) 2000-2022 the
FFmpeg developers
built with gcc 11.2.0 (crosstool-NG 1.24.0.533_681aaef)
configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static
--pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64
--target-os=mingw32 --enable-gpl --enable-version3 --disable-debug
--enable-shared --disable-static --disable-w32threads --enable-pthreads
--enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype
--enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig
--enable-libvorbis --enable-opencl --disable-libpulse --enable-libvmaf
--disable-libxcb --disable-xlib --enable-amf --enable-libaom --enable-
avisynth --enable-libdav1d --enable-libdavs2 --disable-libfdk-aac
--enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libgme
--enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus
--enable-librist --enable-libtheora --enable-libvpx --enable-libwebp
--enable-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-
libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-
libopenmpt --enable-librav1e --enable-librubberband --enable-schannel
--enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1
--enable-libtwolame --enable-libuavs3d --disable-libdrm --disable-vaapi
--enable-libvidstab --enable-vulkan --enable-libshaderc --enable-
libplacebo --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-
libxvid --enable-libzimg --enable-libzvbi --extra-
cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread
--extra-ldexeflags= --extra-libs=-lgomp --extra-version=20220425
libavutil 57. 17.100 / 57. 17.100
libavcodec 59. 18.100 / 59. 18.100
libavformat 59. 16.100 / 59. 16.100
libavdevice 59. 4.100 / 59. 4.100
libavfilter 8. 24.100 / 8. 24.100
libswscale 6. 4.100 / 6. 4.100
libswresample 4. 3.100 / 4. 3.100
libpostproc 56. 3.100 / 56. 3.100
}}}
The complete output is given in the file ffmpeg.log
== How to reproduce (Using transparent black)
This command uses lavfi to simulate the transparent black output of RGBA.
For demonstration purposes only, you may need ctrl+c to prevent infinite
output.
{{{
% ffmpeg.exe -y -i a1.mp4 -f lavfi -i
"color=color=black at 0.0:size=1920x540,format=rgba" -filter_complex
"[0:v][1:v]overlay=x=0:y=0:alpha=premultiplied[v]" -map "[v]" -c:v:0
libx264 -f mp4 output.mp4
}}}
The results show that the upper part is more whitish (brighter).
--
--
Ticket URL: <https://trac.ffmpeg.org/ticket/9750#comment:2>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list