我正在编写一个解码视频样本并播放解码样本的应用。为此我使用MediaExtractor API。配置解码器时我收到错误。这是我的日志
01-08 11:46:50.225: E/ACodec(23085): [OMX.qcom.video.decoder.avc] configureCodec returning error -2147483648
01-08 11:46:50.225: A/MediaCodec(23085): frameworks/av/media/libstagefright/MediaCodec.cpp:743 CHECK_EQ( mState,INITIALIZED) failed: 3 vs. 2
01-08 11:46:50.225: A/libc(23085): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 23136 (MediaCodec_loop)
01-08 11:46:50.225: I/OMXClient(23085): Using client-side OMX mux.
01-08 11:46:50.225: E/ACodec(23085): Unable to instantiate a decoder for type 'video/avc'.
01-08 11:46:50.225: A/ACodec(23085): frameworks/av/media/libstagefright/ACodec.cpp:3302 CHECK(mCodec->mNode != NULL) failed.
01-08 11:46:50.225: A/libc(23085): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1), thread 23137 (CodecLooper)
这是我的代码
for (int i = 0; i < videoExtractor.getTrackCount(); i++) {
MediaFormat format = videoExtractor.getTrackFormat(i);
String mime = format.getString(MediaFormat.KEY_MIME);
if (mime.startsWith("video/")) {
videoExtractor.selectTrack(i);
videoExtractorForSeek.selectTrack(i);
videoDecoder = MediaCodec.createDecoderByType(mime);
//error is in below line
videoDecoder.configure(format, surface, null, 0);
break;
}
}
此代码适用于Android 4.2及更高版本。并在4.1.2中失败