Last active
June 5, 2021 08:18
-
-
Save mniami/b6b3f5f6bbba7565568de727978d9093 to your computer and use it in GitHub Desktop.
Movie processing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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