[英]MediaCodec encoder using Surface crashes inconsistently on various devices
我正在開發一個通過將圖形和文本應用於視頻來發布處理視頻的應用程序。 我的代碼基於Android CTS測試DecodeEditEncodeTest,並且在Nexus 4和Nexus 5(4.4)上運行良好,但在我嘗試過的任何其他設備上都無法運行; 甚至連4.4上的Nexus 7 II也沒有。 例如,在Galaxy S3上,出現以下錯誤:
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(它們並沒有失敗,但是創建了一個垃圾視頻)。
基於此錯誤,對於上述代碼是從使用MediaPlayer和SurfaceView顯示原始視頻的Fragment執行上述代碼的事實,系統似乎並不滿意。
我想保持此視圖可見,因此我嘗試對MediaPlayer進行reset()和destroy()調試,實際上這使該應用程序在Nexus 7上正常工作,但在G3或HTC One上仍然無法正常工作。
還有什么我需要發布的嗎? 還是我被迫銷毀片段,並使用其他片段進行后期處理?
答案是輸入和輸出視頻都不要超過720p
有時,唯一的方法是重啟設備,編碼器繼續正常工作。 連結5 .. android 4.2.2。
在連續啟動和停止視頻解碼時,在壓力測試期間,我也面臨着完全相同的錯誤日志。
我的問題是我錯過了發布視頻解碼器實例的機會。 之后,我沒有收到這個問題。
超過720p時我沒有遇到這個問題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.