-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
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
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() |
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
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.