FFmpeg - Split Video Into Chunks
I recently discovered how to get FFmpeg to interpolate frames in order to create amazing 60fps videos. It's pretty amazing how well it does the job. Unfortunately, the process runs on a single thread, so doing this for a 2 hour movie would take a looooong time. Thus, I wanted to see if I could break the movie up into 20 minute chunks, interpolate those chunks in parallel, and then stitch those processed chunks together and perform a final 2-pass HEVC encode (which is multi-threaded).
Unfortunately, videos tend not to have "fade-to-black" scenes every 20 minutes, and even worse, I found that using ffmpeg -ss to break up the videos into different chunks, and then playing them back in a VLC playlist, I would end up with a little bit of overlap, making the video look like it would jump.
Luckily, there is a better solution, where you can just tell FFmpeg that you want to split it into relatively equidistant chunks, and it will do this with no overlaps, by splitting on the nearest keyframe. These usually occur when the video snaps from one scene to another (e.g. there are very-few shared pixels with the previous frame).
Steps
The command below will split the video into chunks that are roughly 20 minutes long. Change the -segment_time
to increase/decrease the amount of time per chunk as desired.
ffmpeg \
-i input.mkv \
-c copy \
-map 0 \
-segment_time 00:20:00 \
-f segment \
-reset_timestamps 1 \
output%03d.mkv
References
First published: 19th September 2021