我在停止 MediaMuxer 时遇到问题。
除了我使用音频之外,几乎一直遵循fadden 的示例,所以我还不能 100% 确定音频和视频轨道排成一行。这可能是问题所在。
当我命中 mMediaMuxer.stop() 的断点时,我收到一个致命错误:
09-30 17:11:21.677: E/AndroidRuntime(32304): FATAL EXCEPTION: CaptureManager
09-30 17:11:21.677: E/AndroidRuntime(32304): java.lang.IllegalStateException: Failed to stop the muxer
09-30 17:11:21.677: E/AndroidRuntime(32304): at android.media.MediaMuxer.nativeStop(Native Method)
09-30 17:11:21.677: E/AndroidRuntime(32304): at android.media.MediaMuxer.stop(MediaMuxer.java:190)
09-30 17:11:21.677: E/AndroidRuntime(32304): at com.harmonicprocesses.penelopefree.camera.MyMediaMux.stop(MyMediaMux.java:97)
09-30 17:11:21.677: E/AndroidRuntime(32304): at com.harmonicprocesses.penelopefree.camera.CaptureManager.stopMuxer(CaptureManager.java:86)
09-30 17:11:21.677: E/AndroidRuntime(32304): at com.harmonicprocesses.penelopefree.camera.MyMediaCodec.stop(MyMediaCodec.java:209)
09-30 17:11:21.677: E/AndroidRuntime(32304): at com.harmonicprocesses.penelopefree.camera.MyMediaCodec.checkEOS(MyMediaCodec.java:190)
09-30 17:11:21.677: E/AndroidRuntime(32304): at com.harmonicprocesses.penelopefree.camera.MyMediaCodec.runQue(MyMediaCodec.java:177)
09-30 17:11:21.677: E/AndroidRuntime(32304): at com.harmonicprocesses.penelopefree.camera.MyMediaCodec.runQue(MyMediaCodec.java:182)
09-30 17:11:21.677: E/AndroidRuntime(32304): at com.harmonicprocesses.penelopefree.camera.MyMediaCodec.sendEOS(MyMediaCodec.java:199)
09-30 17:11:21.677: E/AndroidRuntime(32304): at com.harmonicprocesses.penelopefree.camera.CaptureManager$2.run(CaptureManager.java:94)
09-30 17:11:21.677: E/AndroidRuntime(32304): at android.os.Handler.handleCallback(Handler.java:730)
09-30 17:11:21.677: E/AndroidRuntime(32304): at android.os.Handler.dispatchMessage(Handler.java:92)
09-30 17:11:21.677: E/AndroidRuntime(32304): at android.os.Looper.loop(Looper.java:137)
09-30 17:11:21.677: E/AndroidRuntime(32304): at android.os.HandlerThread.run(HandlerThread.java:61)
当我调用 stop 时,我可以深入了解 MediaMuxer.mState = MUXER_STATE_INITIALIZED。但它在 nativeStart(mNativeObject) 中失败了......
if (mState == MUXER_STATE_INITIALIZED) {
nativeStart(mNativeObject);
mState = MUXER_STATE_STARTED;