Closed parkerlreed closed 3 weeks ago
Realized this may be due to the 5th camera being a depth sensor that can't be grabbed like a normal device
[parker@rogally ~]$ scrcpy --video-source=camera --camera-id=4
scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
INFO: Camera video source: control disabled
INFO: Camera video source: microphone audio source selected
INFO: ADB device found:
INFO: --> (usb) R5CNB05JENH device SM_G986U1
/usr/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 115.7 MB/s (69007 bytes in 0.001s)
[server] INFO: Device: [samsung] samsung SM-G986U1 (Android 13)
INFO: Renderer: opengl
INFO: OpenGL version: 4.6 (Compatibility Profile) Mesa 24.0.5-arch1.1
INFO: Trilinear filtering enabled
ERROR: Demuxer 'video': stream disabled due to connection error
ERROR: Demuxer 'audio': stream disabled due to connection error
ERROR: Demuxer error
[server] ERROR: Exception on thread Thread[video,5,main]
java.lang.NullPointerException: Attempt to get length of null array
at java.util.Arrays.stream(Arrays.java:5473)
at com.genymobile.scrcpy.FakeContext$$ExternalSyntheticApiModelOutline0.m(Unknown Source:0)
at com.genymobile.scrcpy.CameraCapture.selectSize(CameraCapture.java:130)
at com.genymobile.scrcpy.CameraCapture.init(CameraCapture.java:80)
at com.genymobile.scrcpy.SurfaceEncoder.streamScreen(SurfaceEncoder.java:55)
at com.genymobile.scrcpy.SurfaceEncoder.lambda$start$0$com-genymobile-scrcpy-SurfaceEncoder(SurfaceEncoder.java:253)
at com.genymobile.scrcpy.SurfaceEncoder$$ExternalSyntheticLambda0.run(Unknown Source:4)
at java.lang.Thread.run(Thread.java:1012)
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).
scrcpy-server
SHA-256: b92c92032f0afaf462a4df551eec9e880e716c7302c16119ee50c9c017b79a9
That seems to have worked!
[parker@rogally ~]$ scrcpy --list-camera-sizes
scrcpy 2.4 <https://github.com/Genymobile/scrcpy>
INFO: ADB device found:
INFO: --> (usb) R5CNB05JENH device SM_G986U1
/usr/share/scrcpy/scrcpy-server: 1 file pushed, 0 skipped. 262.1 MB/s (163648 bytes in 0.001s)
[server] INFO: Device: [samsung] samsung SM-G986U1 (Android 13)
[server] INFO: List of cameras:
--camera-id=0 (back, 4032x3024, fps=[15, 24, 30])
- 4032x3024
- 4032x2268
- 4032x1816
- 3024x3024
- 1920x824
- 3840x2160
- 1920x1080
- 2400x1080
- 1920x864
- 1920x1440
- 1440x1080
- 1088x1088
- 1280x720
- 960x720
- 720x480
- 640x480
- 640x360
- 352x288
- 320x240
- 256x144
- 176x144
High speed capture (--camera-high-speed):
- 1280x720 (fps=[120, 240])
- 1920x1080 (fps=[120, 240])
- 1920x824 (fps=[120, 240])
--camera-id=1 (front, 3648x2736, fps=[15, 24, 30])
- 3648x2736
- 3648x2048
- 3648x1640
- 2736x2736
- 1920x824
- 1920x1080
- 2400x1080
- 1920x864
- 1920x1440
- 1440x1080
- 1088x1088
- 1280x720
- 960x720
- 720x480
- 640x480
- 640x360
- 352x288
- 320x240
- 256x144
- 176x144
High speed capture (--camera-high-speed):
- 1280x720 (fps=[120])
- 1920x1080 (fps=[120])
- 1920x824 (fps=[120])
--camera-id=2 (back, 4032x3024, fps=[15, 24, 30])
- 4032x3024
- 4032x2268
- 4032x1816
- 3024x3024
- 1920x824
- 3840x2160
- 1920x1080
- 2400x1080
- 1920x864
- 1920x1440
- 1440x1080
- 1088x1088
- 1280x720
- 960x720
- 720x480
- 640x480
- 640x360
- 352x288
- 320x240
- 256x144
- 176x144
--camera-id=3 (front, 3216x2208, fps=[15, 24, 30])
- 3216x1808
- 3216x1448
- 2944x2208
- 2944x1656
- 2944x1320
- 2208x2208
- 1920x824
- 1920x1080
- 2400x1080
- 1920x864
- 1920x1440
- 1440x1080
- 1088x1088
- 1280x720
- 960x720
- 720x480
- 640x480
- 640x360
- 352x288
- 320x240
- 256x144
- 176x144
High speed capture (--camera-high-speed):
- 1280x720 (fps=[120])
- 1920x1080 (fps=[120])
- 1920x824 (fps=[120])
--camera-id=4 (back, 640x480, fps=[5, 10, 15, 20])
(none)
Side note: I can do 1080 60 for video recording but this seems to not list it?
Camera ID 0 says max of 30 and when I trying specifying ID 0 size 1080 and FPS 60 I get Camera capture failed.
That seems to have worked!
Merged bcb8503b261969c1ec176c7b852f9e0a4924db7b into dev
:rocket:
Side note: I can do 1080 60 for video recording but this seems to not list it?
Camera ID 0 says max of 30 and when I trying specifying ID 0 size 1080 and FPS 60 I get Camera capture failed.
Looks like #4675. Can you record at 1080p 60fps with another camera app (like OpenCamera)?
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).