我想知道有没有人知道如何在Android上使用mp4parser
将mp4音频文件叠加到mp4视频文件上。我已经能够将一个视频追加到另一个视频上,现在我只需要在合并的文件上叠加一个原始mp4。
如果有帮助,将不胜感激!
public static void main(String[] args) throws IOException {
String audioDeutsch = MuxMp4SourcesExample.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/count-deutsch-audio.mp4";
String audioEnglish = MuxMp4SourcesExample.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/count-english-audio.mp4";
String video = MuxMp4SourcesExample.class.getProtectionDomain().getCodeSource().getLocation().getFile() + "/count-video.mp4";
Movie countVideo = MovieCreator.build(new FileInputStream(video).getChannel());
Movie countAudioDeutsch = MovieCreator.build(new FileInputStream(audioDeutsch).getChannel());
Movie countAudioEnglish = MovieCreator.build(new FileInputStream(audioEnglish).getChannel());
Track audioTrackDeutsch = countAudioDeutsch.getTracks().get(0);
audioTrackDeutsch.getTrackMetaData().setLanguage("deu");
Track audioTrackEnglish = countAudioEnglish.getTracks().get(0);
audioTrackEnglish.getTrackMetaData().setLanguage("eng");
countVideo.addTrack(audioTrackDeutsch);
countVideo.addTrack(audioTrackEnglish);
Container out = new DefaultMp4Builder().build(countVideo);
FileOutputStream fos = new FileOutputStream(new File("output.mp4"));
out.writeContainer(fos.getChannel());
fos.close();
}
mp4parser
将两个视频文件合并成一个,是否可行? - user3751794