[FFmpeg-user] "vibrance" video filter, default luma coefficients swapped?

Jim DeLaHunt list+ffmpeg-user at jdlh.com
Thu Apr 15 08:33:06 EEST 2021


I recently wondered if FFmpeg had a "vibrance" filter, and I was 
delighted to find the "vibrance" video filter[1]. It looks like you 
added this back in 2018[1].  Thank you for that! I think it might come 
in handy for me.

I'm curious about the default values for coefficients "rlum", "glum", 
and "blum". It looks like they are supposed to match the luma 
computation as defined in BT.709-6[3] or something similar. Wikipedia 
gives this formula as:

> /R’G’B’/ coefficients 0.2126, 0.7152, and 0.0722 (together they add to 1)
So, luma = 0.2126 * r + 0.7152 * g + 0.0722 * b, a value in [0.0, 1.0] 
for r, g, b in [0.0, 1.0]

But the default values I see in the FFmpeg vibrance filter are[4]:

   rlum (default 0.072186), glum (default 0.715158), blum (default 0.212656)

Thus it looks like the default values for rlum and blum are swapped.

Luma would still yield a value in a value in [0.0, 1.0], but it wouldn't 
be the correct value per BT.709. Since the vibrance adjustments are 
relative to luma, they might be slightly off.

Am I reading that right? If so, would it be helpful for me to submit a 
patch to swap them back? Are there unit tests of vibrance to check?

[1] https://ffmpeg.org/ffmpeg-filters.html#vibrance
[2] commit b7b3e8c5c759350379eaf176f73334a65bfea2b4
[3] https://en.wikipedia.org/wiki/Rec._709

[4] % ffmpeg -h filter=vibrance
ffmpeg version 4.4 Copyright (c) 2000-2021 the FFmpeg developers
   built with Apple LLVM version 10.0.0 (clang-1000.10.44.4)
   configuration: --prefix=/opt/local --enable-swscale --enable-avfilter 
--enable-avresample --enable-libmp3lame --enable-libvorbis 
--enable-libopus --enable-librsvg --enable-libtheora 
--enable-libopenjpeg --enable-libmodplug --enable-libvpx 
--enable-libsoxr --enable-libspeex --enable-libass --enable-libbluray 
--enable-lzma --enable-gnutls --enable-fontconfig --enable-libfreetype 
--enable-libfribidi --disable-libjack --disable-libopencore-amrnb 
--disable-libopencore-amrwb --disable-indev=jack --enable-opencl 
--disable-outdev=xv --enable-audiotoolbox --enable-videotoolbox 
--enable-sdl2 --disable-securetransport --mandir=/opt/local/share/man 
--enable-shared --enable-pthreads --cc=/usr/bin/clang --enable-libdav1d 
--arch=x86_64 --enable-x86asm --enable-libx265 --enable-gpl 
--enable-postproc --enable-libx264 --enable-libxvid
   libavutil      56. 70.100 / 56. 70.100
   libavcodec     58.134.100 / 58.134.100
   libavformat    58. 76.100 / 58. 76.100
   libavdevice    58. 13.100 / 58. 13.100
   libavfilter     7.110.100 /  7.110.100
   libavresample   4.  0.  0 /  4.  0.  0
   libswscale      5.  9.100 /  5.  9.100
   libswresample   3.  9.100 /  3.  9.100
   libpostproc    55.  9.100 / 55.  9.100
Filter vibrance
   Boost or alter saturation.
     slice threading supported
        #0: default (video)
        #0: default (video)
vibrance AVOptions:
   intensity         <float>      ..FV.....T. set the intensity value 
(from -2 to 2) (default 0)
   rbal              <float>      ..FV.....T. set the red balance value 
(from -10 to 10) (default 1)
   gbal              <float>      ..FV.....T. set the green balance 
value (from -10 to 10) (default 1)
   bbal              <float>      ..FV.....T. set the blue balance value 
(from -10 to 10) (default 1)
   rlum              <float>      ..FV.....T. set the red luma 
coefficient (from 0 to 1) (default 0.072186)
   glum              <float>      ..FV.....T. set the green luma 
coefficient (from 0 to 1) (default 0.715158)
   blum              <float>      ..FV.....T. set the blue luma 
coefficient (from 0 to 1) (default 0.212656)
   alternate         <boolean>    ..FV.....T. use alternate colors 
(default false)

This filter has support for timeline through the 'enable' option.

Again, thanks for contributing this "vibrance" filter. It's a nice 
feature to have.

Best regards,
     —Jim DeLaHunt

More information about the ffmpeg-user mailing list