42

How is ffmpeg used with a video filter circa 2017 to adjust gamma/contrast, brightness and saturation?

Stack Exchange resources that are a few years old point to the filter mp=eq2=, but it seems to be deprecated1 and replaced with just eq=. The link does not reveal a good understanding of the setting ranges, however.

How is eq= (or equivalent filters) used? E.g., what is the format and appropriate settings/ranges?

For my personal usage, I'd like to keep gamma where it is, while increasing brightness and saturation a fair bit, for a dark video.


1Throws error message: No such filter: 'mp'

2
  • 3
    Checks the docs, and look into the curves or pp filter as well.
    – Gyan
    Mar 19, 2017 at 10:32
  • 4
    The syntax is the same as for all filters. i.e. filtername=option1=value1:option2=value2:option3=value3... These can be in any order.
    – Gyan
    Mar 19, 2017 at 10:51

3 Answers 3

46

These settings helped me to lighten up a dark video using the filter eq, with some added saturation.

Syntax:

filtername=option1=value1:option2=value2:option3=value3... These can be in any order.

Filter ranges and all options:

https://ffmpeg.org/ffmpeg-filters.html#eq

Preview:

ffplay -vf eq=brightness=0.06:saturation=2 INPUT.MOV

Render:

ffmpeg -i INPUT.MOV -vf eq=brightness=0.06:saturation=2 -c:a copy OUTPUT.MOV


Alternative filters: curves and pp.

2
  • 8
    the preview ffplay is an awesome added value
    – Amjo
    Apr 29, 2019 at 7:20
  • works like a charm. Thanks! Jul 3, 2022 at 4:51
15

Gamma correction is likely to be a better choice than brightness, to stretch the histogram to the right rather than push it over:

# tinker with numbers
ffplay -vf eq=gamma=1.5:saturation=1.3 original.vid 

# render
ffmpeg -i original.vid -vf eq=gamma=1.5:saturation=1.3 \
    -c:a copy  outfile.vid
2
  • Is there a reason the saturation needs to be changed with the gamma? Jan 20 at 17:42
  • 1
    Been a few years but my recollection is that when you brighten a dark video it looks a bit muted color-wise. Jan 22 at 4:51
9

I'd also try curves:

ffmpeg -i input.vid -vf "curves=all='0/0 0.5/1 1/1'" -codec:a copy -codec:v libx264 -y output.vid

The 0.5/1 maps mid-range brightness (0.5) to full bright (1)

Not the answer you're looking for? Browse other questions tagged or ask your own question.