Unity-Technologies / com.unity.webrtc

WebRTC package for Unity
Other
759 stars 197 forks source link

[BUG]: The encoder sometimes chooses the wrong minimum level and causes a parameter exception #896

Open doctorpangloss opened 1 year ago

doctorpangloss commented 1 year ago

Package version

3.0.0-pre.4

Environment

* OS: Windows 2022
* Unity version: 2021 LTS

Steps To Reproduce

  1. Request a 1688x614 frame, frame rate 60, max bit rate 24000000, target bps 4925000
  2. Observe the level computing code incorrectly computes Level 4 for this request.
  3. Observe it should be at least 4.2.
  4. Observe an exception.
  5. m_level = std::max(m_level, NV_ENC_LEVEL_H264_42); resolves the issue.

Windows 2022 LTSC + DirectX 11 + NVEnc streaming to Windows Chrome: Works Windows 2022 LTSC + DirectX 11 + NVEnc streaming to Mobile Safari, Portrait: Works Windows 2022 LTSC + DirectX 11 + libvpx streaming to Mobile Safari, Portrait: Works Windows 2022 LTSC + DirectX 11 + libvpx streaming to Mobile Safari, Landscape: Works Windows 2022 LTSC + DirectX 11 + NVEnc streaming to Mobile Safari, Landscape: Does not work (see parameters to repro)

Current Behavior

An invalid parameter exception thrown by m_encoder->CreateEncoder(&m_initializeParams);

Expected Behavior

Select Profile 4.2 instead of 4.

Anything else?

The workaround is to always set the level to at least 4.2.

kannan-xiao4 commented 1 year ago

@doctorpangloss Thank you for reporting. We investigate this issue. memo: WRS-467

Can you tell me in which environment it occurs and in which environment there is no problem?

doctorpangloss commented 1 year ago

Windows 2022 LTSC + DirectX 11 + NVEnc streaming to Chrome: Works Windows 2022 LTSC + DirectX 11 + NVEnc streaming to Mobile Safari, Portrait: Works Windows 2022 LTSC + DirectX 11 + libvpx streaming to Mobile Safari, Portrait: Works Windows 2022 LTSC + DirectX 11 + libvpx streaming to Mobile Safari, Landscape: Works Windows 2022 LTSC + DirectX 11 + NVEnc streaming to Mobile Safari, Landscape: Does not work (see parameters to repro)

When using the particular parameters I wrote there, it should reproduce without needing to go through this whole rigamarole.

kannan-xiao4 commented 1 year ago

@doctorpangloss Thanks about detail.