46

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
    Commented 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
    Commented Mar 19, 2017 at 10:51

3 Answers 3

54

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
  • 10
    the preview ffplay is an awesome added value
    – Amjo
    Commented Apr 29, 2019 at 7:20
  • works like a charm. Thanks! Commented Jul 3, 2022 at 4:51
20

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? Commented Jan 20, 2023 at 17:42
  • 3
    Been a few years but my recollection is that when you brighten a dark video it looks a bit muted color-wise. Commented Jan 22, 2023 at 4:51
14

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)

1
  • One reason to use curves instead of eq: the latter seems to affect pixel format. If you convert from YUV to BGRP for conventional blending purposes, but blending for some unexplainable reason happens in YUV anyway, replacing eq with curves may help. Another filter that seems to mess up blending is normalize. Commented May 28, 2023 at 8:35

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