I succesfully compiled ffmpeg for Android, but I don't know how I can programatically convert flv or mp4 files to mp3, but I need it. Can anybody help me with example or tutorial? Thank you.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
A good example on how to use an FFmpeg binary compiled for Android via CLI, using ProcessBuilder
, is available here:
https://github.com/guardianproject/android-ffmpeg-java/blob/master/src/org/ffmpeg/android/FfmpegController.java
Note the method:
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;
}