bramp / ffmpeg-cli-wrapper

Java wrapper around the FFmpeg command line tool
BSD 2-Clause "Simplified" License
1.72k stars 413 forks source link

How to split a video into small chunks and process them separately? #275

Closed ghost closed 2 years ago

ghost commented 2 years ago

The question I want to split a local video file into chunks, process those chunks separately in different threads and merge the results.

Example ffmpeg command

ffmpeg -i input.mp4 -c copy -map 0 -segment_time 00:20:00 -f segment -reset_timestamps 1 output.mp4

What you have tried This is my code snippet:

FFmpegBuilder ffmpegBuilder = new FFmpegBuilder()
                    .addOutput("./ha%03d.mp4")
                    // "-c copy -map 0 -segment_time 00:20:00 -f segment -reset_timestamps 1"
                    .addExtraArgs("-c copy", "-map 0", "-segment_time 00:20:00", "-f segment")
                    .done()
                    .setInput(file.getAbsolutePath());

The wrapper cannot recognize the flags.

The whole plan is to change the FPS of a video to 60, the video filter to achieve this is slow (interlacing) and ffmpeg won’t use multi threading so I’m trying to speed it up splitting and processing smaller chunks in parallel.