How to set resolution for Video Capture

41 views
Skip to first unread message

Dante Zhang

unread,
Apr 21, 2021, 6:35:07 AMApr 21
to Android CameraX Discussion Group
Hi there,

I am trying to set the resolution for the final video file through VideoCapture, the code is:

mVideoCapture = new VideoCapture.Builder()
.setTargetResolution(new Size(1920, 1080))
.build();

But the resolution I got is 1088 * 1088, and when I put break point at void setupEncoder(@NonNull String cameraId, @NonNull Size resolution), I found the suggest resolution is 1088 * 1088 (BTW, it is the same for the ImageCapture).

However, if I set the aspect ratio instead of setting target resolution like:

mVideoCapture = new VideoCapture.Builder()
.setTargetAspectRatio(AspectRatio.RATIO_16_9)
.build();

The resolution can be 1920 * 1080, so I wonder why the suggest resolution or the final resolution is not we set, and why VideoCapture not using target resolution to setup encoder?

Charcoal Chen

unread,
Apr 21, 2021, 10:54:13 PMApr 21
to Dante Zhang, Android CameraX Discussion Group
Hi Dante,

Please refer to the javadoc of ImageCapture.Builder#setTargetResolution() because VideoCapture is actually a hidden class.

=>  The resolution Size should be expressed in the coordinate frame after rotating the supported sizes by the target rotation. For example, a device with portrait natural orientation in natural target rotation requesting a portrait image may specify 480x640, and the same device, rotated 90 degrees and targeting landscape orientation may specify 640x480.

I guess the device is in portrait mode. Please try to specify the target resolution with Size(1080, 1920) and check the result. Then, the size of 1920x1080 should be selected.

--
You received this message because you are subscribed to the Google Groups "Android CameraX Discussion Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to camerax-develop...@android.com.
To view this discussion on the web visit https://groups.google.com/a/android.com/d/msgid/camerax-developers/09a1e0d9-8c4a-4429-9e84-8f3bcc39f3een%40android.com.

Dante Zhang

unread,
Apr 22, 2021, 8:39:49 PMApr 22
to Android CameraX Discussion Group, charco...@google.com
That works pretty well, thanks
Reply all
Reply to author
Forward
0 new messages