video – FFMPEG keeps HDR10 data in a sdr tone-mapped output

Im trying to convert a prores file with embedded hdr10 metadata to a sdr h264 and h265 tonemapped version. but what ever I try the HDR data from the prores file is alway in the output file.

Im running the latest ffmpeg version from brew (6.0)

my script is

ffmpeg -i input/input-test-embeded.mov \
 -vf "scale=-1:540, 'zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=pc,format=yuv420p10le', sidedata=delete, metadata=delete" \
-c:v libx265 \
-x265-params "no-hdr=1:repeat-headers=0:log-level=0:open-gop=0:scenecut=0:keyint="48":min-keyint="48":no-info=1" \
-preset ultrafast \
-map_metadata -1\
-force_key_frames "expr:gte(t,n_forced*48)" \
-r 25 \
-map 0:v \
-b:v 700k \
-maxrate 1000k \
-bufsize 2000k \
-an \
-write_tmcd 0 \
-brand mp42 \
-movflags +faststart \
-pix_fmt yuv420p10le \
-color_range jpeg \
-f mp4 \
-tag:v hvc1 \
-y \
output/tonemap-test.mp4

Wen I run this script i get the following in MediaInfo

General
Complete name                            : /output/tonemap-test.mp4
Format                                   : MPEG-4
Format profile                           : Base Media / Version 2
Codec ID                                 : mp42 (mp42/iso2/mp41)
File size                                : 18.0 KiB
Duration                                 : 5 s 0 ms
Overall bit rate                         : 29.5 kb/s
Frame rate                               : 25.000 FPS
Writing application                      : Lavf60.3.100

Video
ID                                       : 1
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Format profile                           : Main 10@L3@Main
HDR format                               : SMPTE ST 2086, HDR10 compatible
Codec ID                                 : hvc1
Codec ID/Info                            : High Efficiency Video Coding
Duration                                 : 5 s 0 ms
Bit rate                                 : 25.3 kb/s
Maximum bit rate                         : 1 000 kb/s
Width                                    : 960 pixels
Height                                   : 540 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 25.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 10 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.002
Stream size                              : 15.4 KiB (86%)
Color range                              : Full
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709
Mastering display color primaries        : Display P3
Mastering display luminance              : min: 0.0050 cd/m2, max: 4000 cd/m2
Maximum Content Light Level              : 1000 cd/m2
Maximum Frame-Average Light Level        : 213 cd/m2
Codec configuration box                  : hvcC

And when I run the same script but change the input to a prores file that doesn’t have the metadata embedded I get this

General
Complete name                            : /output/tonemap-test.mp4
Format                                   : MPEG-4
Format profile                           : Base Media / Version 2
Codec ID                                 : mp42 (mp42/iso2/mp41)
File size                                : 18.0 KiB
Duration                                 : 5 s 0 ms
Overall bit rate                         : 29.5 kb/s
Frame rate                               : 25.000 FPS
Writing application                      : Lavf60.3.100

Video
ID                                       : 1
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Format profile                           : Main 10@L3@Main
Codec ID                                 : hvc1
Codec ID/Info                            : High Efficiency Video Coding
Duration                                 : 5 s 0 ms
Bit rate                                 : 25.3 kb/s
Maximum bit rate                         : 1 000 kb/s
Width                                    : 960 pixels
Height                                   : 540 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 25.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 10 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.002
Stream size                              : 15.4 KiB (86%)
Color range                              : Full
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709
Codec configuration box                  : hvcC

I also tried it with the x264 encoder but there also I got the HDR Metadata in the output file.

Is there a way to remove the metadata. Because I tried playing the output file on a sony tv with android tv via chromecast and the result was just garbage. And the file that hasn’t got the metadata played fine.

Read more here: Source link