You are here

FFMPEG Gamma Correction

Error message

Deprecated function: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in drupal_strip_dangerous_protocols() (line 1458 of /home2/crephoto/public_html/techblog/includes/common.inc).

While there's no substitution for good lighting and exposure, every so often I come across a video which is a bit on the light or dark side. While there's no perfect correction for exposure deficiencies, ffmpeg does have some tools to correct for the "middle gray" point, that is, to make an video brighter or darker without affecting the lightest highlights or darkest shadows. This is called a gamma adjustment. First, test a few settings and see how it looks, comparing the playback with the original:

$ ffplay -vf eq=gamma=1.3:saturation=1.1 <video_file>

A gamma setting of greater than one will "lighten". I use quotes, because it's really just moving the mid-level brightness, and compressing lighter values while expanding the darker values (and vice versa for values less than one). I've also added a bit of saturation, just because I felt the video needed it. Once you're happy with the settings, you can transcode and save them permanently in a new file:

$ ffmpeg -i <video_file> eq=gamma=1.3:saturation=1.1 -c:a copy <output_file>

Is there anything ffmpeg can't do? Well, it's no substitute for quality lighting and exposure (not to mention focus), but it's pretty amazing.