I am using WritingMinds/ffmpeg-android-java in application.
here is my code
loadFFmpeg();
String cmd="ffmpeg -i /storage/emulated/0/media/audio/a.mp3 -i /storage/emulated/0/recording.3gp -filter_complex \"[0:a][1:a]amerge=inputs=2[aout]\" -map \"[aout]\" " + outputFile;
executeFFmpeg(cmd.split(" "));
and
private void loadFFmpeg() {
FFmpeg ffmpeg = FFmpeg.getInstance(MainActivity.this.getApplicationContext());
try {
ffmpeg.loadBinary(new LoadBinaryResponseHandler() {
@Override
public void onStart() {}
@Override
public void onFailure() {}
@Override
public void onSuccess() {}
@Override
public void onFinish() {}
});
} catch (FFmpegNotSupportedException e) {
// Handle if FFmpeg is not supported by device
}
}
private void executeFFmpeg(String[] cmd)
{
/*String workFolder = getApplicationContext().getFilesDir() + "/ffmpeg";
String environment = Environment.getExternalStorageDirectory().getAbsolutePath();
Map<String, String> map = new HashMap<String, String>();
map.put("Working Directory", workFolder);
map.put("Environment",environment);*/
FFmpeg ffmpeg = FFmpeg.getInstance(MainActivity.this.getApplicationContext());
try {
// to execute "ffmpeg -version" command you just need to pass "-version"
ffmpeg.execute(cmd, new ExecuteBinaryResponseHandler() {
@Override
public void onStart() {}
@Override
public void onProgress(String message) {}
@Override
public void onFailure(String message) {}
@Override
public void onSuccess(String message) {}
@Override
public void onFinish() {
stop.setEnabled(false);
play.setEnabled(true);
}
});
} catch (FFmpegCommandAlreadyRunningException e) {
// Handle if FFmpeg is already running
}
}
but I am getting following error
6784-6962/com.flipartstudio.playandrecord E/FFmpeg: Exception while trying to run: [Ljava.lang.String;@41803270 java.io.IOException: Error running exec(). Command: [/data/data/com.flipartstudio.playandrecord/files/ffmpeg, /system/bin/ls, -l, /data/data/com.example.foo/files/ffmpeg] Working Directory: null Environment: null at java.lang.ProcessManager.exec(ProcessManager.java:211) at java.lang.Runtime.exec(Runtime.java:168) at java.lang.Runtime.exec(Runtime.java:123) at com.github.hiteshsondhi88.libffmpeg.ShellCommand.run(ShellCommand.java:10) at com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteAsyncTask.doInBackground(FFmpegExecuteAsyncTask.java:38) at com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteAsyncTask.doInBackground(FFmpegExecuteAsyncTask.java:10) at android.os.AsyncTask$2.call(AsyncTask.java:287) at java.util.concurrent.FutureTask.run(FutureTask.java:234) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) at java.lang.Thread.run(Thread.java:856) Caused by: java.io.IOException: No such file or directory at java.lang.ProcessManager.exec(Native Method) at java.lang.ProcessManager.exec(ProcessManager.java:209) at java.lang.Runtime.exec(Runtime.java:168) at java.lang.Runtime.exec(Runtime.java:123) at com.github.hiteshsondhi88.libffmpeg.ShellCommand.run(ShellCommand.java:10) at com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteAsyncTask.doInBackground(FFmpegExecuteAsyncTask.java:38) at com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteAsyncTask.doInBackground(FFmpegExecuteAsyncTask.java:10) at android.os.AsyncTask$2.call(AsyncTask.java:287) at java.util.concurrent.FutureTask.run(FutureTask.java:234) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) at java.lang.Thread.run(Thread.java:856)
I have also added
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.STORAGE" />