gpt4 book ai didi

android - 当使用 COLOR_FormatYUV420Planar 兼容编解码器时,dequeueOutputBuffer 引发 IllegalStateException

转载 作者:太空宇宙 更新时间:2023-11-03 11:11:45 25 4
gpt4 key购买 nike

我正在使用 Android 4.4.2 的 LG G2 上运行这个简单的 MediaCodec 测试:

public class MyActivity extends Activity {
private static final String MIME_TYPE = "video/avc";

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

MediaFormat format = MediaFormat.createVideoFormat(MIME_TYPE, 1280, 720);

int numCodecs = MediaCodecList.getCodecCount();
for (int i = 0; i < numCodecs; i++) {
MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);

if (codecInfo.isEncoder()) {
String[] types = codecInfo.getSupportedTypes();

for (int j = 0; j < types.length; j++) {
if (types[j].equalsIgnoreCase(MIME_TYPE)) {
MediaCodecInfo.CodecCapabilities capabilities = codecInfo.getCapabilitiesForType(MIME_TYPE);

for(int colorFormat : capabilities.colorFormats) {
if (colorFormat == MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Planar) {

format.setInteger(MediaFormat.KEY_COLOR_FORMAT, MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Planar);
format.setInteger(MediaFormat.KEY_BIT_RATE, 1000000);
format.setInteger(MediaFormat.KEY_FRAME_RATE, 15);
format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, 10);

MediaCodec mMediaCodec = MediaCodec.createByCodecName(codecInfo.getName());

mMediaCodec.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
mMediaCodec.start();

MediaCodec.BufferInfo mBufferInfo = new MediaCodec.BufferInfo();
mMediaCodec.dequeueOutputBuffer(mBufferInfo, 1000);

return;
}
}
}
}
}
}


}
}

它引发了以下错误:

04-21 18:08:29.531    6513-6513/com.example.mediacodec I/OMXClient﹕ Using client-side OMX mux.
04-21 18:08:29.531 6513-6513/com.example.mediacodec E/OMXMaster﹕ A component of name 'OMX.qcom.audio.decoder.aac' already exists, ignoring this one.
04-21 18:08:29.531 6513-6513/com.example.mediacodec I/﹕ @@@VOLOG Info THD 4001A154: VOOMXPlugin.cpp VOOMXPlugin 59 open libvoOMXOne.so successfully. 0X5BB9A5B8
04-21 18:08:29.541 6513-6513/com.example.mediacodec E/﹕ VOLOG Info THD 4001A154 voCOMXBaseConfig.cpp Open 368 The config file vomeOne.cfg could not be opened!
04-21 18:08:29.541 6513-6513/com.example.mediacodec I/SoftAVCEncoder﹕ Construct SoftAVCEncoder
04-21 18:08:29.541 6513-6536/com.example.mediacodec I/OMXClient﹕ Using client-side OMX mux.
04-21 18:08:29.541 6513-6536/com.example.mediacodec E/OMXMaster﹕ A component of name 'OMX.qcom.audio.decoder.aac' already exists, ignoring this one.
04-21 18:08:29.541 6513-6536/com.example.mediacodec I/﹕ @@@VOLOG Info THD 60471CD0: VOOMXPlugin.cpp VOOMXPlugin 59 open libvoOMXOne.so successfully. 0X5BB9A370
04-21 18:08:29.541 6513-6536/com.example.mediacodec E/﹕ VOLOG Info THD 60471CD0 voCOMXBaseConfig.cpp Open 368 The config file vomeOne.cfg could not be opened!
04-21 18:08:29.541 6513-6536/com.example.mediacodec I/SoftAVCEncoder﹕ Construct SoftAVCEncoder
04-21 18:08:29.541 6513-6536/com.example.mediacodec E/SoftAVCEncoder﹕ internalSetParameter: StoreMetadataInBuffersParams.nPortIndex not zero!
04-21 18:08:29.541 6513-6536/com.example.mediacodec E/OMXNodeInstance﹕ OMX_SetParameter() failed for StoreMetaDataInBuffers: 0x80001001
04-21 18:08:29.541 6513-6536/com.example.mediacodec E/ACodec﹕ [OMX.google.h264.encoder] storeMetaDataInBuffers (output) failed w/ err -2147483648
04-21 18:08:29.541 6513-6536/com.example.mediacodec I/ACodec﹕ setupVideoEncoder succeeded
04-21 18:08:29.541 6513-6537/com.example.mediacodec E/SoftAVCEncoder﹕ Failed to initialize the encoder: -8
04-21 18:08:29.551 6513-6536/com.example.mediacodec E/ACodec﹕ [OMX.google.h264.encoder] ERROR(0x80001001)
04-21 18:08:29.551 6513-6535/com.example.mediacodec E/MediaCodec﹕ Codec reported an error. (omx error 0x80001001, internalError -2147483648)
04-21 18:08:29.551 6513-6513/com.example.mediacodec D/AndroidRuntime﹕ Shutting down VM
04-21 18:08:29.551 6513-6513/com.example.mediacodec W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x417a8e48)
04-21 18:08:29.551 6513-6513/com.example.mediacodec E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.mediacodec, PID: 6513
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mediacodec/com.example.mediacodec.MyActivity}: java.lang.IllegalStateException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2200)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250)
at android.app.ActivityThread.access$800(ActivityThread.java:139)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1200)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5105)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.IllegalStateException
at android.media.MediaCodec.dequeueOutputBuffer(Native Method)
at com.example.mediacodec.MyActivity.onCreate(MyActivity.java:49)
at android.app.Activity.performCreate(Activity.java:5275)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2164)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2250)
            at android.app.ActivityThread.access$800(ActivityThread.java:139)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1200)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:136)
            at android.app.ActivityThread.main(ActivityThread.java:5105)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:515)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:792)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
            at dalvik.system.NativeStart.main(Native Method)

同样的错误可以在 Sony Xperia ZR 上重现。这两种设备还支持 COLOR_FormatYUV420SemiPlanar,并且它在相同参数下运行良好。我尝试从 android.media.cts 包运行 EncodeDecodeTest 并成功通过,但看起来它只测试了第一个支持的第一个支持的颜色格式在本例中为 COLOR_FormatYUV420SemiPlanar 的编解码器。

最佳答案

在你的日志中,

04-21 18:08:29.541    6513-6536/com.example.mediacodec E/SoftAVCEncoder﹕ internalSetParameter: StoreMetadataInBuffersParams.nPortIndex not zero!
04-21 18:08:29.541 6513-6536/com.example.mediacodec E/OMXNodeInstance﹕ OMX_SetParameter() failed for StoreMetaDataInBuffers: 0x80001001
04-21 18:08:29.541 6513-6536/com.example.mediacodec E/ACodec﹕ [OMX.google.h264.encoder] storeMetaDataInBuffers (output) failed w/ err -2147483648
04-21 18:08:29.541 6513-6536/com.example.mediacodec I/ACodec﹕ setupVideoEncoder succeeded
04-21 18:08:29.541 6513-6537/com.example.mediacodec E/SoftAVCEncoder﹕ Failed to initialize the encoder: -8

AVC 停止 nPortIndex 不为零。请参阅以下链接作为引用。 http://androidxref.com/4.4.2_r2/xref/frameworks/av/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp#684

686            StoreMetaDataInBuffersParams *storeParams =
687 (StoreMetaDataInBuffersParams*)params;
688 if (storeParams->nPortIndex != 0) {
689 ALOGE("%s: StoreMetadataInBuffersParams.nPortIndex not zero!",
690 __FUNCTION__);
691 return OMX_ErrorUndefined;
692 }

这将在 SoftAVCEncoder.cpp 上出错,

150  /** There was an error, but the cause of the error could not be determined */
151 OMX_ErrorUndefined = (OMX_S32) 0x80001001,

http://androidxref.com/4.4.2_r2/xref/frameworks/native/include/media/openmax/OMX_Core.h#151

如何检查您的配置或寻找解决此错误的方法?

关于android - 当使用 COLOR_FormatYUV420Planar 兼容编解码器时,dequeueOutputBuffer 引发 IllegalStateException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23199351/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com