[FFmpeg-trac] #7756(avcodec:new): add mastering display color volume and content light level information to hevc_metadata bitstream filter
FFmpeg
trac at avcodec.org
Fri Aug 22 13:14:43 EEST 2025
#7756: add mastering display color volume and content light level information to
hevc_metadata bitstream filter
-------------------------------------+-----------------------------------
Reporter: sneaker | Owner: (none)
Type: enhancement | Status: new
Priority: wish | Component: avcodec
Version: git-master | Resolution:
Keywords: hevc | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
-------------------------------------+-----------------------------------
Comment (by Miklos Juhasz):
I've created a patch to add support for Maximum Content Light Level
(MaxCLL) and Maximum Frame-Average Light Level (MaxFALL) metadata to the
hevc_metadata bitstream filter. This will allow users to insert or modify
this HDR metadata in HEVC streams.
Here's a link to the patch:
[[https://gist.github.com/mjuhasz/e1f01937c44108dc442f3a4ea2d9b2a5|add-
hdr-sei.patch]]
The attached patch adds master_display and max_cll options to the
hevc_metadata bitstream filter to handle Mastering Display Colour Volume
and Content Light Level Information SEI messages respectively. It ensures
the filter is idempotent by replacing any existing SEI messages of the
same type.
The syntax is the same as that for x265, see
[[https://x265.readthedocs.io/en/master/cli.html#cmdoption-master-
display|documentation]]
{{{
ffmpeg -i input.hevc -c copy -bsf:v
"hevc_metadata=max_cll='1000,400':master_display='G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,1)’"
output.hevc
}}}
According to the HEVC specification (ITU-T H.265), MaxCLL and MaxFALL
information is contained within Supplemental Enhancement Information (SEI)
messages. These SEI messages with static metadata, such as mastering
display and content light level information, are often repeated within the
bitstream to ensure that a decoder can begin playback from any random
access point. Industry best practice is to repeat this information at
every Intra Random Access Point (IRAP) frame.
My implementation reflects this understanding of the HEVC specification in
the following ways:
• The filter first removes any pre-existing MaxCLL and MaxFALL SEI
messages to avoid conflicts.
• If the removal of an SEI message results in an empty NAL unit, that
empty NAL unit is also removed to prevent bitstream corruption.
• The new MaxCLL and MaxFALL information is then inserted as a new SEI
message only at access units containing IRAP frames or parameter sets.
This ensures that the static metadata is available at every random access
point without unnecessarily bloating the stream by repeating it in every
access unit.
I tested this patch extensively and it works as expected. I also submitted
it to the FFmpeg developer mailing list in the hope that a developer will
review it and that it can eventually be merged into the main FFmpeg
project.
--
Ticket URL: <https://trac.ffmpeg.org/ticket/7756#comment:2>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list