encoding hevc hdr bt2020 lost


i’m not sure, if it should be supported already.
My problem is, that i want to re-encode an HDR clip with ffmpeg and hevc_nvenc and the colormatrix (bt2020) and transfer characteristic (smpte2084) get lost.

When i watch both clips on a non HDR display, they look the same.
On the HDR TV, on the re-econded clip it is not switching any more into HDR Mode.

Miss i something, or is this (currently) not available for nvenc_hevc?
FFmpeg issue or nvidia part?

I use an GTX1080.


This is likely an FFmpeg issue. The video encoder on GPUs has no notion of HDR or transfer characteristics (smpte2084). It simply does normal 10-bit 4:2:0 encoding.

As far as I am aware, FFmpeg 10-bit hardware decode-encode (i.e. transcode) pipeline is not fully functional yet.

10-bit encoding is only supported on HEVC in GTX1080. I am presuming that you are encoding using FFmpeg and HEVC codec.

ok… thanks. will see if ffmpeg will add more support.
I used an 1080.

At the present, HDR signalling is implemented in FFmpeg, as shown in the example below using a filter and a VAAPI-based encoder for reference.

For instance, with VAAPI, you’ll find support for features such as OpenCL-based tone map filters, allowing for HDR(HDR10/HLG) to SDR conversion with tone-mapping, with the example shown below, using a hardware device derived from the VAAPI initialization sequence:

ffmpeg -init_hw_device vaapi=va:/dev/dri/renderD128 -init_hw_device \
opencl=ocl@va -hwaccel vaapi -hwaccel_device va -hwaccel_output_format \
vaapi -i INPUT -filter_hw_device ocl -filter_complex \
'[0:v]hwmap,tonemap_opencl=t=bt2020:tonemap=linear:format=p010[x1]; \
[x1]hwmap=derive_device=vaapi:reverse=1' -c:v hevc_vaapi -profile 2 OUTPUT

The same filter chain can also be derived from an existing OpenCL device on the platform, say, with an NVIDIA GPU, as shown below, which assumes that the NVIDIA GPU is the first OCL device on the first platform (modify as needed):

ffmpeg -init_hw_device opencl=opencl:1.0  \
-hwaccel nvdec  \
-i INPUT -filter_hw_device opencl -filter_complex \
'[0:v]hwmap,tonemap_opencl=t=bt2020:tonemap=linear:format=p010[x1]; \
[x1]hwmap=derive_device=opencl' -c:v hevc_nvenc -preset:v slow 2 OUTPUT

Let me know if you need any further assistance.

Then run your ffmpeg command I got “Segmentation fault” error. Is it hwmap is usable with nvenc or only with vaapi?

ffmpeg -init_hw_device opencl=opencl:0.0 -i 720p.mp4 -filter_hw_device opencl \
-filter_complex '[0:v]hwmap,tonemap_opencl=t=bt2020:tonemap=linear:format=p010,hwmap=derive_device=opencl'\
-c:v h264_nvenc -an -b:v 6M -y out_opencl_nvenc.mp4