Mã sau đây mô tả hai ngôn ngữ âm thanh và video. Bạn nên dễ dàng áp dụng nó theo nhu cầu của mình:
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();
}
Nguồn
2013-06-30 21:33:49
Âm thanh Ghi đè khi sử dụng mã này .. ANy help ?? –
@Sebastian Các bản âm thanh được thêm sau cái kia. Có anyway tôi có thể thêm hai bài hát âm thanh và họ phải chạy cùng một lúc và rõ ràng là video. Giả sử tôi có video và âm thanh thoại cũng như nhạc nền. Bây giờ tôi muốn có hai âm thanh chạy song song cùng một lúc với video. Bạn có thể giúp chúng tôi đạt được điều này không? – ROCKY
Đoạn mã được đề cập ở trên kết hợp video với bản âm thanh đầu tiên được thêm vào. Tôi muốn phát hai bản âm thanh song song với tệp video. Bất cứ ai có thể giúp tôi cho rằng –