How to set resolution for new video capture API?

508 views
Skip to first unread message
Assigned to trevor...@google.com by eri...@google.com

Tomáš Válek

unread,
Nov 22, 2021, 1:33:16 PM11/22/21
to Android CameraX Discussion Group
In CameraXVideo sample there is the code to set resolution by QualitySelector:

// create the user required QualitySelector (video resolution): we know this is
// supported, a valid qualitySelector will be created.
val qualitySelector = QualitySelector.of(
cameraCapabilities[cameraIndex].qualitySelector[qualitySelectorIndex])

// build a recorder, which can:
// - record video/audio to MediaStore(only shown here), File, ParcelFileDescriptor
// - be used create recording(s) (the recording performs recording)
val recorder = Recorder.Builder()
.setQualitySelector(qualitySelector)
.build()
videoCapture = VideoCapture.withOutput(recorder)

but how can I set resolution returned by Camera2 API:

cameraCharacteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)?.getOutputSizes(SurfaceTexture::class.java)

There are resolutions (e.g. with ratio: 1:1) that QualitySelector does not contain.

It could be set only via:
val videoCaptureBuilder = VideoCapture.Builder()
videoCaptureBuilder.setTargetRotation(...)
videoCaptureBuilder.setTargetResolution(...)
videoCaptureBuilder.setMaxResolution(...)

but this is different way then VideoCapture with recorder.

Trevor McGuire

unread,
Nov 22, 2021, 11:15:44 PM11/22/21
to Tomáš Válek, Android CameraX Discussion Group
Thank you for reporting the issue.

The supported resolutions returned by Camera2 do not take into account whether the device's video encoder can support that resolution and which encoder parameters (e.g., bitrate) are appropriate to use. So for now we only support the resolutions that map directly to one of the QualitySelector constants.

We are planning on adding proper support for other resolutions, including 1:1 aspect ratio, and without needing to query the Camera2 stream configuration map. This is a fairly important use case, so it will be a high priority to support soon.

--
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/1c93bd21-2e29-46c7-bde2-cc2cb062d796n%40android.com.
Reply all
Reply to author
Forward
0 new messages