MediaMuxer error “Failed to stop the muxer”

不羁岁月 提交于 2019-11-28 00:53:27
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.

I had the same issue .While closing the Muxer it was throwing "Failed to stop" error.When I checked my saved file in an ISO viewer I couldn't find the Track in it . I solved issue by creating the track only after getting the first output from the video encoder.Here is how I add my track

 m_VideoTrackIndex = muxer.addTrack(mediaCodec.getOutputFormat());

The media format for the track is obtained from mediaCodec.getOutputFormat() which in turn will get initialized only after encoding the first frame.I changed my code to add the track after getting first encoded data (And of course only once).It is working fine .

There are 2 Problems with Android 5.0.2 Devices Moto E 1) The Width & height if not supplied multiples of 16 its crashing 2) The mediaBuffer to be set after the First Frame is Encoded

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!