1

I am using the Android 4.4 screenrecord command to record the screen of some different devices, but if I use the --size parameter then the capture video is corrupted.

How can I get the list of valid screenrecord sizes for a given device's encoder?

Daniel Smith
  • 8,561
  • 3
  • 35
  • 58
jacob
  • 1,397
  • 1
  • 26
  • 53

1 Answers1

0

There is no such list. At least, not one that includes all valid resolutions.

Any size that is listed in the AVC profile list will work if the encoder supports that profile level, and you can get that by querying MediaCodec. From code written in the Java programming language, you just need to get a MediaCodecInfo for AVC, then use getCapabilitiesForType() to get a CodecCapabilities object, from which you can get an array of CodecProfileLevel. The CodecProfileLevel class includes the AVC profile level constants. (I'm not sure offhand what the private native equivalents of this is.)

Many resolutions that are not explicitly supported will happen to work. The probability of an arbitrary MxN resolution working is much higher if both M and N are multiples of 16 (with an additional allowance for 1080). However, some devices are more limited (see e.g. this post).

Community
  • 1
  • 1
fadden
  • 51,356
  • 5
  • 116
  • 166
  • I managed to get the supported profile/levels , but how can I calculate from that, what are the supported sizes ? – jacob Apr 02 '14 at 10:10
  • Make a table from the AVC standard (or at least the AVC wikipedia page linked earlier). You can see an example of it being used to determine width/height/fps for test cases in one of the CTS tests: https://android.googlesource.com/platform/cts/+/kitkat-release/tests/tests/media/src/android/media/cts/EncodeVirtualDisplayWithCompositionTest.java (find `getAvcSupportedFormatInfo()`). Some of the other tests should have a similar check, e.g. low-end devices might not support 720p encoding but a couple of the existing tests require it. – fadden Apr 02 '14 at 14:47