obsproject / obs-studio

OBS Studio - Free and open source software for live streaming and screen recording
https://obsproject.com
GNU General Public License v2.0
60.47k stars 8k forks source link

Set the codec level for AMF encoders #11548

Open lexano-ivs opened 20 hours ago

lexano-ivs commented 20 hours ago

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: