handle multi command

handle multi command
pull/166/head
xufulong 5 years ago
parent 640c92c774
commit 52d648811e
  1. 30
      app/src/main/java/com/frank/ffmpeg/FFmpegCmd.java
  2. 30
      app/src/main/java/com/frank/ffmpeg/handler/FFmpegHandler.java

@ -1,9 +1,12 @@
package com.frank.ffmpeg;
import android.text.TextUtils;
import android.util.Log;
import com.frank.ffmpeg.listener.OnHandleListener;
import java.util.List;
/**
* The JNI interface of handling FFmpeg command
* Created by frank on 2018/1/23
@ -39,6 +42,33 @@ public class FFmpegCmd {
}).start();
}
/**
* Execute FFmpeg multi commands
* @param commands the String array of command
* @param onHandleListener the callback for executing command
*/
public static void execute(final List<String[]> commands, final OnHandleListener onHandleListener) {
new Thread(new Runnable() {
@Override
public void run() {
if (onHandleListener != null) {
onHandleListener.onBegin();
}
//call JNI interface to execute FFmpeg cmd
int result = 0;
int count = 0;
for (String[] command : commands) {
result = handle(command);
count ++;
Log.i("FFmpegCmd", count + " result=" + result);
}
if (onHandleListener != null) {
onHandleListener.onEnd(result, null);
}
}
}).start();
}
/**
* Using FastStart to moov box in front of mdat box
*

@ -8,6 +8,8 @@ import com.frank.ffmpeg.listener.OnHandleListener;
import com.frank.ffmpeg.model.MediaBean;
import com.frank.ffmpeg.tool.JsonParseTool;
import java.util.List;
/**
* Handler of FFmpeg and FFprobe
* Created by frank on 2019/11/11.
@ -64,6 +66,34 @@ public class FFmpegHandler {
});
}
/**
* execute multi commands of FFmpeg
*
* @param commandList the list of command
*/
public void executeFFmpegCmds(final List<String[]> commandList) {
if (commandList == null) {
return;
}
FFmpegCmd.execute(commandList, new OnHandleListener() {
@Override
public void onBegin() {
Log.i(TAG, "handle onBegin...");
mHandler.obtainMessage(MSG_BEGIN).sendToTarget();
}
@Override
public void onEnd(int resultCode, String resultMsg) {
Log.i(TAG, "handle onEnd...");
if (isContinue) {
mHandler.obtainMessage(MSG_CONTINUE).sendToTarget();
} else {
mHandler.obtainMessage(MSG_FINISH).sendToTarget();
}
}
});
}
/**
* execute the command of FFprobe
*

Loading…
Cancel
Save