Skip to content

Instantly share code, notes, and snippets.

@raymondberg
Created July 25, 2019 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raymondberg/ded30fa7d01f0de8ddbb00c37ccbacdc to your computer and use it in GitHub Desktop.
Save raymondberg/ded30fa7d01f0de8ddbb00c37ccbacdc to your computer and use it in GitHub Desktop.
Extract clips from videos
import os
from moviepy.video.io.ffmpeg_tools import ffmpeg_extract_subclip
OUTPUT_DIRECTORY = 'done'
clips = [
{'output': 'baby_peek_a_boo.mp4', 'input': 'baby_peek_a_boo.mp4', 'start': 0, 'end': 23},
{'output': 'tickle_me_elmo.mp4', 'input': 'tickle_me_elmo.mp4', 'start': 39, 'end': 74},
//... As many clips as you need
{'output': 'slapstick.mp4', 'input': 'slapstick.mp4', 'start': 6, 'end': 91},
]
for clip in clips:
ffmpeg_extract_subclip(
clip['input'],
clip['start'],
clip['end'],
targetname=os.path.join(OUTPUT_DIRECTORY, clip['output']),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment