Skip to content

Commit

Permalink
Add trying 1/3 resolution in fallback.
Browse files Browse the repository at this point in the history
1/4 is probably unnecessary, as 1/3 of 4k is 720, which should be supported on
all practical encoders.

PiperOrigin-RevId: 440055144
  • Loading branch information
claincly authored and icbaker committed Apr 7, 2022
1 parent 8709b1e commit 1f265a4
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ public static Size getSupportedResolution(
return new Size(newWidth, newHeight);
}

// Try one-third (e.g. 4k -> 720).
newWidth = alignResolution(width / 3, widthAlignment);
newHeight = alignResolution(height / 3, heightAlignment);
if (videoEncoderCapabilities.isSizeSupported(newWidth, newHeight)) {
return new Size(newWidth, newHeight);
}

// Fix frame being too wide or too tall.
width = videoEncoderCapabilities.getSupportedWidths().clamp(width);
int adjustedHeight = videoEncoderCapabilities.getSupportedHeightsFor(width).clamp(height);
Expand Down

0 comments on commit 1f265a4

Please sign in to comment.