Is there a way to extract the maximum video resolution Android can play? We have MP4 files we download from the camera and I would like to show some error to the user before pla
Okay,
on Android Lollipop
you can use this,
MediaCodecInfo.VideoCapabilities.areSizeAndRateSupported(int width, int height, double frameRate)
which returns whether a given video size (width and height)
and frameRate
combination is supported.
On Android < Lollipop
you can just check which AVC codec levels are supported, so you could derive the maximum supported resolution, which unfortunately is not correct for most of the devices. For example, on the Nexus 5, Android will return AVC profile level 4 which would mean that you can playback 1920x1080 videos. However, the Nexus 5 is capable of playing higher resolution videos already, so it is not reliable.
Only workaround on Android < 5 so far: Try to play the video and check for any errors. That's what HTC or other devices do as well. As a result it can happen that on some devices you will get about 1 frame each 2 seconds or so.