我成功编译了ffmpeg for Android,但我不知道如何以编程方式将flv或mp4文件转换为mp3,但我需要它。有人可以通过示例或教程帮助我吗?谢谢。
答案 0 :(得分:1)
有关如何使用ProcessBuilder
通过CLI为Android编译的FFmpeg二进制文件的一个很好的示例,请访问:
请注意方法:
private int execProcess(String cmd, ShellCallback sc, File fileExec) throws IOException, InterruptedException {
ProcessBuilder pb = new ProcessBuilder(cmd);
pb.directory(fileExec);
Log.d(TAG,cmd);
// pb.redirectErrorStream(true);
Process process = pb.start();
// any error message?
StreamGobbler errorGobbler = new
StreamGobbler(process.getErrorStream(), "ERROR", sc);
// any output?
StreamGobbler outputGobbler = new
StreamGobbler(process.getInputStream(), "OUTPUT", sc);
// kick them off
errorGobbler.start();
outputGobbler.start();
int exitVal = process.waitFor();
sc.processComplete(exitVal);
return exitVal;
}