我正在开发一款应用程序,通过将图形和文本应用于视频来对视频进行后期处理。我的代码基于Android CTS测试 DecodeEditEncodeTest ,并且在Nexus 4和Nexus 5(4.4)上表现良好,但是在我尝试的其他任何设备上都无法正常工作,甚至不包括Nexus 7 II on 4.4。例如,在Galaxy S3上,我会遇到以下错误:
相关代码如下:
它在其他设备上以不同的方式失败; 我尝试了Nexus 7 II,G3和HTC One(其中HTC One没有失败但创建了垃圾视频)。
根据此错误,似乎系统对执行上述代码的片段感到不满,该片段使用MediaPlayer和SurfaceView显示原始视频。
我想保持此视图可见,因此我尝试重置(reset())和销毁(destroy())MediaPlayer。实际上,在Nexus 7上这使应用程序正常工作,但在G3和HTC One上仍然无法正常工作。
我需要释放其他东西吗?还是我必须销毁片段并使用不同的片段进行后期处理?
E/ACodec(17651): configureCodec multi window instance fail appPid : 17651
E/ACodec(17651): [OMX.qcom.video.decoder.avc] configureCodec returning error -38
E/MediaCodec(17651): Codec reported an error. (omx error 0x80001001, internalError -38)
相关代码如下:
MediaCodecInfo codecInfo = selectCodec(MIME_TYPE);
if (codecInfo == null) {
// Don't fail CTS if they don't have an AVC codec (not here, anyway).
Log.e(TAG, "Unable to find an appropriate codec for " + MIME_TYPE);
return false;
}
if (VERBOSE) Log.d(TAG, "found codec: " + codecInfo.getName());
// We avoid the device-specific limitations on width and height by using values that
// are multiples of 16, which all tested devices seem to be able to handle.
MediaFormat format = MediaFormat.createVideoFormat(MIME_TYPE, mWidth, mHeight);
// Set some properties. Failing to specify some of these can cause the MediaCodec
// configure() call to throw an unhelpful exception.
format.setInteger(MediaFormat.KEY_COLOR_FORMAT,
MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface);
format.setInteger(MediaFormat.KEY_BIT_RATE, mBitRate);
format.setInteger(MediaFormat.KEY_FRAME_RATE, FRAME_RATE);
format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, IFRAME_INTERVAL);
if (VERBOSE) Log.d(TAG, "format: " + format);
output.setMediaFormat(format);
// Create a MediaCodec for the desired codec, then configure it as an encoder with
// our desired properties.
encoder = MediaCodec.createByCodecName(codecInfo.getName());
encoder.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
它在其他设备上以不同的方式失败; 我尝试了Nexus 7 II,G3和HTC One(其中HTC One没有失败但创建了垃圾视频)。
根据此错误,似乎系统对执行上述代码的片段感到不满,该片段使用MediaPlayer和SurfaceView显示原始视频。
我想保持此视图可见,因此我尝试重置(reset())和销毁(destroy())MediaPlayer。实际上,在Nexus 7上这使应用程序正常工作,但在G3和HTC One上仍然无法正常工作。
我需要释放其他东西吗?还是我必须销毁片段并使用不同的片段进行后期处理?