5

我只是想知道是否有人知道如何获取 mp4 音频文件并将其覆盖到mp4parser在 Android 上使用的 mp4 视频文件上。我已经能够将一个视频附加到另一个视频,现在我只需要将我拥有的原始 mp4 覆盖在组合文件上。

任何帮助,将不胜感激!

4

1 回答 1

4

以下代码混合了两种音频语言和一个视频。它应该很容易满足您的需求:

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

}
于 2013-06-30T21:33:49.097 回答