Created
October 31, 2024 02:26
-
-
Save koorukuroo/1aee0dc78e1da86a1cd52df3b404d139 to your computer and use it in GitHub Desktop.
4k_5min_countdown.py
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
from moviepy.editor import VideoClip, TextClip | |
from tqdm import tqdm | |
def make_frame(t): | |
# Calculate remaining time in minutes and seconds | |
remaining_time = max(0, int(5*60 - t)) | |
minutes, seconds = divmod(remaining_time, 60) | |
time_str = f"{minutes:01d}:{seconds:02d}" | |
# Create TextClip for the countdown with 4K resolution | |
W, H = 3840, 2160 # 4K resolution | |
txt_clip = TextClip( | |
time_str, | |
fontsize=400, | |
color='white', | |
font='Arial-Bold', | |
size=(W, H), | |
method='label' | |
).set_position('center') | |
# Return the frame for this time | |
return txt_clip.get_frame(t) | |
# Create the VideoClip with a single make_frame function | |
countdown_duration = 5 * 60 # 5 minutes in seconds | |
video = VideoClip(make_frame, duration=countdown_duration).set_fps(24) | |
# Export the video file with 20 threads for parallel processing in 4K quality | |
video.write_videofile("4k_countdown_300.mp4", fps=24, threads=20) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment