Search code examples
androidandroid-mediacodec

Is there a way to retrieve the limits of a MediaCodec instance?


Let's use one example to explain this. Suppose a MediaCodec instance is created as following:

MediaCodec.createDecoderByType("video/avc");

It is configured with an instance of MediaFormat. We know the decoder has the following limits by checking media_codecs.xml:

<MediaCodec name="OMX.rk.video_decoder.avc" type="video/avc">
    <Limit name="size" max="4096x2160" min="176x144"/>
    <Limit name="alignment" value="8x8"/>
    <Limit name="block-size" value="16x16"/>
    <Limit name="blocks-per-second" max="244800" min="1"/>
    <Limit name="bitrate" range="1-10000000"/>
    <Feature name="adaptive-playback"/>
</MediaCodec>

Is there a way to find the resolution limits (176x244 - 4096x2160) programatically?


Solution

  • How about VideoCapabilities gotten from MediaCodec.getCodecInfo()?

    https://developer.android.com/reference/android/media/MediaCodecInfo.VideoCapabilities.html