Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/191.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android MediaMuxer无法停止_Android_Android Mediacodec_Mediaextractor_Mediamuxer - Fatal编程技术网

Android MediaMuxer无法停止

Android MediaMuxer无法停止,android,android-mediacodec,mediaextractor,mediamuxer,Android,Android Mediacodec,Mediaextractor,Mediamuxer,我正在尝试使用MediaCodec、MediaExtractor和MediaMuxer生成mp4文件。一切似乎都正常,但当我打电话给MediaMuxer.stop时,我出现了一个错误。MP4文件已创建,但无法与播放机一起播放 这是我的日志: 02-13 10:41:22.420: D/OpenGLRenderer(11768): Enabling debug mode 0 02-13 10:41:22.600: I/OMXClient(11768): Using client-side OMX

我正在尝试使用MediaCodec、MediaExtractor和MediaMuxer生成mp4文件。一切似乎都正常,但当我打电话给MediaMuxer.stop时,我出现了一个错误。MP4文件已创建,但无法与播放机一起播放

这是我的日志:

02-13 10:41:22.420: D/OpenGLRenderer(11768): Enabling debug mode 0
02-13 10:41:22.600: I/OMXClient(11768): Using client-side OMX mux.
02-13 10:41:22.717: E/ACodec(11768): [OMX.TI.DUCATI1.VIDEO.DECODER] storeMetaDataInBuffers failed w/ err -2147483648
02-13 10:41:22.717: I/ACodec(11768): DRC Mode: Port Reconfig Mode
02-13 10:41:22.725: I/MPEG4Writer(11768): limits: 2147483647/0 bytes/us, bit rate: -1 bps and the estimated moov size 3072 bytes
02-13 10:41:22.803: I/MPEG4Writer(11768): setStartTimestampUs: 0
02-13 10:41:22.803: I/MPEG4Writer(11768): Earliest track starting time: 0
02-13 10:41:22.896: W/AHierarchicalStateMachine(11768): Warning message AMessage(what = 'omx ', target = 1) = {
02-13 10:41:22.896: W/AHierarchicalStateMachine(11768):   int32_t type = 0
02-13 10:41:22.896: W/AHierarchicalStateMachine(11768):   void *node = 0x4d
02-13 10:41:22.896: W/AHierarchicalStateMachine(11768):   int32_t event = 3
02-13 10:41:22.896: W/AHierarchicalStateMachine(11768):   int32_t data1 = 1
02-13 10:41:22.896: W/AHierarchicalStateMachine(11768):   int32_t data2 = 117440527
02-13 10:41:22.896: W/AHierarchicalStateMachine(11768): } unhandled in root state.
02-13 10:41:22.912: I/MPEG4Writer(11768): setStartTimestampUs: 0
02-13 10:41:22.912: D/DecodeActivity(11768): INFO_OUTPUT_BUFFERS_CHANGED
02-13 10:41:22.935: D/DecodeActivity(11768): New format {height=832, what=1869968451, color-format=256, slice-height=832, crop-left=32, width=1408, crop-bottom=743, crop-top=24, mime=video/raw, stride=4096, crop-right=1311}
02-13 10:41:22.959: W/MPEG4Writer(11768): 0-duration samples found: 1
02-13 10:41:22.975: W/MPEG4Writer(11768): 0-duration samples found: 1
02-13 10:41:22.990: I/ActivityManager(11768): Timeline: Activity_idle id: android.os.BinderProxy@41ab6858 time:26420441
02-13 10:41:33.701: D/DecodeActivity(11768): InputBuffer BUFFER_FLAG_END_OF_STREAM
02-13 10:41:33.709: D/DecodeActivity(11768): OutputBuffer BUFFER_FLAG_END_OF_STREAM
02-13 10:41:33.709: E/MPEG4Writer(11768): There are no sync frames for video track
02-13 10:41:33.717: W/MPEG4Writer(11768): 0-duration samples found: 283
02-13 10:41:33.717: I/MPEG4Writer(11768): Received total/0-length (284/0) buffers and encoded 284 frames. - video
02-13 10:41:33.717: D/MPEG4Writer(11768): Stopping Video track
02-13 10:41:33.717: D/MPEG4Writer(11768): Stopping Video track source
02-13 10:41:33.717: D/MPEG4Writer(11768): Video track stopped
02-13 10:41:33.717: D/MPEG4Writer(11768): Stopping Audio track
02-13 10:41:36.076: W/MPEG4Writer(11768): 0-duration samples found: 453
02-13 10:41:36.076: I/MPEG4Writer(11768): Received total/0-length (454/0) buffers and encoded 454 frames. - audio
02-13 10:41:36.271: I/MPEG4Writer(11768): Audio track drift time: 0 us
02-13 10:41:36.271: D/MPEG4Writer(11768): Stopping Audio track source
02-13 10:41:36.271: D/MPEG4Writer(11768): Audio track stopped
02-13 10:41:36.271: D/MPEG4Writer(11768): Duration from tracks range is [0, 0] us
02-13 10:41:36.271: D/MPEG4Writer(11768): Stopping writer thread
02-13 10:41:36.271: D/MPEG4Writer(11768): 0 chunks are written in the last batch
02-13 10:41:36.271: D/MPEG4Writer(11768): Writer thread stopped
02-13 12:28:47.507: E/MediaMuxer(14233): stop() is called in invalid state 3
02-13 10:41:36.271: W/dalvikvm(11768): threadid=11: thread exiting with uncaught exception (group=0x417fbc80)
02-13 10:41:36.271: E/AndroidRuntime(11768): FATAL EXCEPTION: Thread-2394
02-13 10:41:36.271: E/AndroidRuntime(11768): Process: com.test.applyexporter, PID: 11768
02-13 10:41:36.271: E/AndroidRuntime(11768): java.lang.IllegalStateException: Failed to stop the muxer
02-13 10:41:36.271: E/AndroidRuntime(11768):    at android.media.MediaMuxer.nativeStop(Native Method)
02-13 10:41:36.271: E/AndroidRuntime(11768):    at android.media.MediaMuxer.stop(MediaMuxer.java:226)
02-13 10:41:36.271: E/AndroidRuntime(11768):    at com.test.applyexporter.MainActivity$DecoderThread.releaseDecoder(MainActivity.java:266)
02-13 10:41:36.271: E/AndroidRuntime(11768):    at com.test.applyexporter.MainActivity$DecoderThread.run(MainActivity.java:113)
02-13 10:41:36.310: I/Process(11768): Sending signal. PID: 11768 SIG: 9
有什么线索说明停止失败的原因吗

注意错误:

E/MPEG4Writer(11768): There are no sync frames for video track
多路复用视频输出必须以同步帧(a/k/a关键帧、a/k/a I帧)开始。如果你从一个预测帧开始,但是没有什么可以预测的,解码器将不知道该做什么

确保您正在将所有值传递到
MediaMuxer
——这就是标志所在的位置。同步帧将设置
BUFFER\u FLAG\u sync\u FRAME
标志


(更新:从API 21开始,
BUFFER\u FLAG\u SYNC\u FRAME
被弃用,取而代之的是
BUFFER\u FLAG\u KEY\u FRAME
。这两个符号具有相同的整数值和相同的含义;这一变化只是API中采用一致术语的努力的一部分。)

谢谢Fadden,这就是问题所在。仅供参考,
BUFFER\u FLAG\u SYNC\u帧
已被弃用。使用
BUFFER\u FLAG\u KEY\u FRAME