[Features request / Discution] Support for HDR and HDR10 when MLT 8.x become ready
As MLT is aiming to add HDR support (8.x), we should start to discuss what Kdenlive should do on its part.
For simple HDR, it should be as simple as add support for the BT2020nc colour space
(with ffmpeg) -pix_fmt yuv420p10le -color_primaries bt2020 -color_trc smpte2084 -colorspace bt2020nc -color_range tv
HDR10 will require some more stuff as it need to use HEVC (x265) and keep or insert some metadata in the final output. It could be nice to have a panel in the app to specify the mastering display characteristic so it can be embedded in the metadata Also, the app could gain having an integrated tool that can calculate the maxFALL and maxCLL (a bit like DaVinci Resolve and other are capable of doing) so the user can fix those two values in the metadata.
- Maximum Frame-Average Light Level (MaxFALL). It corresponds to the highest frame average brightness per frame in the entire stream. The MaxFALL metadata value is represented in nits, a unit of luminance.
- Maximum Content Light Level (MaxCLL). It corresponds to the brightest pixel in the entire stream. The MaxCLL metadata is represented in nits.
Those information are send directly to the encoder (depend on how MLT will implement that)
(with ffmpeg) -x265-params hdr-opt=1:repeat-headers=1:colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc:range=limited:master-display="G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,1)":max-cll="1000,400"
I don't think it's possible to ever support HDR10+ (even if Kdenlive could be modified to support generating those metadata in json format before embedding) because of all the royalties around it.
I'm open to the discussion :-D I already produce HDR10 video from Blender's render using OpenEXR. But I can edit those video without loosing the HDR support :-/
ffmpeg -hwaccel auto -apply_trc smpte2084 -framerate 60 -i ./%4d.exr -c:v libx265 -preset 1 \
-pix_fmt yuv420p10le -color_primaries bt2020 -color_trc smpte2084 -colorspace bt2020nc -color_range tv \
-profile:v main10 -coder 1 \
-x265-params pass=1:keyint=30:min-keyint=30:bframes=2:hdr-opt=1:repeat-headers=1:colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc:range=limited:master-display="G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,1)":max-cll="1000,10" \
-b:v 100M -maxrate 300M -bufsize 100M -an -f null /dev/null && \
ffmpeg -hwaccel auto -apply_trc smpte2084 -framerate 60 -i ./%4d.exr -c:v libx265 -preset 1 \
-pix_fmt yuv420p10le -color_primaries bt2020 -color_trc smpte2084 -colorspace bt2020nc -color_range tv \
-profile:v main10 -coder 1 \
-x265-params pass=2:keyint=30:min-keyint=30:bframes=2:hdr-opt=1:repeat-headers=1:colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc:range=limited:master-display="G(13250,34500)B(7500,3000)R(34000,16000)WP(15635,16450)L(10000000,1)":max-cll="1000,10" \
-maxrate 300M -bufsize 100M -an -movflags +faststart ./hdr.mp4