Last active
August 7, 2021 19:44
-
-
Save Kabongosalomon/e4bcaf323459f247b75bffa48a128689 to your computer and use it in GitHub Desktop.
Whatsapp status 30s splitter :).
This file contains 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
#!/usr/bin/env python | |
""" | |
Whatsapp status 30s splitter by Salomon Kabongo | |
""" | |
import argparse | |
import os | |
import moviepy.editor as mpy | |
def edit_video(file_path, output_path="./"): | |
# load file | |
video = mpy.VideoFileClip(file_path) | |
duration = video.duration | |
title = file_path.split(".")[-2].split("/")[-1] | |
for count, cut in enumerate(range(0, int(duration), 30)): | |
if (30+cut <= duration): | |
clip = video.subclip(t_start=0+cut, t_end=30+cut) | |
else: | |
clip = video.subclip(t_start=0+cut) | |
result = mpy.CompositeVideoClip([clip]) # Overlay text on video | |
result.write_videofile(f"{output_path}{title}_{count}.mp4", | |
# fps=60, | |
audio_codec='aac') # Many options... | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser(description="Run the Whatsapp status spliter") | |
parser.add_argument("-input_file", default="./law_vs_tradition.mp4", help="Path to the input file") | |
parser.add_argument("-output_path", default='./', help="Output path") | |
args = parser.parse_args() | |
if not os.path.exists(args.output_path): | |
os.makedirs(args.output_path) | |
edit_video(file_path = args.input_file, output_path = args.output_path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to install the follow packages:
On some linux system you need to run as well
conda install -c conda-forge ffmpeg
.How to use :