This Python script provides a simple graphical user interface (GUI) for generating lightweight countdown videos with a customizable text overlay. It's designed for quick, one-click video creation for events, streams, or any scenario where a simple countdown is needed.
- GUI-based: Easy to use with a friendly interface.
- Customizable Countdown: Set the total duration of the countdown.
- Text Overlay: Add a custom one-line or multi-line text message above the countdown.
- Background Image Support: Use your own image as the video background or opt for a plain black background.
- Adjustable Resolution: Define the output video dimensions (e.g., for vertical videos like stories/reels).
- Flexible Text Positioning: Place the countdown timer in the center, top-left, top-right, bottom-left, bottom-right, or top-center.
- Customizable Font Color and Margin: Control the appearance of the text.
- Video Encoding Options: Adjust CRF (quality), preset (speed/compression), and tune (content type) for optimal output.
- AI-Generated Code: Most parts of this software were generated by an AI assistant.
- Security: The author has informally confirmed the software do not do anything harmfull, through a code investigation and my own daily use, howerver:
- No Warranty: This software is provided "as-is" without any warranty, express or implied, as is common with most Open Source Software (OSS) products. Use at your own risk.
To run this script, you need Python 3 and a few libraries.
-
Install Python 3: If you don't have Python installed, download it from python.org. Make sure to check "Add Python to PATH" during installation.
-
Install Dependencies: Open your terminal or command prompt and run the following command to install all necessary libraries:
pip install moviepy Pillow numpy tkinter
moviepy: For video editing and generation.Pillow: For image manipulation (used in creating frames).numpy: For numerical operations on image data.tkinter: (Usually comes with Python) For the graphical user interface.
-
Save the Script: Save the provided Python code as a
.pyfile (e.g.,countdown_generator.py). -
Run the Script: Open your terminal or command prompt, navigate to the directory where you saved the script, and run it using:
python countdown_generator.py
-
Use the GUI: A window titled "Countdown Video Generator" will appear.
- Output Filename: Specify the name for your generated video file (e.g.,
my_countdown.mp4). - Video Duration (seconds): Enter the total length of your countdown in seconds (e.g.,
3600for 1 hour). - Background Image (PNG/JPG): Optionally, click "Browse" to select an image file to use as the video background. If left blank, the background will be black.
- Resolution (WIDTHxHEIGHT): Set the desired video resolution (e.g.,
624x912for a vertical video). - Top Text: Enter the text you want to appear above the countdown. Use
\nfor a new line (e.g., "Time remaining until\nthe event"). - Font Color: Enter a hex color code (e.g.,
#fffffffor white), a named color (e.g.,red), or click "Select Color" for a color picker. - CRF (Quality): Constant Rate Factor for video quality. Lower values mean higher quality and larger file sizes (e.g.,
23is a good balance). - Preset (Speed/Compression): Controls encoding speed vs. file size.
veryslowprovides the best compression,ultrafastis fastest. - Tune (Content): Optimizes encoding for specific content (e.g.,
fastdecodefor quicker playback,stillimagefor static backgrounds). - Counter Position: Choose where the countdown timer appears on the screen.
- Margin (px, %): If the counter is in a corner or
top-centerposition, this sets the distance from the edges (e.g.,48pxor5%).
- Output Filename: Specify the name for your generated video file (e.g.,
-
Generate Video: Click the "Generate Video" button. You will see a confirmation message when the generation starts and another when it completes. The output video will be saved in the same directory as your script, or the specified path in the "Output Filename" field.