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 only?
/* 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 Here
There is a method in this FFmpeg library called killRunningProcess()
. When I use this method, shows an error called cannot resolve method killRunningProcess()
How can I achieve Killing a process without memory leaks and without crashing the app when the particular code has been invoked?