Skip to content

Instantly share code, notes, and snippets.

@mniami
Last active June 5, 2021 08:18
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 mniami/b6b3f5f6bbba7565568de727978d9093 to your computer and use it in GitHub Desktop.
Save mniami/b6b3f5f6bbba7565568de727978d9093 to your computer and use it in GitHub Desktop.
Movie processing
import click
from moviepy.editor import *
from natsort import natsorted
@click.command()
@click.argument("path")
@click.argument("output-file-name")
def combine_movies(path: str, output_file_path: str):
if path is None:
path = input("Path to the movie files:\n")
if output_file_path is None:
output_file_path = input("Output file path:\n")
video_clips = []
for root, dirs, files in os.walk(path):
files = natsorted(files)
for file in files:
if os.path.splitext(file)[1].lower() in ['.mp4', '.mov']:
file_path = os.path.join(root, file)
video = VideoFileClip(file_path)
video_clips.append(video)
final_clip = concatenate_videoclips(video_clips)
final_clip.to_videofile(output_file_path, fps=video_clips[0].fps, remove_temp=True)
if __name__ == '__main__':
combine_movies()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment