Oleg Sokolov
Oleg Sokolov

Reputation: 1143

How to get max resolution of MediaCodec before configuring

My app create several instance of MediaCodec which work parallel as video/audio decoders and encoders.

I know that video codec has limiting buffer space and this limit depends on device.

For example on tab Samsung SM-P600 I can create four MediaCodecs with resolution 720p:

1280*720*4=3686400

but not five:

1280*720*5=4608000

Because codec will return error during configuring:

E/OMX:  setParam  sum(4608000) > max resolution(4177920)
E/ACodec: [OMX.Exynos.AVC.Encoder] failed to set input port definition parameters.
E/ACodec:  configureCodec multi window instance fail  appPid : 17054
E/ACodec: [OMX.Exynos.AVC.Encoder] configureCodec returning error -1021
E/ACodec: signalError(omxError 0x80001001, internalError -1021)
E/MediaCodec: Codec reported err 0xfffffc03, actionCode 0, while in state 3
E/MediaCodec: configure failed with err 0xfffffc03, resetting...

How can I get max resolution(4177920) before configuring MediaCodecs to count max available resolutions for all MediaCodecs I need?

Upvotes: 4

Views: 3537

Answers (1)

Tomer Nuni
Tomer Nuni

Reputation: 189

Try to use getMaxSupportedInstances () in MediaCodecInfo.CodecCapabilities. https://developer.android.com/reference/android/media/MediaCodecInfo.CodecCapabilities.html

Or isSizeSupported(int width, int height) in MediaCodecInfo.VideoCapabilities. https://developer.android.com/reference/android/media/MediaCodecInfo.VideoCapabilities.html

Upvotes: 2

Related Questions