I am currently working on a project in Java, where I have to combine several pictures to an MP4 file and also add audio track to this file (as WAV or MP3).
<\/li>
If yes, then I'd also like to know how to convert a WAV or MP3 file to AAC\/M4A in Java. Is there a good library for doing the job? I've been stuck at this point for about a week now and I hope this thread will lead to some more useful result.<\/li><\/ul> I hope someone will be able to help, I wish you a happy day, whether you can help or not.
using this code you can add .wav and other supported formats by jdk to your java code
import java.io.File;
import javax.sound.sampled.*;
use try catch or throws method here i used try catch method
public class Music {
public static void main(String[] args){
try{
File file = new File("--file location--");
AudioInputStream audioStream =AudioSystem.getAudioInputStream(file);
Clip clip = AudioSystem.getClip();
clip.open(audioStream);
clip.start();
Thread.sleep(s*1000); // s = time in seconds
}catch(Exception e){
System.out.println(e);
System.out.println("File Not Supported");
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.