Infinite content, zero manual editing. A fully automated 'faceless' video factory that turns trending topics into engaging YouTube Shorts using Gemini AI, Edge-TTS, and dynamic FFmpeg editing
Last updated Jul 8, 2026
169
Stars
40
Forks
0
Issues
+4
Stars/day
Attention Score
78
Topics
Language breakdown
No language data available.
โธ Files
click to expand
README
๐ฌ AutoShorts AI: The Automated Faceless Video Generator
AutoShorts AI is a Python pipeline that creates viral-style "Faceless" YouTube Shorts and TikToks from a topic. It handles the production chain: AI topic/script generation, voiceover generation, stock footage sourcing, and FFmpeg editing with transitions and avatar injection.
โจ Key Features
- ๐ง Intelligent Scriptwriting: Uses Google Gemini 2.0 Flash to write engaging, "Edutainment" style scripts (Vox/Kurzgesagt style) with strict storytelling structures (Hook โ Context โ Mechanism โ Twist).
- ๐ฃ๏ธ Voiceovers: Generates narration with
edge-tts. - ๐๏ธ Dual-Visual System: Automatically searches and downloads two distinct stock videos per scene from Pexels, creating a dynamic "A/B Split" visual style to maximize viewer retention.
- โ๏ธ Advanced FFmpeg Editing:
- Smart Trimming: Syncs video perfectly to audio duration.
- A/B Splitting: Cuts every scene in half, switching visuals mid-sentence.
- Pro Transitions: Randomly applies
xfade(fade, slide, wipes) between scenes. - Silence Removal: Automatically trims dead air from AI voice generation.
- ๐ค Random Avatar Injection: Automatically inserts a custom "Avatar/Mascot" video into a random middle scene to build channel brand identity.
- ๐ช Windows Ready: Includes specific FFmpeg flags (
yuv420p,faststart) to prevent corruption errors (0x80004005) on Windows Media Player.
๐ Project Structure
Automated-YT-Shorts-AI/
โ
โโโ assets/ # Stores all media files
โ โโโ audio_clips/ # Generated voiceovers (.wav)
โ โโโ video_clips/ # Downloaded stock footage (.mp4)
โ โโโ temp/ # Intermediate processing files
โ โโโ final/ # ๐ The Final Output Video lives here
โ โโโ avatar/ # โ ๏ธ PUT YOUR AVATAR VIDEO HERE
โ โโโ ProfessionalGirlAnimationVideoGeneration.mp4
โ
โโโ modules/ # Core Logic Modules
โ โโโ brain.py # AI Scriptwriter (Gemini)
โ โโโ audio.py # Voice generator (edge-tts)
โ โโโ asset_manager.py # Pexels Downloader (Dual-Visual logic)
โ โโโ composer.py # FFmpeg Video Editor (Stitching & Transitions)
โ
โโโ main.py # Entry point (Orchestrator)
โโโ requirements.txt # Python dependencies
๐ ๏ธ Prerequisites
- Python 3.10+ installed.
- FFmpeg installed and added to your system PATH.
- Windows:
winget install ffmpeg(or download from ffmpeg.org). - Verify: Type
ffmpeg -versionin your terminal.
- API Keys:
- Google Gemini API Key (Free tier available).
- Pexels API Key (Free).
- No Ngrok token is required for the default voiceover path. The current pipeline uses
edge-tts.
๐ Installation
1. Clone the Repository
git clone https://github.com/yourusername/AutoShorts-AI.git
cd AutoShorts-AI
2. Install Dependencies
pip install -r requirements.txt
3. Environment Setup
Create the required folders and add your avatar:
- Create folder:
assets/avatar - Place your avatar video inside and name it:
avatars.mp4
4. Configure API Keys
Copy .env.example to .env and fill in your key:
cp .env.example .env
Required:
GEMINIAPIKEYfor script generationPEXELSAPIKEYfor stock video search/download
GEMINI_MODELto override the defaultgemini-2.0-flashmodel
๐ฎ How to Run
Generate Video
Run the main script:
python main.py
- Enter a topic (e.g., "The Mystery of the Pyramids").
- Wait for the AI to write the script, generate audio, download stock footage, and edit the video.
- The final video will be saved in
assets/final/final_short.mp4.
๐งฉ Module Breakdown
brain.py ( The Writer)
- Input: Topic string.
- Logic: Prompts Gemini to create an 8-9 scene JSON script. It asks for two visual keywords per scene (
visual1,visual2) to enable the A/B split effect.
audio.py (The Voice)
- Input: Text script.
- Logic: Generates MP3 voice clips with
edge-tts. - Post-Processing: Reads durations with
mutagenso scenes can be synced to audio length.
asset_manager.py (The Librarian)
- Input: Visual keywords.
- Logic: Searches Pexels for Portrait (9:16) videos. Downloads pairs of videos for every scene. Handles fallbacks (if Video B is missing, reuse Video A).
composer.py (The Editor)
- Input: Audio files + Video files.
- Logic:
- Scene Processing: Cuts the scene duration in half. Plays Video A for the first half, Video B for the second half.
- Avatar Injection: Identifies a random "middle" scene (not hook/outro) and replaces the stock footage with your Avatar loop.
- Stitching: Merges all scenes using
xfadetransitions (wipes, slides). - Rendering: Exports as
yuv420pH.264 MP4 withfaststartflags for maximum compatibility.
โ ๏ธ Troubleshooting
Q: The video is black or corrupt (0x80004005 error).
- Fix: This is usually a Windows codec issue. The updated
composer.pyforcespix_fmt='yuv420p'. Try opening the file with VLC Media Player.
- Fix: Ensure your folder structure is exactly
assets/avatar/avatars.mp4.
- Fix: Check your internet connection and that
edge-ttsis installed fromrequirements.txt.
- Fix: Ensure FFmpeg is installed and accessible from your command line.
๐ License
This project is open-source. Feel free to modify and build your own automation empire!
๐ More in this category