I'm trying to record the contents of the screen using mediarecorder and mediaprojection api. When I'm trying to change the video to HD on my device the recording fails but it works fine with 640 x 480 resolution. So my question is how could I get the supported video resolutions on a particular device? Cheers Jon
Asked
Active
Viewed 1,670 times
0
-
Jake Wharton's been using `CamcorderProfile` in his Telecine app: https://github.com/JakeWharton/Telecine/blob/master/telecine/src/main/java/com/jakewharton/telecine/RecordingSession.java – CommonsWare Oct 18 '15 at 21:07
-
@CommonsWare `CamcorderProfile.QUALITY_HIGH` doesn't return the highest supported resolution, my device supports 2k and 4k video recording, but it returns Full HD resolution – user924 Aug 19 '20 at 10:48
1 Answers
2
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.

fadden
- 51,356
- 5
- 116
- 166
-
I could do that but I want to support as wide range of android devices as I can if I'll hard-code the resolutions it won't work on all devices – John Smith Oct 20 '15 at 17:33
-
1I'm not sure what part of my answer sounds like hard-coding resolutions. – fadden Oct 20 '15 at 18:06
-
Okay I've used the getVideoCapabilities method but I have problems with making the recording with default screen resolution, even though the getVideoCapabilities tells me that the framerate, width and height is supported the app crashes. – John Smith Oct 23 '15 at 22:03
-
@fadden Updated my question with some info about devices, it seems `MediaCodecInfo` makes sense but still 4K fails on some devices for video recording with `MediaRecorder` https://stackoverflow.com/questions/76846234/mediarecorder-java-io-ioexception-prepare-failed-for-4k-resolutions-on-some – user924 Aug 19 '23 at 21:03