Automate the creation of short-form videos (TikTok, YouTube Shorts, Instagram Reels) by combining narrated Reddit stories with background footage and synchronized captions, all through a simple web interface.
- Web UI: Easy-to-use interface built with Flask and Tailwind CSS for selecting subreddits, background videos, and initiating generation.
- Multi-Platform Compatibility: Outputs 9:16 vertical videos.
- Reddit Integration: Scrapes stories using PRAW.
- AI Narration: Converts text (with 'AITA' and age/gender substitutions) to speech using gTTS.
- Accurate Captions: Uses OpenAI Whisper to generate word-level timestamps for precise caption synchronization.
- Dynamic Title Card: Draws the post title onto a provided template image, adapting font size.
- Background Options: Choose from multiple background videos (Minecraft, GTA, Subway Surfer).
- Layered Audio: Mixes narration with adjustable background music volume.
- Automated Video Creation: Combines background video, title card, narration, music, and timed captions using MoviePy.
- Real-time Progress: Monitor the generation process with a detailed progress bar and logs in the web UI.
- Direct Download & Replay: Download the generated video or watch it directly in the browser on completion.
- Git LFS: Handles large background video files efficiently.
- Frontend Interaction: User selects subreddit, background video, and music volume via the web interface served by Flask.
- Trigger: Submitting the form sends a POST request to the
/generate
endpoint. - Backend Pipeline (run_pipeline in main.py):
a. Story Selection: Fetches a random, popular story from the chosen subreddit.
b. Narration Generation: Cleans text (substitutions) and generates MP3 audio using gTTS.
c. Timestamp Generation: Uses Whisper to get word timestamps from the narration.
d. Title Card Creation: Dynamically draws the title on
title_template.png
. e. Caption Image Generation: Creates transparent PNGs for caption chunks based on timestamps. f. Video Assembly (create_video in video_creator.py): Combines chosen background video (via Git LFS), music, title card, and captions using MoviePy. - Progress Tracking: The Flask app captures logs and updates progress status via a queue.
- Frontend Polling: The web UI periodically polls the
/status
endpoint to update the progress bar, logs, and current step. - Result Display: Upon completion, the UI shows a success message, an embedded video player, and download/retry buttons.
- Python: Core backend language.
- Flask: Web framework and API.
- PRAW: Reddit API integration.
- gTTS: Text-to-Speech generation.
- openai-whisper: Audio transcription and word-level timestamp generation.
- Pillow (PIL Fork): Image manipulation (drawing title, creating captions).
- MoviePy: Video and audio editing/compositing.
- python-dotenv: Environment variable management.
- Frontend:
- HTML: Structure.
- Tailwind CSS: Styling.
- JavaScript: Interactivity, API calls, progress updates.
- Git LFS: For managing large background video files.
- FFmpeg: Essential backend for MoviePy and Whisper (must be installed separately).
- Clone the repository:
git clone <repository-url> cd <repository-directory>
- Install Git LFS:
- Download and install Git LFS from git-lfs.github.com or use a package manager.
- Initialize LFS for your user account (run once):
git lfs install
- Pull the large files tracked by LFS:
git lfs pull
- Create & Activate Virtual Environment:
python -m venv venv # Windows: .\venv\Scripts\activate # macOS/Linux: source venv/bin/activate
- Install FFmpeg:
- Download FFmpeg from ffmpeg.org.
- Ensure the
ffmpeg
executable is in your system's PATH.
- Install Python Dependencies:
pip install -r requirements.txt # Note: Whisper installation might take time as it includes PyTorch.
- Set up Reddit API Credentials:
- Create a
.env
file in the root directory (where README.md is). - Add your credentials:
REDDIT_CLIENT_ID='your_client_id' REDDIT_CLIENT_SECRET='your_client_secret' REDDIT_USER_AGENT='your_user_agent' # e.g., 'ReelitApp by u/your_username'
- Create a
- Prepare Assets (Verify):
- The
assets/
directory should contain:background_gta.webm
(via Git LFS)background_minecraft.webm
(via Git LFS)background_subway_surfer.webm
(via Git LFS)background_music.mp3
(Your background music)title_template.png
(Your title card template)Inter-Bold.ttf
(Or your desired font file - update path insrc/video_creator.py
if different)
- The
- Start the Server:
- Navigate to the
src
directory:cd src
- Run the Flask app:
python app.py
- Keep this terminal running. It will show backend logs.
- Navigate to the
- Open the Web UI:
- Open your web browser and go to
http://127.0.0.1:5000
(or the address shown in the terminal).
- Open your web browser and go to
- Generate Video:
- Enter a subreddit name.
- Select a background video.
- Adjust the music volume if desired.
- Click "Generate Video".
- Monitor & Retrieve:
- Watch the progress bar and logs directly in the web UI.
- The first run might take longer as it downloads the Whisper model (
tiny.en
by default). - Once complete, the video player will appear.
- Watch the video, download it, or generate another.
- Final videos are also saved in the
output/
directory.
- Background Videos: Add more
.webm
files toassets/
, update theBACKGROUND_VIDEOS
dictionary insrc/app.py
, and potentially track them withgit lfs track "*.webm"
. - Title Card Text: Adjust font size range, color, boundary box in
draw_title_on_template
withinsrc/video_creator.py
. - Caption Style: Modify font, size, colors, outline in
create_subtitle_image
withinsrc/video_creator.py
. - Caption Grouping: Adjust
MAX_WORDS_PER_CAPTION
orMIN_GAP_BETWEEN_CAPTIONS
increate_video
withinsrc/video_creator.py
. - Whisper Model: Modify
model_name
inget_word_timestamps
call withinsrc/main.py
(e.g., to "base.en" for potentially better accuracy but slower speed). - Progress Steps/Weights: Modify the
PIPELINE_STEPS
dictionary insrc/app.py
and update corresponding UI elements/logic if needed. - UI Styling: Modify
src/templates/index.html
(Tailwind CSS classes) andsrc/static/js/script.js
.