Opened 6 months ago

Last modified 6 months ago

#7037 new defect

ffmpeg destroys HDR information when encoding

Reported by: mario66 Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: libx265 hdr
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

Hi,

I have a new 4k bluray with a 10 bit HDR movie and I now want to convert it to 1080p with x265, but keep the HDR.

I downloaded a ffmpeg binary build against 10 bit x265 and started the conversion with '-vf "scale=1920x1080"' option. While the resultsing video is indeed encoded with the Main10 profile, the video itself looks dull and as if the HDR information was lost. I notice that metadata changed.

In the original video, there are the following tags:

colour_range                             : Limited
colour_primaries                         : BT.2020
transfer_characteristics                 : PQ
matrix_coefficients                      : BT.2020 non-constant
MasteringDisplay_ColorPrimaries          : R: x=0.680000 y=0.320000, G: x=0.265000 y=0.690000, B: x=0.150000 y=0.060000, White point: x=0.312700 y=0.329000
MasteringDisplay_Luminance               : min: 0.0050 cd/m2, max: 4000.0000 cd/m2
MaxCLL                                   : 500 cd/m2
MaxFALL                                  : 200 cd/m2

In my new video, these are not included any more. I consider this to be a BUG because I never told ffmpeg to mess with color spaces etc. therefore ffmpeg should just leave everything as it is including the metadata.

How to reproduce:

% ffmpeg -i in.mkv -vf "scale=1920x1080" -map 0:v -map 0:a? -map 0:s? -c:v libx265 [-pix_fmt yuv420p10le] -c:a copy -c:s copy out.mkv

The argument in square brackets is an alternative I tried but the result is the same.

Version:
ffmpeg-20180220-a877d22-win64-static

Change History (6)

comment:1 Changed 6 months ago by jamrial

What's lost, only the MasteringDisplay?, MaxCLL and MaxFALL values, or also colour_range, colour_primaries, transfer_characteristics and matrix_coefficients?

Also, can you provide us with a sample to reproduce this? What's the x265 version you're using?

comment:2 Changed 6 months ago by mario66

Everything is gone. Also colour_range, etc.

Sample:
https://we.tl/xpeDCFJYDH

It's only the Time Warner logo, but you can see the difference very clearly. And you can see the that the tags are lost. (Note: Not the original video, but the bug is still reproducible on that)

It says "ffmpeg version N-90094-ga877d22d9a" and "x265 2.6+37-1949157705ce:[Windows][GCC 7.2.0][64 bit] 10bit" (for the x265 included in ffmpeg)

Last edited 6 months ago by mario66 (previous) (diff)

comment:3 Changed 6 months ago by cehoyos

  • Component changed from undetermined to avcodec
  • Keywords libx265 added
  • Priority changed from important to normal

comment:4 Changed 6 months ago by mario66

Could someone from the ffmpeg team please download the sample and store it somewhere internally? I just saw that WeTransfer? deletes the file after 7 days automatically. Unfortunately I couldn't upload to your website because you have a filesize limit of 2,5 MB...

Last edited 6 months ago by mario66 (previous) (diff)

comment:5 Changed 6 months ago by mario66

  • deleted -
Last edited 6 months ago by mario66 (previous) (diff)
Note: See TracTickets for help on using tickets.