Skip to content

Python script to split a batch of videos into chunks of equal length and save the chunks to another folder.

Notifications You must be signed in to change notification settings

JoshuaMathew/Video-Split

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Video-Split

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.

Arguments

  • -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.

Spliting video into equal chunks

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 seconds
  • vid2.mp4 Length: 5 seconds

After running the above line, the output folder will contain:

  • vid1-0.mp4 Length: 2 seconds
  • vid1-1.mp4 Length: 2 seconds
  • vid1-2.mp4 Length: 1 second
  • vid2-0.mp4 Length: 2 seconds
  • vid2-1.mp4 Length: 2 seconds
  • vid2-2.mp4 Length: 1 second

Exluding the last chunk

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 seconds
  • vid1-1.mp4 Length: 2 seconds
  • vid2-0.mp4 Length: 2 seconds
  • vid2-1.mp4 Length: 2 seconds

About

Python script to split a batch of videos into chunks of equal length and save the chunks to another folder.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages