java – 在Android上使用mp4parser组合Mp4s

我只是想知道是否有人知道如何使用mp4音频文件并使用Android上的mp4parser将其叠加到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();

}

相关文章

Android 如何解决dialog弹出时无法捕捉Activity的back事件 在...
Android实现自定义带文字和图片的Button 在Android开发中经常...
Android 关于长按back键退出应用程序的实现最近在做一个Andr...
android自带的时间选择器只能精确到分,但是对于某些应用要求...