[FFmpeg-user] How to correct dark video with bright background

Gerardo Ballabio gerardo.ballabio at gmail.com
Sat Mar 9 20:14:10 EET 2019

Hello all,
I have a video that was filmed under bad lighting conditions, the
background is too bright and people in the foreground are dark. I'm
trying to use ffmpeg to correct it. Please kindly help me.

Here you can find a snippet:

video1.mts is the original file. video2.mp4 was created by a friend of
mine using proprietary software on Windows. I've been trying to
reproduce that. video3.mts is the best result I obtained (see below)
but the contrast is still too high and the colors aren't quite right.

I've tried several of ffmpeg's effects but maybe there are some better
ones that I missed?

- "eq=brightness=..." turns black into grey and gives the video a
"foggy" look, no good
- "colorlevels=..." I tried many parameter sets but couldn't do much
better, in the end I concluded that probably linear scaling isn't good
enough and I need nonlinear
- "curves=..." was indeed better but when I stretched the curve beyond
a certain point I obtained distorted colors
- I tried "geq=..." too but it doesn't seem to work, I always get an
error like this, if I'm getting the syntax wrong I couldn't figure out
what is the right one (I'm using Debian stable, ffmpeg version is

ffmpeg -i video1.mts -vf geq='r=r(X,Y):g=g(X,Y):b=b(X,Y)' video3.mts
[Parsed_geq_0 @ 0x55a01bb0aa60] [Eval @ 0x7ffd3d63afb0] Missing ')' or
too many args in 'r(X'
[AVFilterGraph @ 0x55a01bb09e80] Error initializing filter 'geq' with
args 'r=r(X'
Error opening filters!

These are the commands that I used to produce video3.mts:

ffmpeg -i video1.mts -vf colorlevels=romax=0.8:gomax=1.0:bomax=0.9 -b
12M temp.mts
ffmpeg -i temp.mts -vf curves=r='0/0.05 0.1/0.25 1/0.8':g='0/0.05
0.1/0.25 1/0.8':b='0/0.05 0.1/0.25 1/0.8' -b 12M video3.mts


More information about the ffmpeg-user mailing list