Android MediaCodec:多个SurfaceViews支持多少个同时(视频)解码线程? [英] Android MediaCodec: How many simultaneous (video) decoding threads are supported on multiple SurfaceViews?

查看:734
本文介绍了Android MediaCodec:多个SurfaceViews支持多少个同时(视频)解码线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Grafika 项目中,文件DoubleDecodeActivity.java.我在3个SurfaceView上尝试使用MediaCodec API的3个同时视频(h264)解码器.将带有Android 5.1 CRASHES的第4个解码器添加到第4个SurfaceView到Nexus 7上时,那么将可能或支持多少个同时解码器.

PS.崩溃之后,MediaCodec不再起作用.需要重新启动设备才能使用MediaCodec.

下面是崩溃日志.第4个解码器线程的 decoder.start()函数崩溃.

  com.example.app.one V/DecodeActivity:Mime:video/avccom.example.app.one I/OMXClient:使用客户端OMX多路复用器.com.example.app.one V/DecodeActivity:Mime:video/avccom.example.app.one I/OMXClient:使用客户端OMX多路复用器.com.example.app.one V/DecodeActivity:Mime:video/avccom.example.app.one E/ACodec:[OMX.qcom.video.decoder.avc]带有错误-2147483648的storeMetaDataInBuffers失败com.example.app.one E/ACodec:[OMX.qcom.video.decoder.avc]带有错误-2147483648的storeMetaDataInBuffers失败com.example.app.one W/ACodec:不知道颜色格式0x7fa30c03 = 2141391875com.example.app.one W/ACodec:不知道颜色格式0x7fa30c03 = 2141391875com.example.app.one I/OMXClient:使用客户端OMX多路复用器.com.example.app.one V/DecodeActivity:Mime:video/avccom.example.app.one I/OMXClient:使用客户端OMX多路复用器.com.example.app.one E/ACodec:[OMX.qcom.video.decoder.avc]带有错误-2147483648的storeMetaDataInBuffers失败com.example.app.one E/ACodec:[OMX.qcom.video.decoder.avc]带有错误-2147483648的storeMetaDataInBuffers失败com.example.app.one W/ACodec:不知道颜色格式0x7fa30c03 = 2141391875com.example.app.one W/ACodec:不知道颜色格式0x7fa30c03 = 2141391875com.example.app.one E/ACodec:向OMX IL组件注册GraphicBuffer 9失败:-2147483648com.example.app.one V/PlayerFromFileThread:inputBuffer不可用.com.example.app.one E/ACodec:转换为IDLE状态后失败,无法分配缓冲区(错误0x80000000)com.example.app.one E/ACodec:signalError(omxError 0x80001001,internalError -2147483648)com.example.app.one V/PlayerFromFileThread:inputBuffer不可用.com.example.app.one E/MediaCodec:编解码器报告错误0x80001001,actionCode 0,而处于状态5?E/ACodec:向OMX IL组件注册GraphicBuffer 4失败:-2147483648?E/AndroidRuntime:致命例外:Thread-485流程:com.example.app.one,PID:17143android.media.MediaCodec $ CodecException:启动失败在android.media.MediaCodec.native_start(本机方法)在android.media.MediaCodec.start(MediaCodec.java:612)在com.example.app.one.MainActivity $ PlayerFromFileThread.run(MainActivity.java:1921)?E/ACodec:转换为IDLE状态后无法分配缓冲区(错误0x80000000)?E/ACodec:signalError(omxError 0x80001001,internalError -2147483648)?E/MediaCodec:编解码器在状态5时报告err 0x80001001,actionCode 0 

解决方案

定义有点不准确.

在API 23中,MediaCodecInfo getMaxSupportedInstances()

牢牢定义此值的麻烦在于,硬件实例的数量可能会受到带宽要求的限制,而不是固定的值.因此,您也许可以解码两个720p流,但只能解码一个1080p流.

在许多设备上,如果硬件无法支持您的请求,则OMX会切换到软件解码器,例如其中一种较旧的Nexus设备可以让您使用硬件编解码器解码两个流,然后开始分发软件编解码器实例.

getMaxSupportedInstances()调用是为了尝试提供其他信息,但是据我所知,仍然需要进行一定数量的每台设备反复试验才能确定设备的确切功能.

From Grafika project, file DoubleDecodeActivity.java. I tried 3 simultaneous video(h264) decoders using MediaCodec APIs on 3 SurfaceViews. 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.

PS. After this crash, MediaCodec doesn't work anymore. Need to restart the device to use MediaCodec.

Below is the crash log. Crashes at decoder.start() function for 4th decoder thread.

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."

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.

On many devices, if the hardware is unable to support your request, OMX will switch to a software decoder, e.g. one of the older Nexus devices would let you decode two streams with the hardware codec and then start handing out software codec instances.

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.

这篇关于Android MediaCodec:多个SurfaceViews支持多少个同时(视频)解码线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆