Convert Full Range to Limited Range Video with FFmpeg
This article provides a straightforward guide on how to convert a video’s color range from full (0-255) to limited (16-235) using FFmpeg. You will learn the exact command-line arguments and video filters required to scale the pixel values and write the correct metadata, ensuring your video displays properly on standard broadcast and TV screens.
The Conversion Command
To convert both the actual video stream data (pixel values) and the container metadata from full range to limited range, use the following FFmpeg command:
ffmpeg -i input.mp4 -vf "scale=out_range=limited,format=yuv420p" -color_range tv -c:v libx264 -crf 18 -c:a copy output.mp4Parameter Breakdown
-i input.mp4: Specifies the source video file.-vf "scale=out_range=limited,format=yuv420p":scale=out_range=limited: This is the core filter that compresses the color values from the 0-255 spectrum down to the 16-235 spectrum.format=yuv420p: Ensures the output pixel format is YUV 4:2:0, which is the standard format for limited-range web and broadcast video.
-color_range tv: Sets the metadata flag in the output file container to “tv” (limited range). This tells media players to interpret the video as 16-235 instead of stretching it to 0-255.-c:v libx264: Re-encodes the video using the H.264 codec (necessary because the pixel values are being modified).-crf 18: Sets the Constant Rate Factor for high-quality video encoding (lower values mean higher quality; 18-23 is standard).-c:a copy: Copies the audio stream without re-encoding it, saving time and preserving audio quality.
Changing Metadata Only (No Re-encoding)
If your video pixels are already limited to 16-235, but the file is incorrectly flagged as full range (0-255), you can fix the metadata flag instantly without re-encoding the video:
ffmpeg -i input.mp4 -c copy -color_range tv output.mp4Using -c copy bypasses the rendering process, meaning
this command completes almost instantly and results in zero quality
loss.