简体   繁体   English

Android MediaCodec:多个 SurfaceView 上支持多少个同时(视频)解码线程?

[英]Android MediaCodec: How many simultaneous (video) decoding threads are supported on multiple SurfaceViews?

From Grafika project, file DoubleDecodeActivity.java.Grafika项目,文件 DoubleDecodeActivity.java。 I tried 3 simultaneous video(h264) decoders using MediaCodec APIs on 3 SurfaceViews.我在 3 个 SurfaceViews 上使用 MediaCodec API 尝试了 3 个同步视频(h264)解码器。 On adding 4th decoder to 4th SurfaceView to Nexus 7 with Android 5.1 CRASHES, So how many simultaneous decoders would be possible or supported.将第 4 个解码器添加到第 4 个 SurfaceView 到带有 Android 5.1 崩溃的 Nexus 7,那么可能或支持多少个同时解码器。

PS.附注。 After this crash, MediaCodec doesn't work anymore.这次崩溃后,MediaCodec 不再工作。 Need to restart the device to use MediaCodec.需要重启设备才能使用 MediaCodec。

Below is the crash log.下面是崩溃日志。 Crashes at decoder.start() function for 4th decoder thread.在第四个解码器线程的decoder.start()函数中崩溃。

com.example.app.one V/DecodeActivity: Mime: video/avc
com.example.app.one I/OMXClient: Using client-side OMX mux.
com.example.app.one V/DecodeActivity: Mime: video/avc
com.example.app.one I/OMXClient: Using client-side OMX mux.
com.example.app.one V/DecodeActivity: Mime: video/avc
com.example.app.one E/ACodec: [OMX.qcom.video.decoder.avc] storeMetaDataInBuffers failed w/ err -2147483648
com.example.app.one E/ACodec: [OMX.qcom.video.decoder.avc] storeMetaDataInBuffers failed w/ err -2147483648
com.example.app.one W/ACodec: do not know color format 0x7fa30c03 = 2141391875
com.example.app.one W/ACodec: do not know color format 0x7fa30c03 = 2141391875
com.example.app.one I/OMXClient: Using client-side OMX mux.
com.example.app.one V/DecodeActivity: Mime: video/avc
com.example.app.one I/OMXClient: Using client-side OMX mux.
com.example.app.one E/ACodec: [OMX.qcom.video.decoder.avc] storeMetaDataInBuffers failed w/ err -2147483648
com.example.app.one E/ACodec: [OMX.qcom.video.decoder.avc] storeMetaDataInBuffers failed w/ err -2147483648
com.example.app.one W/ACodec: do not know color format 0x7fa30c03 = 2141391875
com.example.app.one W/ACodec: do not know color format 0x7fa30c03 = 2141391875
com.example.app.one E/ACodec: registering GraphicBuffer 9 with OMX IL component failed: -2147483648
com.example.app.one V/PlayerFromFileThread: inputBuffer not available.
com.example.app.one E/ACodec: Failed to allocate buffers after transitioning to IDLE state (error 0x80000000)
com.example.app.one E/ACodec: signalError(omxError 0x80001001, internalError -2147483648)
com.example.app.one V/PlayerFromFileThread: inputBuffer not available.
com.example.app.one E/MediaCodec: Codec reported err 0x80001001, actionCode 0, while in state 5
? E/ACodec: registering GraphicBuffer 4 with OMX IL component failed: -2147483648
? E/AndroidRuntime: FATAL EXCEPTION: Thread-485
                                                   Process: com.example.app.one, PID: 17143
                                                   android.media.MediaCodec$CodecException: start failed
                                                       at android.media.MediaCodec.native_start(Native Method)
                                                       at android.media.MediaCodec.start(MediaCodec.java:612)
                                                       at com.example.app.one.MainActivity$PlayerFromFileThread.run(MainActivity.java:1921)
? E/ACodec: Failed to allocate buffers after transitioning to IDLE state (error 0x80000000)
? E/ACodec: signalError(omxError 0x80001001, internalError -2147483648)
? E/MediaCodec: Codec reported err 0x80001001, actionCode 0, while in state 5

This is somewhat poorly defined.这有点不好定义。

In API 23 the MediaCodecInfo getMaxSupportedInstances() method was added, which boldly claims, "This is a hint for an upper bound."在 API 23 中添加了 MediaCodecInfo getMaxSupportedInstances()方法,该方法大胆地声称,“这是对上限的提示。”

The trouble with defining this value firmly is that the number of hardware instances may be limited by bandwidth requirements, rather than a fixed value.严格定义此值的麻烦在于硬件实例的数量可能受带宽要求的限制,而不是固定值。 So you might be able to decode two 720p streams but only one 1080p stream.因此,您可能能够解码两个 720p 流,但只能解码一个 1080p 流。

On many devices, if the hardware is unable to support your request, OMX will switch to a software decoder, eg one of the older Nexus devices would let you decode two streams with the hardware codec and then start handing out software codec instances.在许多设备上,如果硬件无法支持您的请求,OMX 将切换到软件解码器,例如,较旧的 Nexus 设备之一将让您使用硬件编解码器解码两个流,然后开始分发软件编解码器实例。

The getMaxSupportedInstances() call was an attempt to provide additional information, but as far as I can tell there's still some amount of per-device trial and error required to determine what exactly a device can do. getMaxSupportedInstances()调用试图提供额外的信息,但据我所知,仍然需要对每个设备进行一定数量的试验和错误来确定设备究竟可以做什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM