Search code examples
androidandroid-camera2

Android Camera2 API quality issue


I am currently putting together an app that records some video. The target hardware supports 1080p@30fps. When I record video from the native Camera app, I get some nice 1080p video @ 30fps.

However, in my app, I load the QUALITY_HIGH profile...

CamcorderProfile profile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);

profile.videoFrameWidth = 1920

profile.videoFrameHeight = 1080

mMediaRecorder.setVideoSize(profile.videoFrameWidth, profile.videoFrameHeight);.

I then get this error...

Surface with size (w=1920, h=1080) and format 0x1 is not valid, size not in valid set: [1280x960, 1280x720, 960x720, 960x540, 864x480, 720x480, 768x432, 640x480, 320x240, 176x144]

Does anyone know why the Camera2 API appears to lock me out of using the phones full potential?


Solution

  • Most likely, the cameras reported via the camera2 API are at the LEGACY level; this means they run via a compatibility layer on top of an older revision of the Android camera HAL (hardware abstraction layer).

    Due to the differences between the old HAL and camera2, certain use cases may have reduced capabilities in this compatibility mode.

    Since camera2 requires the same set of resolutions for all use cases of a given format, it does not expose a size if it can only be used for video recording. This can happen with the legacy HAL, unfortunately.

    On such devices, you may have to use the deprecated camera API to access the maximum resolution available.