结合使用mp4parser在Android MP4S [英] Combine Mp4s using mp4parser on Android
本文介绍了结合使用mp4parser在Android MP4S的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只是想知道,如果有人知道如何采取一个MP4的音频文件,并使用 mp4parser
Android上覆盖其上的MP4的视频文件。我已经能够添加一个视频与另一个,现在我只需要覆盖原始的MP4,我有过合并的文件。
I was just wondering if anybody knows how to take an mp4 audio file and overlay it onto an mp4 video file using mp4parser
on Android. I have been able to append one video with another, now I just need to overlay a raw mp4 that I have over the combined file.
任何帮助将是AP preciated!
Any help would be appreciated!
推荐答案
以下code复用器两个音频语言和视频。它应该很容易将其采纳您的需要:
The following code muxes two audio languages and a video. It should be easy to adopt it to your needs:
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在Android MP4S的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文