From 14585b1a69ce7e537dcd681f7e109587401d13d9 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Thu, 5 Aug 2021 14:49:25 +0200 Subject: [PATCH 1/2] fix: Actually use a format's `videoSize` for Preview/Video Capture --- android/src/main/java/com/mrousavy/camera/CameraView.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/mrousavy/camera/CameraView.kt b/android/src/main/java/com/mrousavy/camera/CameraView.kt index 87147a2b25..28f265a672 100644 --- a/android/src/main/java/com/mrousavy/camera/CameraView.kt +++ b/android/src/main/java/com/mrousavy/camera/CameraView.kt @@ -357,9 +357,9 @@ class CameraView(context: Context) : FrameLayout(context), LifecycleOwner { val format = DeviceFormat(format!!) Log.i(TAG, "Using custom format - photo: ${format.photoSize}, video: ${format.videoSize} @ $fps FPS") val aspectRatio = aspectRatio(format.photoSize.width, format.photoSize.height) - previewBuilder.setTargetAspectRatio(aspectRatio) + previewBuilder.setTargetResolution(format.videoSize) imageCaptureBuilder.setDefaultResolution(format.photoSize) - videoCaptureBuilder.setDefaultResolution(format.photoSize) + videoCaptureBuilder.setDefaultResolution(format.videoSize) fps?.let { fps -> if (format.frameRateRanges.any { it.contains(fps) }) { From d452e199756119c236f9abf797f05fa975348078 Mon Sep 17 00:00:00 2001 From: Marc Rousavy Date: Thu, 5 Aug 2021 14:50:30 +0200 Subject: [PATCH 2/2] `setDefaultResolution` -> `setTargetResolution` --- android/src/main/java/com/mrousavy/camera/CameraView.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/android/src/main/java/com/mrousavy/camera/CameraView.kt b/android/src/main/java/com/mrousavy/camera/CameraView.kt index 28f265a672..f6dc2278f6 100644 --- a/android/src/main/java/com/mrousavy/camera/CameraView.kt +++ b/android/src/main/java/com/mrousavy/camera/CameraView.kt @@ -356,10 +356,9 @@ class CameraView(context: Context) : FrameLayout(context), LifecycleOwner { // User has selected a custom format={}. Use that val format = DeviceFormat(format!!) Log.i(TAG, "Using custom format - photo: ${format.photoSize}, video: ${format.videoSize} @ $fps FPS") - val aspectRatio = aspectRatio(format.photoSize.width, format.photoSize.height) previewBuilder.setTargetResolution(format.videoSize) - imageCaptureBuilder.setDefaultResolution(format.photoSize) - videoCaptureBuilder.setDefaultResolution(format.videoSize) + imageCaptureBuilder.setTargetResolution(format.photoSize) + videoCaptureBuilder.setTargetResolution(format.videoSize) fps?.let { fps -> if (format.frameRateRanges.any { it.contains(fps) }) {