Android的媒体codeC configureFailed [英] Android mediacodec configureFailed

查看:519
本文介绍了Android的媒体codeC configureFailed的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这我曾尝试以下code初始化媒体codeC,但它失败了! GitHub的托管项目运行没有任何问题。更新日志如下

  2月1日至27日:02:25.125:I / OMXClient(8956):使用客户端OMX MUX。
2月1日至27日:02:25.140:I / A codeC(8956):setupVideoEn codeR成功
2月1日至27日:02:25.140:E / OMXNodeInstance(1910年):OMX_GetExtensionIndex失败
2月1日至27日:02:25.140:A / A codeC(8956):框架/ AV /媒体/ libstagefright / A codec.cpp:3234 CHECK_EQ((status_t)OK,M codeC- > initNativeWindow())失败:0与-2147483648
2月1日至27日:02:25.140:A / libc的(8956):在0xdeadbaad致命信号11(SIGSEGV)(code = 1),螺纹8990(codecLooper)

的code - 法登的答案后更新

 格式= MediaFormat.createVideoFormat(视频/ AVC,480,800);
format.setInteger(MediaFormat.KEY_BIT_RATE,400000);
format.setInteger(MediaFormat.KEY_FRAME_RATE,25);
format.setInteger(MediaFormat.KEY_COLOR_FORMAT,媒体codecInfo codecCapabilities.COLOR_FormatYUV420Planar);
format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL,5);codeR =媒体codec.createEn coderByType(视频/ AVC);
// codeR =媒体codec.createDe coderByType(视频/ AVC);
如果(格式!= NULL)
    coder.configure(格式,mSurface,空,媒体codec.CONFIGURE_FLAG_EN code);
Log.e(后,配置);


解决方案

看起来你不配置所有的强制性键

查看 MediaFormat 文档,并注意它说:所有没有标明可选的键是强制性的。

更新:

它崩溃的失败断言。由行号和断言消息来看,你正在运行JB-MR1(Android 4.2版,API 17);源文件<一个href=\"https://android.googlesource.com/platform/frameworks/av/+/jb-mr1-release/media/libstagefright/A$c$cc.cpp\"相对=nofollow>是这里。

它抱怨本地窗口,这是说它不喜欢你传递在表面。既然你配置一间codeR的另一种方式,你不应该传递表面在所有 - 这是仅适用于渲染输出。更改 mSurface

如果您想要通过表面来提供输入,你需要使用媒体codeC#createInputSurface(),这是不是可用,直到API 18.

Following this i have tried below code to initialize MediaCodec, but it failed! The github hosted project runs without any problem. The updated log is as below

01-27 02:02:25.125: I/OMXClient(8956): Using client-side OMX mux.
01-27 02:02:25.140: I/ACodec(8956): setupVideoEncoder succeeded
01-27 02:02:25.140: E/OMXNodeInstance(1910): OMX_GetExtensionIndex failed
01-27 02:02:25.140: A/ACodec(8956): frameworks/av/media/libstagefright/ACodec.cpp:3234 CHECK_EQ( (status_t)OK,mCodec->initNativeWindow()) failed: 0 vs. -2147483648
01-27 02:02:25.140: A/libc(8956): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 8990 (CodecLooper)

The code - Updated after fadden's answer

format = MediaFormat.createVideoFormat("video/avc", 480, 800);
format.setInteger(MediaFormat.KEY_BIT_RATE,400000 );
format.setInteger(MediaFormat.KEY_FRAME_RATE, 25);
format.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Planar);
format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 5);

coder = MediaCodec.createEncoderByType("video/avc");
//  coder = MediaCodec.createDecoderByType("video/avc");
if(format != null)
    coder.configure(format, mSurface, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
Log.e("After","Configure");

解决方案

Looks like you're not configuring all of the mandatory keys.

See the MediaFormat doc, and note where it says "all keys not marked optional are mandatory".

Update:

It's crashing on a failed assertion. Judging by the line number and the assert message, you're running jb-mr1 (Android 4.2, API 17); source file is here.

It's complaining about the "native window", which is another way of saying it doesn't like the surface you're passing in. Since you're configuring an encoder, you shouldn't be passing in a surface at all -- that's only for rendered output. Change mSurface to null.

If you want to provide input through a Surface, you need to use MediaCodec#createInputSurface(), which isn't available until API 18.

这篇关于Android的媒体codeC configureFailed的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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