Android getSupportedVideoSizes allways returns null

I need help with the MediaRecorder class on Android.

I am trying to use getSupportedVideoSizes to get a list of supported video sizes, but it always returns null.

During testing, the following devices return null when getSupportedVideoSizes requested:

  • Galaxy Nexus (Android 4.2)
  • HTC One Mini (Android 4.4.2)
  • HTCEVOV4G (Android 4.0.3)
+6
source share
2 answers

Documentation for Camera.getSupportedVideoSizes() that reads,

Returns
a list of the size object if the camera has a separate view and video output; otherwise null is returned.

not quite clear. However, this means that if Camera.getSupportedVideoSizes() returns null, then the preview sizes supported by the camera and video sizes are the same; in this case, use Camera.getSupportedPreviewSizes() to get a list of supported video sizes.

Code example:

 public List<Size> getSupportedVideoSizes(Camera camera) { if (camera.getParameters().getSupportedVideoSizes() != null) { return camera.getParameters().getSupportedVideoSizes(); } else { // Video sizes may be null, which indicates that all the supported // preview sizes are supported for video recording. return camera.getParameters().getSupportedPreviewSizes(); } } 
+33
source

Or just use

 mediarecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH)); 

to set the best resolution automatically.

0
source

All Articles