我想使用mp4parser合并一些视频文件,其中任何一个都可能没有音轨。目前,如果我合并这些文件,音频将进入另一个段,这是错误的。这就是我合并文件的方式
LinkedList<Track> videoTracks = new LinkedList<>();
LinkedList<Track> audioTracks = new LinkedList<>();
for (Movie m : inMovies) {
for (Track t : m.getTracks()) {
if (t.getHandler().equals("soun")) {
audioTracks.add(t);
}
if (t.getHandler().equals("vide")) {
videoTracks.add(t);
}
}
}
Movie result = new Movie();
if (audioTracks.size() > 0) {
result.addTrack(new AppendTrack(audioTracks.toArray(new Track[audioTracks.size()])));
}
if (videoTracks.size() > 0) {
result.addTrack(new AppendTrack(videoTracks.toArray(new Track[videoTracks.size()])));
}
没有音频的视频文件,如果(t.getHandler().equals("soun"))
我还在mp4parser lib中打开了一个问题:https://github.com/sannies/mp4parser/issues/296