MediaMuxer 错误“无法停止复用器" [英] MediaMuxer error "Failed to stop the muxer"
问题描述
我正在使用带有 MIME 类型video/avc"的 MediaCodec
对 Camera
预览数据进行编码,并将编码数据(仅视频,无音频)传递给 <代码>MediaMuxer.多路复用器似乎运行良好并创建了一个合理大小的输出文件(即,我记录的时间越长越大).但是,当我尝试停止多路复用器时,出现无法停止多路复用器"错误:
I'm encoding Camera
preview data using MediaCodec
with mime-type "video/avc" and passing the encoded data (video-only, no audio) to MediaMuxer
. The muxer seems to run fine and creates a reasonably sized output file (i.e., gets larger the longer I record). However, when I try to stop the muxer I get the "Failed to stop the muxer" error:
10-21 10:39:40.755: E/AndroidRuntime(2166): Caused by: java.lang.IllegalStateException: Failed to stop the muxer
在停止失败之前有一些可疑的 MPEG4Writer 日志消息:
There are some suspicious MPEG4Writer log messages preceding the failed stop:
10-21 10:39:40.740: D/MPEG4Writer(2166): Stopping Video track
10-21 10:39:40.740: E/MPEG4Writer(2166): Missing codec specific data
10-21 10:39:40.740: W/MPEG4Writer(2166): 0-duration samples found: 122
10-21 10:39:40.740: I/MPEG4Writer(2166): Received total/0-length (123/1) buffers and encoded 123 frames. - video
10-21 10:39:40.740: D/MPEG4Writer(2166): Stopping Video track source
10-21 10:39:40.740: D/MPEG4Writer(2166): Video track stopped
10-21 10:39:40.740: D/MPEG4Writer(2166): Stopping writer thread
10-21 10:39:40.740: D/MPEG4Writer(2166): 0 chunks are written in the last batch
10-21 10:39:40.740: D/MPEG4Writer(2166): Writer thread stopped
10-21 10:39:40.740: E/MPEG4Writer(2166): writer error ended!
任何线索是什么导致了这种情况?不确定您还需要什么信息.
Any clues what is causing this? Not sure what more info you'll need.
推荐答案
E/MPEG4Writer(2166): Missing codec specific data
听起来您没有使用包含 CSD 的 MediaFormat
调用 MediaMuxer#addTrack()
.有关如何执行此操作的示例,请参阅 EncodeAndMuxTest.java 代码.
Sounds like you didn't call MediaMuxer#addTrack()
with a MediaFormat
that included the CSD. See the EncodeAndMuxTest.java code for an example of how to do this.
查看 MPEG4WriterMediaMuxer
使用的实现,在第 2360 行有一个 isTrackMalformed()
检查;如果 CSD 数据不存在,它会设置 ERROR_MALFORMED
,但不会立即返回.没有什么可以清除错误,所以它会做很多工作然后失败,这似乎与您所看到的相符.
Looking at the MPEG4Writer implementation used by MediaMuxer
, there's an isTrackMalformed()
check on line 2360; it sets ERROR_MALFORMED
if the CSD data isn't present, but doesn't return immediately. Nothing clears the error, so it'll do a bunch of work and then fail, which seems to match what you're seeing.
这篇关于MediaMuxer 错误“无法停止复用器"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!