3

Is it possible to use two Android MediaCodec instances as video encoder to encode two videos simultaneously?

I know that MediaCodec itself can have multiple instances, for video/audio encoding/decoding. But is there any restriction on hardware/Android version on encoding multiple videos, besides the impact of performance?

More specifically, if considering only Android version 4.3 or higher, is multiple instances of video encoder valid or still be device-dependent?

Mark
  • 305
  • 5
  • 17

1 Answers1

2

From my experience it completely depends on a device. And there are devices that are able to support only one instance of video encoder in one time

Marlon
  • 1,473
  • 11
  • 13
  • 1
    It can also depend on resolution. For example, one of the more challenging things you can do in a video editor is a cross-fade at 1080p -- you have to decode two 1080p video streams and encode one 1080p stream simultaneously. Some devices don't have enough bandwidth to do all of that, though they're able to do two 1080p decodes and one 720p encode. – fadden Jul 07 '14 at 15:12
  • great comment, thanks. also since CTS tests do not have 1080p encoding tests and 1080p encoding is not yet required by Goolge a number of devices do not support 1080p encoding through MediaCodec correctly, so for now it is better not to use 1080p resolution for encoding or add extra picture quality checks to understand if device handles 1080p correctly – Marlon Jul 07 '14 at 15:25
  • Some devices may not even support 720p. You can check the level through the MediaCodec capability queries. For example, check for http://developer.android.com/reference/android/media/MediaCodecInfo.CodecProfileLevel.html#AVCLevel31 to test for 720p support. (The current CTS tests don't check for this; this may change in the future.) – fadden Jul 07 '14 at 17:07
  • Thank you two. I will be more careful to test the device capability in my APPs. – Mark Jul 09 '14 at 11:24
  • 1
    Some news: according to http://developer.android.com/preview/api-overview.html#video, the upcoming 'M' release will add a `MediaCodecInfo.CodecCapabilities.getMaxSupportedInstances()` API. Sounds promising. – fadden May 28 '15 at 23:04
  • @fadden I believe it would be even better to have a `getAvailableInstancesCount()` that can report the resources currently available to accommodate different use cases. – LightYearsBehind Sep 07 '15 at 04:02