To fix poor black depth and faded areas in FFmpeg, you must correct the color range metadata by using the -color_range flag instead of the non-existent -range. Additionally, apply the eq=contrast=1.2:brightness=-0.05 video filter to deepen shadows and restore contrast during transcoding.
Understanding Color Range Metadata Issues
The most common cause of washed-out or faded blacks is a mismatch between the source video's color range and the output container's expectations. Video files typically use either "limited" (studio) range, where black is defined as 16/240, or "full" (PC) range, where black is 0/255. When FFmpeg processes a file without explicit instructions, it may incorrectly assume the input is full range when it is actually limited, causing dark pixels to shift upward and resulting in grayish blacks.
Many users mistakenly attempt to control this behavior using a generic -range flag. This flag does not exist in standard FFmpeg builds for video streams. The correct parameter is -color_range. You can explicitly tell FFmpeg how to interpret the input data and what format to write for the output. If your source is standard definition television material or compressed web content, it likely uses limited range. For high-end PC graphics or uncompressed captures, it may be full range.
To diagnose the issue, check the stream information of your input file. Run the following command in your terminal:
ffprobe -v error -select_streams v:0 -show_entries stream=color_range -of default=noprint_wrappers=1:nokey=1 input.mp4
If the output is limited, you should force the output to maintain that range or convert it correctly. Use the -color_range flag in your encoding command. For example, to ensure the output preserves the limited range:
ffmpeg -i input.mp4 -color_range limited -c:v libx264 output.mp4
Conversely, if you are converting from a full-range source to a limited-range target, you might need to specify -color_range pc for input and -color_range tv for output, depending on your specific pipeline needs. Always verify the metadata after encoding with ffprobe to ensure consistency.
Enhancing Contrast and Depth with Filters
While fixing metadata resolves technical mismatches, it does not always address artistic or perceptual issues where the blacks simply look too light due to compression artifacts or poor original grading. In these cases, applying a video filter to adjust contrast and brightness directly is necessary. The eq (equivalence) filter is the standard tool for this task.
The eq filter allows you to modify the image's contrast, brightness, saturation, and gamma. To deepen faded blacks, you generally want to increase the contrast slightly and lower the brightness minimally. A starting point for many videos is eq=contrast=1.2:brightness=-0.05. This increases the difference between light and dark areas while subtly darkening the overall image.
Apply this filter using the -vf (video filter) argument:
ffmpeg -i input.mp4 -vf "eq=contrast=1.2:brightness=-0.05" -c:v libx264 output.mp4
Adjust these values based on visual inspection. If the blacks are still too gray, try increasing the contrast to 1.3 or lowering the brightness further to -0.1. Be cautious not to over-adjust, as excessive contrast can introduce banding artifacts, especially in 8-bit video. If you notice banding, consider adding a dithering filter or ensuring your output bit depth is sufficient.
Combining Metadata Correction and Filtering
For the best results, combine both approaches. First, ensure the color range is handled correctly, then apply the contrast enhancement. This ensures that the filter operates on the correct pixel values rather than misinterpreted ones.
ffmpeg -i input.mp4 -color_range tv -vf "eq=contrast=1.2:brightness=-0.05" -c:v libx264 -crf 23 output.mp4
In this example, we assume the input is TV range (tv). We apply the eq filter to boost contrast and reduce brightness. The -crf 23 sets a reasonable quality level for H.264 encoding. Adjust the CRF value as needed for your storage or bandwidth constraints.
Verifying the Output
After encoding, always verify the result. Play the video back on a calibrated monitor if possible. Check the histogram or waveform monitor in professional editing software to see if the black levels now sit at the expected baseline. If you are working on Linux or Windows, the commands remain identical, though path separators may differ if you are referencing external filter scripts.
If you are concatenating multiple clips with different color ranges, ensure they are normalized before joining. See How to Concatenate Videos with FFmpeg for details on handling frame rates and timestamps during assembly. Mismatched color ranges across segments can cause visible jumps in brightness at cut points.
Similarly, if you are overlaying images or text, ensure their alpha channels and color spaces do not interfere with the background blacks. Refer to Using FFmpeg to Overlay Images on Video Frames for best practices in compositing.
Frequently Asked Questions
Why does my video look washed out even after setting -color_range?
Setting the color range only fixes metadata interpretation; it does not alter the actual pixel values. If the original footage was poorly graded or compressed heavily, the dynamic range may be inherently low. You must use the eq filter to actively adjust contrast and brightness to visually improve the image.
What is the difference between -color_range tv and pc?
tv refers to limited range (16-235 for luma), typical for broadcast video and DVD. pc refers to full range (0-255), typical for computer-generated graphics and high-end capture cards. Using the wrong assumption causes dark pixels to shift, making blacks appear gray.
Can I use the eq filter without re-encoding?
No, the eq filter modifies pixel data, which requires re-encoding the video stream. You cannot apply it in copy mode (-c copy). Re-encoding will change the file size and potentially introduce generation loss, so use the highest quality settings possible.
How do I fix banding after increasing contrast?
Banding occurs when there are not enough bits to represent smooth gradients. You can mitigate this by using a higher bit-depth encoder (like libsvtav1 or x265 with 10-bit support) or by adding a slight noise/dither filter. Increasing CRF quality also helps preserve more gradient information.
Does this solution work for WebM or MKV containers?
Yes, the -color_range flag and eq filter are codec-agnostic and work with any container FFmpeg supports, including WebM, MKV, MP4, and AVI. Ensure the underlying video codec (VP9, H.265, etc.) supports the color space you are targeting.