Reputation: 97
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.
Upvotes: 0
Views: 6931
Reputation: 3263
A good example on how to use an FFmpeg binary compiled for Android via CLI, using ProcessBuilder
, is available here:
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;
}
Upvotes: 1