Commit 1f265a4f by claincly Committed by Ian Baker

Add trying 1/3 resolution in fallback.

1/4 is probably unnecessary, as 1/3 of 4k is 720, which should be supported on
all practical encoders.

PiperOrigin-RevId: 440055144
parent 8709b1ef
...@@ -145,6 +145,13 @@ public final class EncoderUtil { ...@@ -145,6 +145,13 @@ public final class EncoderUtil {
return new Size(newWidth, newHeight); 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. // Fix frame being too wide or too tall.
width = videoEncoderCapabilities.getSupportedWidths().clamp(width); width = videoEncoderCapabilities.getSupportedWidths().clamp(width);
int adjustedHeight = videoEncoderCapabilities.getSupportedHeightsFor(width).clamp(height); int adjustedHeight = videoEncoderCapabilities.getSupportedHeightsFor(width).clamp(height);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment