Open 13330863440 opened 11 months ago
just stop job.run(). like as
Process p = runFunc.run(path(args));
assert (p != null);
p.destroyForcibly()
Can this be done without modifying the source code
@13330863440
you can implements net.bramp.ffmpeg.RunProcessFunction
, the #run()
return java.lang.Process
.
like :
static class OwnProcessFunction extends RunProcessFunction {
private Process p;
@Override
public Process run(List<String> args) throws IOException {
p = super.run(args);
// set process
return p;
}
// destroy process.
private void close() {
ProcessHandle h = p.toHandle();
h.destroy();
h.descendants().forEach(ProcessHandle::destroy);
}
}
public static void main(String[] args) {
String ffmpegPath = Loader.load(org.bytedeco.ffmpeg.ffmpeg.class);
// use my processfunction.
OwnProcessFunction proc = new OwnProcessFunction();
FFmpeg ffmpeg = new FFmpeg(ffmpegPath, proc);
// todo
// in other thread, can call proc.close(); destroy process;
}
``