Skip to content

Instantly share code, notes, and snippets.

@Pymmdrza
Created March 1, 2024 12:44
Show Gist options
  • Save Pymmdrza/2148379f658bdd211bbab65d1b758905 to your computer and use it in GitHub Desktop.
Save Pymmdrza/2148379f658bdd211bbab65d1b758905 to your computer and use it in GitHub Desktop.
Video Cut On Python
# // Windows : pip install moviepy colorthon
# // Linux : pip3 install moviepy colorthon
from moviepy.video.io.VideoFileClip import VideoFileClip
from colorthon import Colors as Fore
def cutVideo(inputFile, outputFile, startTime, endTime):
video = VideoFileClip(inputFile, verbose=False)
newVideo = video.subclip(startTime, endTime)
newVideo.write_videofile(outputFile, verbose=False)
video.close()
newVideo.close()
input_file = str(input("[+] Enter Input File Name: "))
output_file = str(input("[+] Enter Output File Name: "))
start_time = int(input("[+] Enter Start Time: "))
end_time = int(input("[+] Enter End Time: "))
confirm = str(input("[+] Confirm [Y] or Unconfirm [N]: "))
if confirm.lower() == "n":
exit()
else:
print(f"{Fore.GREEN}-{Fore.RESET} {Fore.CYAN}Source File{Fore.RESET} : {Fore.MAGENTA}{input_file}{Fore.RESET}")
print(f"{Fore.GREEN}-{Fore.RESET} {Fore.YELLOW}Output File{Fore.RESET} : {Fore.YELLOW} {output_file}{Fore.RESET}")
print(f'- Cut Video From {Fore.RED}{start_time}{Fore.RESET} To {Fore.RED}{end_time}{Fore.RESET}')
cutVideo(input_file, output_file, start_time, end_time)
print(f"{Fore.GREEN}[+] Done!{Fore.RESET}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment