JAVE 官方的jar包带了ffmpeg的exe程序,所以在windows上可以直接使用,
但是如果要在Linux上用就得先把ffmpeg的环境装好。
File source = new File("source.wav");
File target = new File("target.mp3");
AudioAttributes audio = new AudioAttributes();
audio.setCodec("libmp3lame");
audio.setBitRate(new Integer(128000));
audio.setChannels(new Integer(2));
audio.setSamplingRate(new Integer(44100));
EncodingAttributes attrs = new EncodingAttributes();
attrs.setFormat("mp3");
attrs.setAudioAttributes(audio);
Encoder encoder = new Encoder();
encoder.encode(source, target, attrs);
Jar下载地址:
http://www.sauronsoftware.it/projects/jave/download.php