Skip to content

Instantly share code, notes, and snippets.

@Kabongosalomon
Last active August 7, 2021 19:44
Show Gist options
  • Save Kabongosalomon/e4bcaf323459f247b75bffa48a128689 to your computer and use it in GitHub Desktop.
Save Kabongosalomon/e4bcaf323459f247b75bffa48a128689 to your computer and use it in GitHub Desktop.
Whatsapp status 30s splitter :).
#!/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)
@Kabongosalomon
Copy link
Author

You need to install the follow packages:

  • pip install moviepy

On some linux system you need to run as well conda install -c conda-forge ffmpeg.

How to use :

python whatsapp_status_spliter.py -input_file /mnt/c/Users/Kabongo/Music/Whatsapp/law_tradition.mp4 -output_path /mnt/c/Users/Kabongo/Music/Whatsapp/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment