Auto-splitting video file in equal chunks with ffmpeg and Python

Alex Natskovich
1 min readDec 26, 2020

UPDATE 2: Well this script has outlived my old blog looks like. Parking the original article about it here.

UPDATE: The source code for this simple script has been moved to GitHub, get it here: https://github.com/c0decracker/video-splitter

Recently I needed to upload a whole bunch of long video files. Maximum allowed length for each video was just few minutes, while the actual length of files I tried to upload was about an hour long each. FFmpeg is really great for splitting the video files and Python is quite handy for automating the task.

Naturally combining the two together in this handy little script. The script takes a video file and a chunk size in seconds and splits the video file into chunks using ffmpeg, so each chunk is self contained, playable video.

Since I first published this little script it had a bit of community support and a few good folks worked on expanding it, so not it can do a bit more than just splitting videos in equal chunks. It can split videos into unequal chunks using a manifest file, pass on extra options to FFMPEG to say do additional processing. Check out the readme file for all the options.

--

--