您的位置:首页 > 编程语言 > Java开发

java 将.amr音频文件转换为.mp3或.wav文件

2016-07-25 10:05 465 查看
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/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: