Search code examples
androidandroid-cameraandroid-mediarecorderandroid-camera2

Android CamcorderProfile and Camera2


When trying to determine supported video sizes for a device using the Camera2 API, is it OK to use CamcorderProfile.hasProfile, or is StreamConfigurationMap.getOutputSizes(MediaRecorder.class) the only way to do it?

I have a feeling that CamcorderProfile is not supported, because it takes an int for the camera ID, and Camera2 uses Strings for IDs, but I figured there's no harm in asking.


Solution

  • Camera2 IDs are Strings. http://developer.android.com/reference/android/hardware/camera2/CameraManager.html#getCameraIdList() mentions that:

    "Non-removable cameras use integers starting at 0 for their identifiers, while removable cameras have a unique identifier for each individual device, even if they are the same model"

    Therefore (if the OEMs are to be trusted), we can convert the camera ID to an int, and use that with CamcorderProfile