Change Video Brightness and Contrast with FFmpeg

This article provides a quick overview and step-by-step guide on how to adjust the brightness and contrast of a video using FFmpeg on Linux. By utilizing the powerful eq (equalizer) video filter, you can easily modify your video’s visual properties directly from the command line. Whether you need a subtle correction or a dramatic shift, FFmpeg offers precise controls to achieve the desired look without needing a heavy graphical video editor.

To change these settings, you will use FFmpeg’s video filter flag (-vf) paired with the eq filter. The basic syntax requires you to specify values for brightness and contrast as decimals or integers.

Here is the fundamental command structure:

ffmpeg -i input.mp4 -vf "eq=contrast=1.5:brightness=0.1" output.mp4

Understanding the Parameters

When adjusting the equalizer filter, it helps to understand how FFmpeg calculates these values:

Practical Examples

If you have a video that is slightly underexposed, you can boost both parameters to make the image pop. For instance, to slightly increase the brightness and add a bit of punchy contrast, use the following command:

ffmpeg -i twilight_clip.mp4 -vf "eq=contrast=1.2:brightness=0.05" enhanced_output.mp4

Conversely, if your video is washed out and overly bright, you can lower the brightness and increase the contrast to recover some depth:

ffmpeg -i overexposed_clip.mp4 -vf "eq=contrast=1.3:brightness=-0.08" corrected_output.mp4

Optimizing Encoding Speed and Quality

By default, FFmpeg will re-encode your video using standard settings. To ensure you maintain high visual quality while managing file size, you can specify a video codec and a Constant Rate Factor (CRF). Adding -c:a copy will also allow you to pass the audio through without re-encoding it, saving processing time:

ffmpeg -i input.mp4 -vf "eq=contrast=1.1:brightness=0.02" -c:v libx264 -crf 23 -c:a copy output.mp4

Using these command-line adjustments allows for rapid, scriptable video corrections directly within your Linux terminal.