微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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();

}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐