我使用MP4Parser:https://code.google.com/p/mp4parser/
如果我想合并两个或更多文件,则需要很长时间。
合并时间:大约10分钟。
在LogCat中我看到了很多这样的内容:GC_FOR_ALLOC freed 1668K, 11% free 14047K/15748K, paused 27ms, total 27ms
任何人都可以帮助我吗?
我的代码:
Movie[] inMovies = new Movie[count];
for (int i = 0; i < count; i++) {
inMovies[i] = MovieCreator.build(tempDirectory + "/"
+ i);
}
List<Track> audioTracks = new LinkedList<Track>();
for (Movie m : inMovies) {
for (Track t : m.getTracks()) {
if (t.getHandler().equals("soun")) {
audioTracks.add(t);
}
}
}
Movie result = new Movie();
if (audioTracks.size() > 0) {
result.addTrack(new AppendTrack(audioTracks
.toArray(new Track[audioTracks.size()])));
}
Container out = new DefaultMp4Builder().build(result);
FileChannel fc = new RandomAccessFile(
String.format(src), "rw").getChannel();
out.writeContainer(fc);
fc.close();