Closed Blankeer closed 6 years ago
I am also interested on multi commands.
This works for me. It takes 3 steps:
private static List<FFmpeg> instanceList;
private final static int INSTANCE_COUNT = 2;
public static List<FFmpeg> getInstanceList(final Context context) {
if (instanceList == null) {
//instanceList = new ArrayList<Pair<FFmpeg,FFcommandExecuteAsyncTask>>();
instanceList = new ArrayList<>();
for (int i = 0; i<INSTANCE_COUNT; i ++) {
FFmpeg mFFmpeg = new FFmpeg(new FFbinaryContextProvider() {
@Override
public Context provide() {
return context;
}
});
instanceList.add(mFFmpeg);
}
}
return instanceList;
}
ffmpegExecuteAsyncTask.execute()
to
ffmpegExecuteAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR)
This will make sure the asynctasks run in parallel (which I think what you want)
FFmpeg ffmpeg = FFmpegList.getInstanceList(getApplicationContext()).get(0);
try {
ffmpeg.execute(cmd, new ExecuteBinaryResponseHandler() {}...
}
FFmpeg ffmpeg1 = FFmpegList.getInstanceList(getApplicationContext()).get(1);
try {
ffmpeg1.execute(cmd1, new ExecuteBinaryResponseHandler() {}...
}
Just to give you an idea.
@function1983 Thanks for that code.
Multithreading has now been added for FFmpeg & FFprobe commands.
dependencies {
implementation 'nl.bravobit:android-ffmpeg:1.1.2'
}
I see the code,only allowed to run single command at a time. so,How to use multi command when multi thread? thanks.