-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
Unable to list camera sizes on S20+ #4852
Comments
Realized this may be due to the 5th camera being a depth sensor that can't be grabbed like a normal device
|
Thank you for your report. Could you please retry with these changes: diff --git a/server/src/main/java/com/genymobile/scrcpy/CameraCapture.java b/server/src/main/java/com/genymobile/scrcpy/CameraCapture.java
index a1003829f..df3cf7c4f 100644
--- a/server/src/main/java/com/genymobile/scrcpy/CameraCapture.java
+++ b/server/src/main/java/com/genymobile/scrcpy/CameraCapture.java
@@ -127,6 +127,10 @@ public class CameraCapture extends SurfaceCapture {
StreamConfigurationMap configs = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
android.util.Size[] sizes = highSpeed ? configs.getHighSpeedVideoSizes() : configs.getOutputSizes(MediaCodec.class);
+ if (sizes == null) {
+ return null;
+ }
+
Stream<android.util.Size> stream = Arrays.stream(sizes);
if (maxSize > 0) {
stream = stream.filter(it -> it.getWidth() <= maxSize && it.getHeight() <= maxSize);
diff --git a/server/src/main/java/com/genymobile/scrcpy/LogUtils.java b/server/src/main/java/com/genymobile/scrcpy/LogUtils.java
index efa0672b7..1ffb19d3c 100644
--- a/server/src/main/java/com/genymobile/scrcpy/LogUtils.java
+++ b/server/src/main/java/com/genymobile/scrcpy/LogUtils.java
@@ -118,12 +118,16 @@ public final class LogUtils {
StreamConfigurationMap configs = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
android.util.Size[] sizes = configs.getOutputSizes(MediaCodec.class);
- for (android.util.Size size : sizes) {
- builder.append("\n - ").append(size.getWidth()).append('x').append(size.getHeight());
+ if (sizes == null || sizes.length == 0) {
+ builder.append("\n (none)");
+ } else {
+ for (android.util.Size size : sizes) {
+ builder.append("\n - ").append(size.getWidth()).append('x').append(size.getHeight());
+ }
}
android.util.Size[] highSpeedSizes = configs.getHighSpeedVideoSizes();
- if (highSpeedSizes.length > 0) {
+ if (highSpeedSizes != null && highSpeedSizes.length > 0) {
builder.append("\n High speed capture (--camera-high-speed):");
for (android.util.Size size : highSpeedSizes) {
Range<Integer>[] highFpsRanges = configs.getHighSpeedVideoFpsRanges(); Here is a server binary including the changes (for scrcpy v2.4).
|
That seems to have worked!
|
Merged bcb8503 into
Looks like #4675. Can you record at 1080p 60fps with another camera app (like OpenCamera)? |
The array of sizes may be null. Handle this case gracefully. Fixes Genymobile#4852 <Genymobile#4852>
The array of sizes may be null. Handle this case gracefully. Fixes Genymobile#4852 <Genymobile#4852>
Environment
Describe the bug
Listing cameras works as expected but then going to list sizes results in a crash.
On errors, please provide the output of the console (and
adb logcat
if relevant).The text was updated successfully, but these errors were encountered: