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

Add per-frame encoding time in video encoding CPU connection health policy #2986

Merged
merged 2 commits into from
Nov 5, 2024

Conversation

shi-su
Copy link
Contributor

@shi-su shi-su commented Nov 5, 2024

Issue #:

Description of changes:
This change is to add per-frame encoding time as an additional criterion in video encoding CPU connection health policy. Coded will only degrade when both total encode time and per-frame encode time is above threshold. The purpose is to avoid codec degradation with high framerate SVC. Note that video encoder counts each spatial layer of a frame as a frame encoded (e.g., 30 fps video with L3T3 scalability mode has a encoded framerate of 90 fps), the default value of per-frame encode time threshold has this pattern considered.

Testing:
Smoke tested and verified video codec degradation only when both total encode time and per-frame encode time is above threshold.

Can these tested using a demo application? Please provide reproducible step-by-step instructions.
No

Checklist:

  1. Have you successfully run npm run build:release locally?
    y

  2. Do you add, modify, or delete public API definitions? If yes, has that been reviewed and approved?
    n

  3. Do you change the wire protocol, e.g. the request method? If yes, has that been reviewed and approved?
    n

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@shi-su shi-su force-pushed the per-frame-encode branch 2 times, most recently from 603adb9 to b2224c2 Compare November 5, 2024 01:15
@shi-su shi-su marked this pull request as ready for review November 5, 2024 01:19
@shi-su shi-su requested a review from a team as a code owner November 5, 2024 01:19
@@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Add per-frame encoding time in video encoding CPU connection health policy
Copy link
Contributor

@hensmi-amazon hensmi-amazon Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I messed this up in a previous PR (David's commit added Unreleased section). Can you put your change in the section below? I will move David's change in my PR.

}

health(): number {
const videoEncodingTimeIsHigh =
this.currentData.videoEncodingTimeInMs >= this.highEncodeCpuMsThreshold &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like we don't need both checks. But I assume you have a good reason already? :)

If so, maybe it can be a comment

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having both checks there is to avoid degrading codec in two conditions:

  1. When framerate is low but per-frame encoding time is high (e.g., high resolution screen share with low motion on screen, encoder sometimes just encode like one frame every second. There's no need to degrade codec if each of these frames takes 50 ms to encode);
  2. When frame rate is high (e.g., high framerate and SVC at the same time).

I don't think these two conditions can be excluded with the same check. So kept both here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment to explain the logic

@shi-su shi-su merged commit 3a906b4 into main Nov 5, 2024
10 checks passed
@shi-su shi-su deleted the per-frame-encode branch November 5, 2024 18:34
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

Successfully merging this pull request may close these issues.

2 participants