Opened 3 months ago

Last modified 2 months ago

#10884 new defect

Using `-hwaccel_output_format videotoolbox_vld` make `scale_vt` to produce wrong color

Reported by: gnattu Owned by:
Priority: normal Component: avfilter
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:

When use -hwaccel_output_format videotoolbox_vld with scale_vt filter, the output SDR file will have a wrong color. The red light would appears to be yellow.

The sunlight from below video sample from LG promotion will produce a difference that is very easy to tell:

https://isovideo.com/SDR_to_HLG_Conversion_Clips/LG_4K_OLED_Wonders-184055-tmu_hlg10_hevc.mkv

How to reproduce:

Run below command and the test.mp4 will have wrong color:

% ./ffmpeg -hwaccel videotoolbox \
        -hwaccel_output_format videotoolbox_vld \
        -i LG_4K_OLED_Wonders-184055-tmu_hlg10_hevc.mkv \
        -c:v hevc_videotoolbox \
        -profile:v main \
        -b:v 3M \
        -vf scale_vt=w=iw/2:h=ih/2:color_matrix=bt709:color_primaries=bt709:color_transfer=bt709 \
        -c:a copy \
        -tag:v hvc1 \
        test.mp4

Run this, just removing the -hwaccel_output_format videotoolbox_vld \ line, and replace it with an hwupload, will give you a correct color:

%./ffmpeg -hwaccel videotoolbox \
	-i /Users/gnattu/Movies/ffmpeg-sample/4K_HLG.mkv \
	-c:v hevc_videotoolbox \
	-profile:v main \
	-b:v 3M \
	-vf hwupload,scale_vt=w=iw/2:h=ih/2:color_matrix=bt709:color_primaries=bt709:color_transfer=bt709 \
	-c:a copy \
	-tag:v hvc1 \
	test-correct.mp4

Attachments (2)

wrong-color.jpg (382.3 KB ) - added by gnattu 3 months ago.
The wrong color output. The sunlight appears too yellow.
correct-color.jpg (385.0 KB ) - added by gnattu 3 months ago.
The correct color output. The sunlight looks more natural.

Download all attachments as: .zip

Change History (4)

by gnattu, 3 months ago

Attachment: wrong-color.jpg added

The wrong color output. The sunlight appears too yellow.

by gnattu, 3 months ago

Attachment: correct-color.jpg added

The correct color output. The sunlight looks more natural.

comment:1 by yigithan, 3 months ago

I am new at this project but looks like pixel format causes the problem.

With -hwaccel_output_format videotoolbox_vld you are using videotoolbox_vld as pix_fmt. If you run like that -hwaccel_output_format p010le it should work as expected With hwupload parameter passed. I could not figure out how videotoolbox selects pixel format inside (If it have different format). But looks like it's supporting in the official documentation.

Like;

./ffmpeg -loglevel 45  -hwaccel videotoolbox \
        -hwaccel_output_format p010le \
        -i LG_4K_OLED_Wonders-184055-tmu_hlg10_hevc.mkv \
        -c:v hevc_videotoolbox \
        -profile:v main \
        -b:v 3M \
        -vf hwupload,scale_vt=w=iw/2:h=ih/2:color_matrix=bt709:color_primaries=bt709:color_transfer=bt709 \
        -c:a copy \
        -tag:v hvc1 \
        test3.mp4

Works perfectly fine.

Last edited 2 months ago by yigithan (previous) (diff)

comment:2 by yigithan, 2 months ago

With some research, the problem looks like to me "Tone mapping". I am not sure I am still trying to figure out but it looks like default videotoolbox_vld making basic tone mapping? during hardware decoding and if specify the pix_fmt in this case the format = p010le which is 10 bit format, I could not understand why it is works but it looks like it supposed to be.

Last edited 2 months ago by yigithan (previous) (diff)
Note: See TracTickets for help on using tickets.