cancel the running task

cancel the running task
pull/166/head
xufulong 4 years ago
parent ecb2520208
commit ada8188900
  1. 10
      app/src/main/cpp/ffmpeg/ffmpeg.c
  2. 1
      app/src/main/cpp/ffmpeg/ffmpeg.h
  3. 4
      app/src/main/cpp/ffmpeg_cmd.c
  4. 6
      app/src/main/java/com/frank/ffmpeg/FFmpegCmd.java
  5. 8
      app/src/main/java/com/frank/ffmpeg/handler/FFmpegHandler.java

@ -159,6 +159,7 @@ int nb_output_files = 0;
FilterGraph **filtergraphs;
int nb_filtergraphs;
int cancel_execute = 0;
#if HAVE_TERMIOS_H
/* init terminal so that we can grab keys */
@ -4709,6 +4710,11 @@ static int transcode(void)
break;
}
if (cancel_execute) {
av_log(NULL, AV_LOG_ERROR, "cancel task by user...");
break;
}
ret = transcode_step();
if (ret < 0 && ret != AVERROR_EOF) {
av_log(NULL, AV_LOG_ERROR, "Error while filtering: %s\n", av_err2str(ret));
@ -4940,3 +4946,7 @@ end:
ffmpeg_cleanup(0);
return main_return_code;
}
void cancel_task(int cancel) {
cancel_execute = cancel;
}

@ -675,5 +675,6 @@ enum ProgressState {
};
void progress_callback(int position, int duration, int state);
void cancel_task(int cancel);
#endif /* FFTOOLS_FFMPEG_H */

@ -49,6 +49,10 @@ FFMPEG_FUNC(jint, handle, jobjectArray commands) {
return result;
}
FFMPEG_FUNC(void, cancelTaskJni, jint cancel) {
cancel_task(cancel);
}
void log_callback(void* ptr, int level, const char* format, va_list args) {
switch (level) {
case AV_LOG_DEBUG:

@ -93,6 +93,10 @@ public class FFmpegCmd {
}).start();
}
public static void cancelTask(boolean cancel) {
cancelTaskJni(cancel ? 1 : 0);
}
/**
* Using FastStart to moov box in front of mdat box
*
@ -142,6 +146,8 @@ public class FFmpegCmd {
private native static int handle(String[] commands);
private native static void cancelTaskJni(int cancel);
private native static int fastStart(String inputFile, String outputFile);
private native static String handleProbe(String[] commands);

@ -73,6 +73,14 @@ public class FFmpegHandler {
});
}
/**
* cancel the running task, and exit quietly
* @param cancel cancel the task when flag is true
*/
public void cancelExecute(boolean cancel) {
FFmpegCmd.cancelTask(cancel);
}
/**
* execute multi commands of FFmpeg
*

Loading…
Cancel
Save