Command line Python script that splits video into chunks. Must have FFMpeg installed. File paths should not contain any spaces. Based on video-splitter implemented by c0decracker.
Run python video_split.py -h
to see the options.
- -i File path to folder containing videos that will be split
- -o File path to folder where chunks will be saved
- -l Length of each chunk in seconds
- -e File type to save chunks as, for example mp4
- -s Set to 1 in order to exclude last chunk of each video so that all chunks are of equal length. Otherwise last chunk may be shorter.
python video_split.py -i <input folder path> -o <output folder path> -l 2 -e mp4
This line will split all of the videos in the input folder into 2 second chunks and save them to the output folder.
For example, if the input folder contains the following videos:
vid1.mp4
Length: 5 secondsvid2.mp4
Length: 5 seconds
After running the above line, the output folder will contain:
vid1-0.mp4
Length: 2 secondsvid1-1.mp4
Length: 2 secondsvid1-2.mp4
Length: 1 secondvid2-0.mp4
Length: 2 secondsvid2-1.mp4
Length: 2 secondsvid2-2.mp4
Length: 1 second
python video_split.py -i <input folder path> -o <output folder path> -l 2 -e mp4 -s 1
Running the line above on the same input folder will create the following files:
vid1-0.mp4
Length: 2 secondsvid1-1.mp4
Length: 2 secondsvid2-0.mp4
Length: 2 secondsvid2-1.mp4
Length: 2 seconds