Tuesday, 10 December 2019

How to kill FFmpeg currently running process?

I'm working on an application that trims a video using FFmpeg. While the trimming process has started and I cancel it, the FFmpeg is terminated fully. How can I achieve by killing the current working process?

   /* define PID */
  try {
     String pid = ffmpeg.toString();
     pid = pid.substring(pid.indexOf("[") + 1, pid.indexOf("]"));
     Process process = Runtime.getRuntime().exec("kill -2 " + pid);

     process.waitFor();
     ffmpeg.wait();
  } catch (IOException | InterruptedException e) {
     Log.e(TAG, "kill_ffmpeg: exception failed ",e );
     e.printStackTrace();
  }

This is the code I've been using now. when this code awake the activity restarts with an exception of the index out of bound.

This is the library I've been using for achieving a video editing feature using FFmpeg com.github.hiteshsondhi88.libffmpeg.FFmpeg;

How can I achieve Killing a process without memory leaks and without crashing the app when the particular code has been invoked?



from How to kill FFmpeg currently running process?

No comments:

Post a Comment