Tool

HDR10 Metadata Preservation Helper

If you re-encoded HDR video with x265 and it now looks washed out in a player, or the HDR badge is gone, the HDR information inside the video probably did not carry over. Paste the source’s ffprobe output or MediaInfo text and this tool builds the master-display and max-cll strings and the commands. After encoding, it compares the result file to show whether the information survived.

Format examples:

Pasted text is not sent to a server; it is analyzed only inside this browser. The examples only show the format; they were not read from a real file.

2. Check and edit the values (color coordinates as decimals from 0 to 1, luminance in cd/m²)

3. Generated options

x265 master-display

– (color coordinates and luminance are both required)

Color coordinates are converted to integers in 0.00002 steps, and luminance to integers in 0.0001 cd/m² steps.

x265 max-cll

– (both MaxCLL and MaxFALL are required)

x265 (HEVC) command

ffmpeg -i input.mkv -map 0:v:0 -map 0:a? -c:v libx265 -preset medium -crf <CRF> -pix_fmt yuv420p10le -x265-params "hdr10=1:repeat-headers=1:colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc" -c:a copy output.mkv

x265-params must be wrapped in quotes so the parentheses are not broken by the shell. Audio is copied as-is, and subtitles are not included.

SVT-AV1 command

ffmpeg -i input.mkv -map 0:v:0 -map 0:a? -c:v libsvtav1 -preset 6 -crf <CRF> -pix_fmt yuv420p10le -color_primaries bt2020 -color_trc smpte2084 -colorspace bt2020nc -svtav1-params "enable-hdr=1" -c:a copy output.mkv

SVT-AV1's HDR option names and notation can differ by version. Be sure to check the result with the step 4 verification below.

4. Verify after encoding

Run the command below on the output file, then paste its output to compare it item by item with the values above.

ffprobe command for verification

ffprobe -v error -select_streams v:0 -read_intervals "%+#1" -show_streams -show_frames -of json output.mkv

Where do I get the source information?

  • ffprobe (recommended): ffprobe -v error -select_streams v:0 -read_intervals "%+#1" -show_streams -show_frames -of json input.mkv. It reads only the first frame, so it is fast. Mastering display values come out as fractions such as red_x=34000/50000, and this tool converts them to integers and decimals.
  • MediaInfo: copy the entire ‘Text’ view. Note that MediaInfo sometimes shows the color primaries only as a name such as Display P3 instead of numbers. In that case the tool fills in the standard coordinates for that name and marks that it did so. If there is neither a name nor coordinates, the fields stay empty, so use ffprobe output instead.
  • Many files contain no MaxCLL or MaxFALL at all. If they are missing, they are simply left out of the options. It is safer not to put in made-up values.

What the generated options mean

  • master-display=G(x,y)B(x,y)R(x,y)WP(x,y)L(max,min): the color primaries, white point and maximum/minimum luminance of the monitor the video was graded (mastered) on. x265 takes color coordinates in units of 0.00002 and luminance in units of 0.0001 cd/m², as integers. For example, 0.265 becomes 13250 and 1000 cd/m² becomes 10000000.
  • max-cll=MaxCLL,MaxFALL: the brightest single pixel in the whole video (MaxCLL) and the highest frame-average brightness (MaxFALL), both in cd/m².
  • hdr10=1 and repeat-headers=1: write the HDR information into the bitstream and repeat the headers at every keyframe, so the information is present even when playback starts in the middle.
  • colorprim, transfer and colormatrix: the color tags. When they are missing, a player may interpret HDR (PQ) video as SDR, and the colors look washed out. This is explained in Why colors look washed out and gamma, transfer function and HDR.
  • -pix_fmt yuv420p10le: HDR10 assumes 10-bit. Exporting 8-bit makes the gradations coarser and reduces the point of HDR.

How to use it

  1. Run the ffprobe command above on the source and paste the output into box 1. The values it read are filled into box 2, and you can correct any that are wrong or missing.
  2. Copy the command from step 3, choose a CRF and run it. You can get a rough idea of CRF and preset from the CRF Recommender and the FFmpeg Command Builder, which are based on our SDR 8-bit measurements. We have never measured values for HDR 10-bit video, so treat them as a reference only.
  3. Run the verification command from step 4 on the result file and paste the output. Check that the tags, bit depth, mastering display and MaxCLL each show ‘Match’.
  4. If the problem is on the playback side, check the screen and decoder with the Browser HDR Checker and the Codec Support Checker, and look at the file’s basic information with the Video File Info Inspector.

Limitations worth knowing

  • This tool only builds and compares strings. It does not contain results from encoding and verifying files on this site. Whether a generated command records the values as-is in your build of FFmpeg is something you have to confirm yourself with the step 4 verification.
  • FFmpeg sometimes passes the mastering display and MaxCLL information attached to the input video to the encoder automatically, and the behavior is known to differ by version. A value you specify yourself should match the automatically passed one; if it does not, use the verification to see which one was written.
  • SVT-AV1 options differ a lot between versions. The names and notation of enable-hdr, mastering-display and content-light can vary from build to build, and some users have reported that the metadata was not written in some versions. Use the command only as a starting point.
  • Dynamic metadata for Dolby Vision and HDR10+ is not preserved this way. If the tool detects it, it only shows a warning above.
  • Coordinates filled in from a MediaInfo name are standard values, not values read from the file. For HLG, only the color tags are set, without mastering display or MaxCLL.
  • Converting HDR down to SDR (tone mapping) is not covered. For the steps, see HDR to SDR tone mapping.
  • Pasted text is not sent to a server. If the output contains a file path, remove it before pasting.