natario1 / CameraView

📸 A well documented, high-level Android interface that makes capturing pictures and videos easy, addressing all of the common issues and needs. Real-time filters, gestures, watermarks, frame processing, RAW, output of any size.
https://natario1.github.io/CameraView
Other
4.89k stars 922 forks source link

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

Open ThiruVenket opened 2 months ago

ThiruVenket commented 2 months ago

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