MediaCodec signalEndOfInputStream()错误 [英] MediaCodec signalEndOfInputStream() error

查看:974
本文介绍了MediaCodec signalEndOfInputStream()错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用示例代码Grafika中的Live Camera Recording(With Opengl).在Moto G上一切正常,但我在其他设备(带有Cyanogendmod 11的Galaxy Tab 2)上尝试运行,似乎该方法:signalEndofInputStream()无法正常工作,并且编码器永不停止. 有没有其他方法可以将信号发送到MediaCodec?

I'm trying to use the Live Camera Recording ( With Opengl ) from the Sample Code Grafika. Every things works fine on my Moto G but i try in my other device (Galaxy Tab 2 with Cyanogendmod 11) it's seems the method : signalEndofInputStream() is not working and the Encoder never stop. It's there a way to send the signal to the MediaCodec in an other way ?

对不起,英语不好.

推荐答案

您可以解决它.

如果您查看 DecodeEditEncodeTest ,您会看到一个名为WORK_AROUND_BUGS的神秘布尔值.它的用法是这样的:

If you look at DecodeEditEncodeTest, you can see a mysterious boolean called WORK_AROUND_BUGS. It's used like this:

if (WORK_AROUND_BUGS) {
    // Might drop a frame, but at least we won't crash mediaserver.
    try { Thread.sleep(500); } catch (InterruptedException ie) {}
    outputDone = true;
} else {
    encoder.signalEndOfInputStream();
}

在CTS测试的开发过程中使用了此方法,当时特定于供应商的代码在流末信号方面还不能很好地工作.添加了它,以便我们在供应商开发补丁程序时可以行使其他功能.在4.3中进行测试之前,该标志已被禁用.您可能会在Cyanogen上遇到未打补丁的编解码器.

This was used during the development of the CTS tests, when the vendor-specific code wasn't yet working well with the end-of-stream signal. It was added so we could exercise other features while the vendors worked on patches. The flag was disabled before the tests shipped in 4.3. You're probably running into unpatched codecs on Cyanogen.

解决方法是根本不发送流结束信号.而是,您只需停止编解码器.机上缓冲区有可能会丢失,您会丢掉一帧,但是对于实时录制而言,这可能并不重要. (对于视频编辑来说,这更是一个问题.)

The workaround is to simply never send the end-of-stream signal. Instead, you just stop the codec. There is some chance that an in-flight buffer will be lost and you will drop a frame, but for a live recording this may not matter. (It's more of an issue for video editing.)

这篇关于MediaCodec signalEndOfInputStream()错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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