-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Set the codec level for AMF encoders #11548
base: master
Are you sure you want to change the base?
Set the codec level for AMF encoders #11548
Conversation
I'm generally fine with this, but I sort of want to hear other people's opinions. |
To check this, can I just record locally with AMF and check the codec level with FFmpeg or MediaInfo? Is this something that can be fixed in a driver or AMF update, or is this always expected to be handled by the encoder implementation? Should be there bugs filed at https://github.com/GPUOpen-LibrariesAndSDKs/AMF? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment lines can be expanded to up to 120 columns.
Yes that would work. If you stream using TEB you can also check the log message when streaming starts; I added the "level" output to confirm this was working.
All AMF documentation and source code indicates the encoder implementation should set this. There is no "Auto" setting. Refer to
Yeah probably, but it's an enhancement, not a bug. I've opened GPUOpen-LibrariesAndSDKs/AMF#533. |
00640b6
to
84e0128
Compare
You will probably have to manually rewrap comments to 120 columns because I don't think clang-format will touch them with our settings. |
I confirmed that the HEVC level is incorrect before these changes. Will check with the changes at a later time. I did also confirm that the AVC level does change based on the output settings (resolution+FPS) and seems to be mostly what I'd expect (I got 5.1 when I expected 5.2, but this is still different from the default 4.2), so something within AMF appears to be changing that as needed for AVC, but not for HEVC. |
The default "level" setting was being used for each codec (AVC, HEVC, AV1) supported by AMF. For example, all HEVC encoders were using level 6.2 and this caused some playback devices to reject the bitstream for decode because the device reported a maximum decode level lower than 6.2. Add functionality to determine the best match for the codec level instead of relying on the defaults.
84e0128
to
94a2599
Compare
Reformatted the comments to 120 columns with latest push. |
We tripped over this issue when testing HEVC playback in the TEB beta program, where the HEVC level was set to the maximum by default, so it's consistent with your findings re: HEVC. I don't recall at the moment what AVC was reporting back, but given that HEVC needed to be adjusted to solve mobile player compatibility issues (i.e. the mobile app player is doing the right thing and rejecting levels it can't handle), I adjusted AVC, HEVC, and AV1 "just in case". |
My comment was more along the lines of "there may be a bug in AMF where HEVC levels are not set" since AVC levels do seem to be automatically adjusted, despite also having a default value (4.2). I would suggest testing their sample apps, which notably do not all manually set levels. Since we do not currently set the AVC level in OBS Studio, that it adjusts on its own makes me think that AMF should be able to do this for HEVC and AV1. I could be wrong, but it seems odd. |
Hi @RytoEX , to clarify, AMF does currently adjust the profile levels based on the frame size however it does so by only increasing the profile level "upwards" and the current HEVC default profile level is set to the highest one. I have lowered the HEVC default profile level however this will only be take effect in a future public driver release. |
Description
The default "level" setting was being used for each codec (AVC, HEVC, AV1) supported by AMF. For example, all HEVC encoders were using level 6.2 and this caused some playback devices to reject decoding the bitstream because the device reported a maximum decode level lower than 6.2.
This PR adds functionality to determine the best match for the codec level instead of relying on the defaults, for AMF encoders.
Motivation and Context
The default behaviour of setting the codec level to the maximum resulted in several Android-based devices failing to decode HEVC streams in the TEB (Twitch Enhanced Broadcasting) beta program, which is currently testing HEVC compatibility. Adjusting the level appropriately instantly fixed the decode failures.
Also, most APIs (such as NVENC and VAAPI) have an "Auto" option for setting the codec level, in which case the driver or library code adjust the level. This Auto option doesn't seem to be available for AMF, hence the need to implement something at the application layer.
How Has This Been Tested?
Several local unit tests were carried out by using a configuration override with Enhanced Broadcasting to verify the selected level is accurate. The code has been (and continues to be) tested in the TEB beta builds.
Types of changes
Checklist: