Skip to content

Instantly share code, notes, and snippets.

@cjacobwade
Created May 8, 2022 02:51
Show Gist options
  • Save cjacobwade/533e95b5ad257c45b4a34d538b789ae9 to your computer and use it in GitHub Desktop.
Save cjacobwade/533e95b5ad257c45b4a34d538b789ae9 to your computer and use it in GitHub Desktop.
Python script to cut a video into 10 second skips and 0.5 seconds of gameplay
import sys
from moviepy.editor import *
print(sys.argv)
skipTime = float(sys.argv[1])
videoTime = float(sys.argv[2])
inputName = sys.argv[3]
video = VideoFileClip(inputName)
subclips = []
numCuts = video.duration / (skipTime + videoTime)
i = 0
while i < numCuts:
startTime = float((skipTime + videoTime) * i)
clip = video.subclip(startTime, startTime + videoTime)
subclips.append(clip)
i += 1
finalVideo = concatenate_videoclips(subclips)
outputName = inputName.replace(".mp4", "_Shortplay.mp4")
finalVideo.write_videofile(outputName)
print("Success")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment