0

I am trying to make a python script that can use a given background video and apply a time countdown overlay, making a countdown video. This is like the automated reedit videos we see on TikTok. Here is an example of what I am aiming to make it look like.https://youtu.be/Xyu8lRmR1NY. I want there to be multiple video outputs as different times of countdown(Ex : 1 minute timer, 5 minute timer, 10 minute timer). I found this code that could be some help in chopping the video.

from moviepy.editor import *

video = VideoFileClip("backVid.mp4").subclip(50,60)

# Make the text. Many more options are available.
txt_clip = ( TextClip("My Holidays 2013",fontsize=70,color='white')
             .set_position('center')
             .set_duration(10) )

result = CompositeVideoClip([video, txt_clip]) # Overlay text on video
result.write_videofile("myHolidays_edited.webm",fps=25)

Any help in direction is good.

  • you have to only put it in `for`-loop to create text with different numbers and different start time - `set_start(...)` – furas Aug 27 '22 at 03:10

1 Answers1

0

You have to only put it in for-loop to create text with different numbers and different start time - .set_start(...) - and every text display only 1 second

from moviepy.editor import *

# --- background video ---

video = VideoFileClip("backVid.mp4").subclip(50, 70)  # 20 seconds

all_clips = [video]

# --- countdown text ---

for number in range(10, 0, -1):  # 10 seconds (10 x 1 second)
    txt_clip = ( TextClip( str(number), fontsize=70, color='white')
                 .set_position('center')
                 .set_duration(1)
                 .set_start(10 - number) )  # 1 second
    all_clips.append(txt_clip)
    
# --- final text ---

txt_clip = ( TextClip("My Holidays 2013",fontsize=70,color='white')
             .set_position('center')
             .set_duration(10)
             .set_start(10) )  # 10 seconds
all_clips.append(txt_clip)

# --- create one video ---

result = CompositeVideoClip(all_clips)

result.write_videofile("myHolidays_edited.webm", fps=25)
furas
  • 134,197
  • 12
  • 106
  • 148