natario1/CameraView

while setting the setVideoSize for the recording getting error with the size

Opened this issue · 0 comments

SizeSelector width = SizeSelectors.minWidth(Utility.WIDTH);
SizeSelector height = SizeSelectors.minHeight(Utility.HEIGHT);
SizeSelector dimensions = SizeSelectors.and(width, height); // Matches sizes bigger than width X height
SizeSelector ratio = SizeSelectors.aspectRatio(AspectRatio.of(1, 2), 0); // Matches 1:2 sizes.
SizeSelector ratio3 = SizeSelectors.aspectRatio(AspectRatio.of(2, 3), 0); // Matches 2:3 sizes.
SizeSelector ratio2 = SizeSelectors.aspectRatio(AspectRatio.of(9, 16), 0); // Matches 9:16 sizes.
SizeSelector result = SizeSelectors.or(
SizeSelectors.and(ratio, dimensions),
SizeSelectors.and(ratio2, dimensions),
SizeSelectors.and(ratio3, dimensions)
);

camera.setVideoSize(result);

while i try to set the video size based on the screen aspect ratio getting error like below

Session 1: Failed to create capture session; configuration failed
2024-04-18 10:36:45.265 13580-15968 CameraEngine E onConfigureFailed! Session android.hardware.camera2.impl.CameraCaptureSessionImpl@169617
2024-04-18 10:36:45.265 13580-15968 CameraEngine E onConfigureFailed! onConfigureFailed! Session android.hardware.camera2.impl.CameraCaptureSessionImpl@169617

for this i have changed as below

camera.setVideoSize(SizeSelectors.and(SizeSelectors.maxWidth(MAX_WIDTH), SizeSelectors.smallest()));

after that am able to record the video with out issue but the resolution of the video is too low

camera.setVideoSize(SizeSelectors.and(SizeSelectors.maxWidth(MAX_WIDTH), SizeSelectors.biggest()));

when trying this same above error is came

how to solve the resolution issue based on the device spec.

Please suggest