I use the bramp/ffmpeg-cli-wrapper of java. How to terminate the execution in the thread?

I want to use ffmpeg to achieve streaming function

First I created a thread pool

 private final Map taskThreads = new ConcurrentHashMap<>();
Thread taskThread = new Thread(() -> {
            try {
                private void startTask(Device task) {
        Thread taskThread = new Thread(() -> {

            FFmpegBuilder builder = new FFmpegBuilder()
                    .setInput(source) 
                    .overrideOutputFiles(true)
                    .addOutput(destination) 
                    .setFormat("flv")
                    .addExtraArgs("-c", "copy") 
                    .done();

            FFmpegExecutor executor = new FFmpegExecutor(ffmpeg, ffprobe);
            executor.createJob(builder).run();
        });
        taskThreads.put(task.getId(), taskThread);
        taskThread.start();
    }

stop code

public void stopTask(Integer taskId) {
        Thread taskThread = taskThreads.get(taskId);
        if (taskThread != null) {
            taskThread.interrupt(); 
            taskThreads.remove(taskId);
            
            DeviceDto task = deviceService.findById(taskId);
            if (task != null) {
                task.setIsOnline(0);
                Device device = new Device();
                BeanUtils.copyProperties(task,device);
                deviceService.update(device);
            }
        }
    }

I call stopTask and cannot terminate the ffmpeg thread

It should be executor.createJob(builder).run(); blocked

How to solve

Read more here: Source link