修改音乐文件的码率
?? AVE (Java Audio Video Encoder) 类库是一个 ffmpeg 项目的 Java 语言封装。开发人员可以使用JAVE 在不同的格式间转换视频和音频。例如将 AVI 转成 MPEG 动画,等等 ffmpeg 中可以完成的在 JAVE 都有对应的方法。这是项目主页http://www.sauronsoftware.it/projects/jave/
我找了好久才找到,有人说用jmf 那个我觉得太麻烦 就直接在网上找了一个插件
用法:
public class Mp3Main {
??? ?public static void main(String[] args) throws IllegalArgumentException, InputFormatException, EncoderException {
??? ??? ?File source = new File("D:\\path\\邓宁 - 你是我的骄傲.mp3");//这是源文件,目录里必须要有的
??? ??? ???
??? ??? ??? File target = new File("D:\\path\\bb.mp3");//这是目标文件
??? ??? ??? System.out.println(target);
??? ??? ??? AudioAttributes audio = new AudioAttributes();
??? ??? ???
??? ??? ??? audio.setCodec("libmp3lame");
??? ??? ???
??? ??? ??? audio.setBitRate(new Integer(128000));
??? ??? ???
??? ??? ??? audio.setChannels(new Integer(1));
??? ??? ??? audio.setSamplingRate(new Integer(44100));
??? ??? ??? EncodingAttributes attrs = new EncodingAttributes();
??? ??? ??? attrs.setFormat("mp3");
??? ??? ??? attrs.setAudioAttributes(audio);
??? ??? ???
??? ??? ??? Encoder encoder = new Encoder();
??? ??? ???
??? ??? ??? encoder.encode(source, target, attrs);
??? ???
??? }