Skip to content

Commit

Permalink
housekeeping
Browse files Browse the repository at this point in the history
  • Loading branch information
JiaYee committed Jun 10, 2023
1 parent 1ee7310 commit 71ed83a
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
24 changes: 24 additions & 0 deletions cut 59secs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import os
from moviepy.video.io.VideoFileClip import VideoFileClip
from datetime import datetime

# Iterate through files in current directory
for filename in os.listdir('.'):
if filename.endswith('.mp4'):
# Get current timestamp
timestamp = datetime.now().strftime("%Y%m%d%H%M%S")

# Load video file clip
video = VideoFileClip(filename)

# Cut first 59 seconds
short_video = video.subclip(0, 59)

# Define output filename based on timestamp
output_filename = timestamp + '_shorts.mp4'

# Save short video to file
short_video.write_videofile(output_filename)

# Close video file clip
video.close()
12 changes: 12 additions & 0 deletions cut last 3secs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import os
import moviepy.editor as mp
from datetime import datetime

# loop through all mp4 files in the same directory
for filename in os.listdir():
if filename.endswith(".mp4"):
clip = mp.VideoFileClip(filename)
clip = clip.subclip(0, -3) #remove last 3 secs
timestamp = datetime.now().strftime("%Y%m%d%H%M%S") #get timestamp
new_filename = timestamp + ".mp4" #use timestamp as filename
clip.write_videofile(new_filename) #write the new video
File renamed without changes.

0 comments on commit 71ed83a

Please sign in to comment.