Il codice seguente mux due lingue audio e un video. Dovrebbe essere facile da adottare per le tue esigenze:
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();
}
fonte
2013-06-30 21:33:49
Audio È sovrascrittura quando si utilizza questo codice .. Qualsiasi aiuto ?? –
@Sebastian Le tracce audio vengono aggiunte una dopo l'altra. È comunque possibile aggiungere due tracce audio e devono essere eseguite contemporaneamente e ovviamente nel video. Diciamo che ho un video e una voce audio e anche una musica di sottofondo. Ora voglio far funzionare questi due audio parallelamente allo stesso tempo con il video. Potete aiutare come possiamo ottenere questo? – ROCKY
Il codice sopra menzionato mescola il video con la prima traccia audio aggiunta. Voglio riprodurre due tracce audio parallele al file video. Qualcuno mi può aiutare per questo –