How can I trim a video from Uri, including files that `mp4parser` library can handle, but using Android's framework instead?

巧了我就是萌 提交于 2019-12-04 23:10:48
  1. Why does it occur?

audio/ac3 is an unsupported mime type.

MediaMuxer.addTrack() (native) calls MPEG4Writer.addSource(), which prints this log message before returning an error.

EDIT

My aim was not to provide an answer to each of your sub-questions, but to give you some insight into the fundamental problem. The library you have chosen relies on the Android's MediaMuxer component. For whatever reason, the MediaMuxer developers did not add support for this particular audio format. We know this because the software prints out an explicit message to that effect, then immediately throws the IllegalStateException mentioned in your question.

Because the issue only involves a particular audio format, when you provide a video-only input, everything works fine.

To fix the problem, you can either alter the library to provide for the missing functionality, or find a new library that better suits your needs. sannies/mp4parser may be one such alternative, although it has different limitations (if I recall correctly, it requires all media to be in RAM during the mastering process). I do not know if it supports ac3 explicitly, but it should provide a framework to which you can add support for arbitrary mime types.

I would encourage you to wait for a more complete answer. There may be far better ways to do what you are trying to do. But it is apparent that the library you are using simply does not support all possible mime types.

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