Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AMD HW AV1 with Color Range "Full" outputs wrong colors #9121

Open
akiirui opened this issue Jun 22, 2023 · 15 comments
Open

AMD HW AV1 with Color Range "Full" outputs wrong colors #9121

akiirui opened this issue Jun 22, 2023 · 15 comments

Comments

@akiirui
Copy link

akiirui commented Jun 22, 2023

Operating System Info

Windows 11

Other OS

No response

OBS Studio Version

Other

OBS Studio Version (Other)

29.1.3

OBS Studio Log URL

https://obsproject.com/logs/lXfDZatEdQGpF247

OBS Studio Crash Log URL

No response

Expected Behavior

Use AMD HW AV1 encoder, when different color range "limited" and "full" the colors should be nearly identical when viewed with the naked eye.

Current Behavior

Use AMD HW AV1 encoder, when the different color ranges "limited" and "full", the color is different when viewed with the naked eye.

mediainfo outputs of range-limited.mkv:

Video
ID                                       : 1
Format                                   : AV1
Format/Info                              : AOMedia Video 1
Format profile                           : Main@L5.2
Codec ID                                 : V_AV1
Duration                                 : 5 s 434 ms
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Original height                          : 1 082 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 60.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Default                                  : No
Forced                                   : No
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : sRGB/sYCC
Matrix coefficients                      : BT.709

mediainfo outputs of range-full.mkv:

Video
ID                                       : 1
Format                                   : AV1
Format/Info                              : AOMedia Video 1
Format profile                           : Main@L5.2
Codec ID                                 : V_AV1
Duration                                 : 5 s 400 ms
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Original height                          : 1 082 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 60.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Default                                  : No
Forced                                   : No
Color range                              : Full
colour_range_Original                    : Limited
Color primaries                          : BT.709
Transfer characteristics                 : sRGB/sYCC
Matrix coefficients                      : BT.709

Screenshot of range-limited.mkv:
range-limited mkv-00_00_03 400-0001

Screenshot of range-full.mkv:
range-full mkv-00_00_00 533-0001

The original background imange:
1141274

two videos.zip

Steps to Reproduce

  1. Set Output - "Video Encoder" to AMD HW AV1
  2. Set Advanced - "Color Format" to NV12, "Color Space" to sRGB and "Color Range" to limited.
  3. Record a video with range limited
  4. Set Advanced - "Color Format" to NV12, "Color Space" to sRGB and "Color Range" to full.
  5. Record a video with range full
  6. Compare two videos

Anything else we should know?

No response

@Fenrirthviti
Copy link
Member

What exactly are you playing the file back in? Many video players don't properly handle full color range, and we don't recommend using it in nearly all cases.

@akiirui
Copy link
Author

akiirui commented Jun 22, 2023

What exactly are you playing the file back in? Many video players don't properly handle full color range, and we don't recommend using it in nearly all cases.

I‘m using mpv to play these files. There looks like no difference between "Limited" and "Full" for the AMD HW H.265/H264 encoder.

And the video files of AMD HW AV1 encoder are attached, see two videos.zip

@Xorshasia
Copy link

What is your use case for full?

Most video editing applications and video streaming platforms expect a limited-range (partial) input; streaming or recording in Full range will result in color clipping, often reported as overly bright or dark image.

@akiirui
Copy link
Author

akiirui commented Jun 22, 2023

What is your use case for full?

Import to Davinci to edit, A larger color range helps me manipulate colors.
Of course we have many way to bypass this issue, such as use AMD HW H265 to record full range video. (that is works fine with full)
But here is a bug report for AMD HW AV1 encoder. Thanks.

@Xorshasia
Copy link

Doesn't seem like a bug, though, and seems to work exactly as intended. Limited matches the original, while using Full alters the original.

@akiirui
Copy link
Author

akiirui commented Jun 22, 2023

Doesn't seem like a bug, though, and seems to work exactly as intended. Limited matches the original, while using Full alters the original.

But from AOM AV encoder or others encoder, it not same as AMD HW AV1 encoder:

mediainfo outputs of AOM-limited:

Video
ID                                       : 1
Format                                   : AV1
Format/Info                              : AOMedia Video 1
Format profile                           : Main@L4.1
Codec ID                                 : V_AV1
Duration                                 : 5 s 367 ms
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 60.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Default                                  : No
Forced                                   : No
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : sRGB/sYCC
Matrix coefficients                      : BT.709

mediainfo outputs of AOM-full:

Video
ID                                       : 1
Format                                   : AV1
Format/Info                              : AOMedia Video 1
Format profile                           : Main@L4.1
Codec ID                                 : V_AV1
Duration                                 : 5 s 384 ms
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 60.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Default                                  : No
Forced                                   : No
Color range                              : Full
Color primaries                          : BT.709
Transfer characteristics                 : sRGB/sYCC
Matrix coefficients                      : BT.709

Screenshot of limited:
AOM-limited mkv-00_00_00 583-0001

Screenshot of full:
AOM-full mkv-00_00_01 617-0001

@flaeri
Copy link
Contributor

flaeri commented Jun 22, 2023

@akiirui Could you do the same test with mp4, and upload both partial and full?

@akiirui
Copy link
Author

akiirui commented Jun 22, 2023

@akiirui Could you do the same test with mp4, and upload both partial and full?

Same as mkv. here are two videos, use AMD HW AV1 encoder and mp4. mp4.zip

@flaeri
Copy link
Contributor

flaeri commented Jun 22, 2023

Indeed it is the same, but it ruled out an important factor :)

The code is there to set full range, and seeing as the code is working for HEVC, I believe the path is valid.

	case VIDEO_CS_SRGB:
		enc->amf_color_profile =
			enc->full_range
				? AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_709
....
set_av1_property(enc, OUTPUT_COLOR_PROFILE, enc->amf_color_profile);

Unfortuantely its not possible for me to confirm, seeing as I don't have an AMD av1 encoder avaliable to me.

As per AMD's documentation, that seems to be all that should be required, unlike HEVC, which requires:

set_hevc_property(enc, OUTPUT_COLOR_PROFILE, enc->amf_color_profile);
set_hevc_property(enc, NOMINAL_RANGE, enc->full_range);

There is no NOMINAL_RANGE in the av1 headers, so even if want to set that, its not possible. Again, AMD docs seem to indicate that setting AV1_OUTPUT_COLOR_PROFILE -> COLOR_PROFILE_FULL_709 (which we do), should be sufficient.

Nonetheless, as far as I can see in the bitstream of the files you provided, the full range flag is not set (confirmed with a working aom-av1 file), so I think there is a possibility that this might be an AMF issue.

seq_header_obu\color_config():
color_range 0

In the working full range file from encoded with aom, this value is set to 1.

If you are able to confirm the issue with AMD's tools, like TranscodeHW, you could submit a bug report/issue on their github. Or perhaps reproducing with ffmpeg will suffice as validity (tested 2 implementations).

@akiirui
Copy link
Author

akiirui commented Jun 22, 2023

@flaeri Thanks.

In AMF_Video_Encode_AV1_API.md - Name: AMF_VIDEO_ENCODER_AV1_OUTPUT_COLOR_PROFILE's Description, NOMINAL_RANGE has been mentioned.
But in VideoEncoderAV1.h, It does not exist.

Maybe it's an AMF issue, I'll open an issue for it.

@SuslikV
Copy link
Contributor

SuslikV commented Jun 22, 2023

The 10-bit display while recording 8-bit content? From the log:

11:18:12.475: bits_per_color=10
11:18:12.475: space=RGB_FULL_G22_NONE_P709
11:18:12.475: sdr_white_nits=80

Without test tables(images) it is hard to say where the error is (display/encode/screenshot etc).

I have few test charts for 8-bit:
https://obsproject.com/forum/resources/obs-studio-color-space-color-format-color-range-settings-guide-test-charts.442/
But you have 10-bit display.

@akiirui
Copy link
Author

akiirui commented Jun 22, 2023

@SuslikV 1080p test charts here.
Video: test_charts.zip

Full:
full-1
full-2

Limited:
limited-1
limited-2

@SuslikV
Copy link
Contributor

SuslikV commented Jun 22, 2023

What name:
"amd-hw-av1_full.mkv"
mean?

I'm not common with the AV1 encoder but it seems this media file has no range flag set at all, so almost any player will assume a partial range video here (while it can be full range and from what I see - I assume it is).

You can try make new shortcut to the mpv player and add in the end --vf=format:colorlevels=full(this will ignore range flags and force full range on decoding). Run the shortcut and drag-n-drop the media file into the player, to see if the media can be displayed normally on your monitor (it is still 10-bit device, so it is unknown what you really see).

@akiirui
Copy link
Author

akiirui commented Jun 22, 2023

What name: "amd-hw-av1_full.mkv" mean?

Just color range "full".

You can try make new shortcut to the mpv player and add in the end --vf=format:colorlevels=full

Yep, that let this video displayed normally.

Such as @flaeri says, AMF av1 encoder doesn't set the full range flag. Maybe that's what's causing the problem.

Thanks.

@Kobi-Blade
Copy link

Kobi-Blade commented Nov 15, 2023

This is a long standing issue with OBS not AMF, try recording with Game Bar or Radeon Software and you'll get full HDR in the video.

I reported this back in 2022 and was ignored, #7451

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants