-
FFmpeg是一款在Linux系统中用于将amr格式转换为MP3格式的工具
资源介绍
xz -d ***.tar.xz
tar -xvf ***.tar
public static boolean amrToMp3(String localPath, String targetFilePath,String fileUrl) {
try {
System.out.println("************** ffmpeg ****************");
java.lang.Runtime rt = Runtime.getRuntime();
//命令
String command = fileUrl+"ffmpeg -i " + localPath + " " + targetFilePath;
//执行amr转MP3命令
Process proc = rt.exec(command);
InputStream stderr = proc.getErrorStream();
InputStreamReader isr = new InputStreamReader(stderr);
BufferedReader br = new BufferedReader(isr);
String line = null;
StringBuffer sb = new StringBuffer();
while ((line = br.readLine()) != null)
sb.append(line);
System.out.println("ffmpeg Process errorInfo: " + sb.toString());
int exitVal = proc.waitFor();
System.out.println("ffmpeg Process exitValue: " + exitVal);
return true;
} catch (Exception e) {
System.out.println("ffmpeg exec cmd Exception " + e.toString());
}
return false;
}