-1

I am developing the app for android media record, but some devices have different screen recording resolutions. And it always give me the crash.

I am using this code officially from google https://github.com/googlesamples/android-MediaRecorder/blob/master/Application/src/main/java/com/example/android/mediarecorder/MainActivity.java

it doesnt work also on Sony Xperia Z2 D6503

after I investigate this code

public static Camera.Size getOptimalVideoSize(List<Camera.Size> supportedVideoSizes,
                                                  List<Camera.Size> previewSizes, int w, int h)

doesn't work properly because it will result the size with 1280x720

and the log says

08-18 08:30:12.367 13251 13251 D MediaRecorder: Using Profile 0
08-18 08:30:12.367 13251 13251 D CameraTexture: vidsize = 720 : 1280

08-18 08:30:12.369   339  1370 W ServiceManager: Permission failure: com.sonyericsson.permission.CAMERA_EXTENDED from uid=19621 pid=13251
08-18 08:30:12.370   339  1370 W ServiceManager: Permission failure: com.sonyericsson.permission.CAMERA_EXTENDED from uid=19621 pid=13251
08-18 08:30:12.377  1478  1478 I art     : Explicit concurrent mark sweep GC freed 21(1200B) AllocSpace objects, 0(0B) LOS objects, 40% free, 12MB/21MB, paused 806us total 23.539ms
08-18 08:30:12.390 13251 13251 E MediaRecorder: Starting Record
08-18 08:30:12.391   339   974 W StagefrightRecorder: Intended video encoding frame width (1280) is too large and will be set to (800)
08-18 08:30:12.392   339   974 W StagefrightRecorder: Intended video encoding frame height (720) is too large and will be set to (480)
08-18 08:30:12.393   339   974 E CameraSource: Video dimension (800x480) is unsupported
08-18 08:30:12.394 13251 13251 E MediaRecorder: start failed: -19

I don't know how to properly create the mediarecorder that can be used on all android devices. Is there any reference for this?

Prabhakar
  • 1,138
  • 2
  • 14
  • 30
user965347
  • 186
  • 2
  • 16
  • What about *CamcorderProfile* ? – N0un Aug 18 '16 at 08:41
  • on https://github.com/googlesamples/android-MediaRecorder/blob/master/Application/src/main/java/com/example/android/mediarecorder/MainActivity.java indeed it have the CamcorderProfile but why still giving me errors? – user965347 Aug 19 '16 at 04:30
  • Sony Xperia Z2 D6503 is not android API 21 aka lollipop its still kitkat – user965347 Aug 19 '16 at 04:33

1 Answers1

0

If your only interest is in API 21+, you can use the getVideoCapabilities() method.

The CamcorderProfile class has been around since API 8, but isn't quite as useful.

If all else fails, use trial and error, testing each desired resolution and flagging the ones that don't work.

(it was here)

EDIT: With CamcorderProfile you should use QUALITY_HIGH in your case (I suppose reading your code sample)

Community
  • 1
  • 1
N0un
  • 868
  • 8
  • 31
  • on https://github.com/googlesamples/android-MediaRecorder/blob/master/Application/src/main/java/com/example/android/mediarecorder/MainActivity.java line 155 indeed have CamcorderProfile but still giving me error,, is it error should happen for android for only obtain the supported resolution? – user965347 Aug 19 '16 at 04:29
  • Sony Xperia Z2 D6503 is not android API 21 aka lollipop its still kitkat – user965347 Aug 19 '16 at 04:33
  • Ok and what are values in `profile.videoFrameWidth/Height` after calling `CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);` ? – N0un Aug 19 '16 at 07:16