MediaMuxer writeSampleData错误

时间:2015-10-13 06:43:01

标签: android audio mediacodec mediamuxer

我使用MediaMuxer混合音频和无线电数据,数据来自两个编码器,流程正确,我得到输出并播放它。但是由于错误而导致writeSampleData,MediaMuxer可能会失败:

 E/MPEG4Writer: timestampUs 21932611 < lastTimestampUs 22055361 for Video track
10-14 14:23:41.580 20089-20230/org.cocos2dx.simplegame E/AndroidRuntime: FATAL EXCEPTION: MediaMuxer
10-14 14:23:41.580 20089-20230/org.cocos2dx.simplegame E/AndroidRuntime: Process: org.cocos2dx.simplegame, PID: 20089
10-14 14:23:41.580 20089-20230/org.cocos2dx.simplegame E/AndroidRuntime: java.lang.IllegalStateException: writeSampleData returned an error
10-14 14:23:41.580 20089-20230/org.cocos2dx.simplegame E/AndroidRuntime:     at android.media.MediaMuxer.nativeWriteSampleData(Native Method)
10-14 14:23:41.580 20089-20230/org.cocos2dx.simplegame E/AndroidRuntime:     at android.media.MediaMuxer.writeSampleData(MediaMuxer.java:334)
10-14 14:23:41.580 20089-20230/org.cocos2dx.simplegame E/AndroidRuntime:     at com.duapps.durecorder.muxer.DuMediaMuxer.handleMessage(DuMediaMuxer.java:53)
10-14 14:23:41.580 20089-20230/org.cocos2dx.simplegame E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102)
10-14 14:23:41.580 20089-20230/org.cocos2dx.simplegame E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:136)
10-14 14:23:41.580 20089-20230/org.cocos2dx.simplegame E/AndroidRuntime:     at android.os.HandlerThread.run(HandlerThread.java:61)

我看到MPEG4Writer,错误的根本原因是视频的时间戳,它让MediaMuxer运行到IllegalState。经过大量测试后,我知道视频和音频时间戳都可能出错,当我改变音频采样率时,复发率会发生变化。

当我只录制音频或广播时,错误可能会再次出现。

有人可以给我一些建议吗?

0 个答案:

没有答案