1、在windows系统下
//利用ffmpeg.exe工具与cmd中的命令进行转换
//sourcePath为需要转换的.amr文件路径;targetPath为转换好的.mp3文件路径;
//toolPath为ffmpeg.exe文件路径
public void amrChangeToWavByFfmpegTool(String sourcePath,String targetPath,String toolPath){
File tool = new File(toolPath);
if (tool.exists()) {
String c = "\"" + toolPath + "\"" + " -y -i " + "\"" + sourcePath + "\"" + " -ar 8000 -ab 12.2k -ac 1 " + "\"" + targetPath + "\"";
try {
Process p = Runtime.getRuntime().exec(c);
p.destroy();
} catch (IOException e) {
e.printStackTrace();
}finally{
System.out.println("用ffmpeg工具进行了转换!");
}
}else {
System.out.println("ffmpeg工具不存在!");
}
}
2、在linux系统下
有一篇特别好的文章推荐给大家
http://linjie.org/2015/08/06/amr%E6%A0%BC%E5%BC%8F%E8%BD%ACmp3%E6%A0%BC%E5%BC%8F-%E5%AE%8C%E7%BE%8E%E8%A7%A3%E5%86%B3Linux%E4%B8%8B%E8%BD%AC%E6%8D%A20K%E9%97%AE%E9%A2%98/