关于java对音频格式转换问题

thinker103 2014-10-19 09:04:10
public class ChangeAudioFormat {
public static void main(String[] args) throws Exception {
String path1 = "E:\\Eclipse_Web\\lbtm\\webapp\\uploadFiles\\1395047224460.amr";
String path2 = "E:\\Eclipse_Web\\lbtm\\webapp\\uploadFiles\\1395047224460.mp3";
changeToMp3(path1, path2);
}

public static void changeToMp3(String sourcePath, String targetPath) {
File source = new File(sourcePath);
File target = new File(targetPath);
AudioAttributes audio = new AudioAttributes();
Encoder encoder = new Encoder();

audio.setCodec("libmp3lame");
EncodingAttributes attrs = new EncodingAttributes();
attrs.setFormat("mp3");
attrs.setAudioAttributes(audio);

try {
encoder.encode(source, target, attrs);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InputFormatException e) {
e.printStackTrace();
} catch (EncoderException e) {
e.printStackTrace();
}
}
}
通过这种方式可以把AMR格式的音频转成MP3格式,而且音质也没问题,但是把AAC格式的音频转成Mp3格式的时候,声音变质了,声音变的很慢。我设置相应的比特率和采样率等参数还是这样,这个问题怎么处理?望大神指教。
...全文
205 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

62,621

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧