FFmpeg scale setrange: How to Change Video Color Range

This article explains how to use the setrange option within FFmpeg’s scale video filter to change and correct video color ranges. You will learn the difference between limited and full color ranges, the syntax for the setrange option, and practical command-line examples to convert your video files.

Understanding Color Ranges: Limited vs. Full

Video files typically use one of two color ranges to define how brightness and color values are stored:

If a video is flagged or processed with the incorrect color range, it will look washed out (grayish blacks) or have crushed blacks and clipped whites.

Using the setrange Option

The setrange option in FFmpeg’s scale filter forces the output video to a specific color range. It does not change the actual pixel resolution unless you specify width and height parameters alongside it.

The syntax for the option is: scale=setrange=value

The available values for setrange are: * auto (or 0): Choose the range automatically. * limited or mpeg (or 1): Force limited range (16-235). * full or jpeg (or 2): Force full range (0-255).

Force Output to Full Color Range

To convert a limited-range video to a full-range video, use the following command:

ffmpeg -i input.mp4 -vf "scale=setrange=full" -c:v libx264 -pix_fmt yuv420p output.mp4

Force Output to Limited Color Range

To convert a full-range video (such as a screen recording or PC gameplay) to limited range for standard media players, use this command:

ffmpeg -i input.mp4 -vf "scale=setrange=limited" -c:v libx264 -pix_fmt yuv420p output.mp4

Combining Resolution Scaling and Range Changing

If you need to resize the video while changing the color range, separate the parameters with a colon (:):

ffmpeg -i input.mp4 -vf "scale=1920:1080:setrange=full" -c:v libx264 output.mp4

Verifying Color Range Changes

To verify if the color range was successfully applied, inspect the output file using ffprobe:

ffprobe -v error -show_entries stream=color_range -of default=noprint_wrappers=1 input.mp4

This command will output either color_range=tv (for limited/MPEG range) or color_range=pc (for full/JPEG range).