How to set resolution for Video Capture

Skip to first unread message

Dante Zhang

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))

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()

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

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
To view this discussion on the web visit

Dante Zhang

Apr 22, 2021, 8:39:49 PMApr 22
to Android CameraX Discussion Group,
That works pretty well, thanks
Reply all
Reply to author
0 new messages