Modify MaxCLL and MaxFLL in HEVC streams by passing the --max-cll and --max-fall flags directly to the x265 encoder during the encoding process. These parameters define the metadata for high dynamic range (HDR) displays, ensuring correct brightness interpretation. You must specify these values before encoding begins, as they are written into the HEVC sequence parameter set.
Understanding MaxCLL and MaxFLL Metadata
MaxCLL stands for Maximum Content Light Level, while MaxFLL represents the Maximum Frame-Average Light Level. These two metrics are critical components of the Mastering Display Color Volume metadata within an HEVC stream. They inform compatible displays about the peak brightness capabilities of the content being played back. Without accurate values, HDR content may appear washed out or excessively dark on modern televisions and monitors. The x265 encoder allows you to inject this information directly into the bitstream. This is distinct from tone mapping, which adjusts the visual appearance of the video. Instead, this process sets the reference levels that the playback device uses to map the encoded pixels to the display's physical luminance capabilities. Proper configuration ensures that highlights retain their intended intensity without clipping or losing detail in the shadows.Command Line Configuration Steps
To modify these values, you need to use the command-line interface of x265. The encoder accepts specific arguments that correspond to the light level limits. Follow these steps to integrate the settings into your encoding pipeline. 1. Identify the peak brightness of your source material. This is typically measured in nits using a calibration tool or derived from the mastering display specifications. 2. Determine the average maximum brightness across any single frame. This value is usually lower than the peak but higher than the general scene average. 3. Construct your x265 command with the appropriate flags. Use the following structure to include both parameters simultaneously.x265 --max-cll [peak_nits] --max-fall [avg_nits] input.y4m -o output.hevc
Replace [peak_nits] with your calculated MaxCLL value and [avg_nits] with your calculated MaxFLL value. For example, if your mastering display has a peak of 1000 nits and a frame average of 400 nits, the command would look like this:
x265 --max-cll 1000 --max-fall 400 input.y4m -o output.hevc
This approach embeds the metadata directly into the HEVC container. It is the most reliable method for ensuring compatibility with streaming platforms and local players that respect these standards. Note that these values do not alter the pixel data itself; they only provide hints to the renderer. If you need to change the actual brightness, you must use tone mapping filters such as --hdr-opt or external tools like FFmpeg prior to encoding.
Verifying the Encoded Stream
After encoding, it is essential to verify that the metadata was correctly written. You can use media inspection tools to read the HEVC sequence parameter set. Tools like MediaInfo or ffprobe can extract this information without decoding the entire video. Run the following command to check the details:ffprobe -v error -select_streams v:0 -show_entries stream=side_data_list -of json output.hevc
Look for the side data type labeled "Mastering display color volume". Within this section, you will find the max_cll and max_fall fields. Ensure they match the values you passed to the encoder. If they differ, there may be an issue with how the encoder handled the flags or if another process modified the file afterward.
For users interested in broader streaming infrastructure, understanding how metadata affects delivery is crucial. Related discussions on streaming architecture can be found in React Front-end Fails to Fetch Video Server via Streaming, which covers network-level considerations that often accompany complex video formats.