MediaMuxer错误"未能阻止复用器"错误、复用器、MediaMuxer、QUOT

2023-09-07 11:09:20 作者:白衣折扇

我用媒体codeC 与MIME类型编码摄像机 preVIEW数据视频/ AVC和EN codeD的数据(仅视频,没有音频)传递给 MediaMuxer 。该复用器看上去一切正常,并创建合理大小的输出文件(即变大的时间越长我记录)。然而,当我试图停止复用器我得到的无法停止复用器错误:

  10月10日至21号:39:40.755:E / AndroidRuntime(2166):java.lang.IllegalStateException:无法停止复用器产生的原因
 

有一些可疑的MPEG4Writer日志信息preceding故障停机:

  10月10日至21号:39:40.740:D / MPEG4Writer(2166):停止视频轨
十月10号至21号:39:40.740:E / MPEG4Writer(2166):缺少codeC的具体数据
发现0持续时间样本:10-21 10:39:40.740:W / MPEG4Writer(2166)122
十月10号至21号:39:40.740:I / MPEG4Writer(2166):收到的总/ 0长度(一分之一百二十三)缓冲和连接codeD 123帧。 - 视频
十月10号至21号:39:40.740:D / MPEG4Writer(2166):停止视频音轨源码
十月10号至21号:39:40.740:D / MPEG4Writer(2166):视频轨停止
十月10号至21号:39:40.740:D / MPEG4Writer(2166):停止写线程
10日至21 10:39:40.740:D / MPEG4Writer(2166):0块被写在最后一批
十月10号至21号:39:40.740:D / MPEG4Writer(2166):作家线程停止
十月10号至21号:39:40.740:E / MPEG4Writer(2166):作家失误结束!
 

任何线索是什么原因造成的?不知道是什么的详细信息,您需要。

解决方案

  E / MPEG4Writer(2166):缺少codeC的具体数据
 
stm32 keil MDK在线调试报错 Error Flash download failed Cortex M3

听起来像是你没叫 MediaMuxer#addTrack() MediaFormat ,其中包括CSD。请参阅恩codeAndMuxTest.java $ C $下如何做到这一点的例子。

纵观MPEG4Writer实施的使用 MediaMuxer ,有一个 isTrackMalformed()检查线路2360;它集 ERROR_MALFORMED 如果CSD数据不是present,但不会立即返回。没有清除错误,所以它会做了一堆的工作,然后失败,这似乎符合您所看到的。

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

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

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.

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.