Skip to content

Autonomous AI pipeline that transforms Reddit stories into viral TikTok/YouTube Shorts. Features LLM-powered content curation, neural voice synthesis, and automated video composition. Built with Python, MoviePy, and Edge-TTS.

License

Notifications You must be signed in to change notification settings

indiser/ViralContent-Factory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎬 ViralContent Factory

Autonomous AI-Powered Viral Content Generation Pipeline

Python MoviePy Edge TTS License

Fully automated Reddit story scraping β†’ AI voice synthesis β†’ viral short-form video generation

Features β€’ Architecture β€’ Installation β€’ Usage β€’ Tech Stack


πŸš€ Overview

ViralContent Factory is an end-to-end automated content generation system that transforms Reddit stories into professionally edited, viral-ready short-form videos for TikTok, YouTube Shorts, and Instagram Reels. The pipeline handles everything from content discovery to final video rendering with zero manual intervention.

πŸ’‘ What Makes This Special?

  • πŸ€– Fully Autonomous: Set it and forget it. The system runs daily via scheduled tasks
  • 🧠 AI-Powered Intelligence: LLM-driven gender detection, viral hook generation, and content filtering
  • 🎯 Production-Ready: Includes failover systems, cold storage backups, and email alerting
  • ⚑ Optimized Performance: Multi-threaded rendering, smart caching, and resource management
  • πŸ“Š Scalable Architecture: Modular phase-based design for easy extension and maintenance

✨ Features

πŸ” Phase 1: Intelligent Content Acquisition

  • Multi-Source Scraping: Waterfall system across 10+ high-engagement subreddits (AITA, TIFU, TrueOffMyChest, etc.)
  • Smart Filtering:
    • Language detection (English-only)
    • Optimal word count (120-200 words for 60-second videos)
    • Duplicate prevention via persistent database
    • Automatic removal of deleted/removed posts
  • AI Enhancement:
    • LLM-powered gender detection for voice matching
    • Viral hook generation (transforms boring titles into scroll-stopping openers)
    • Slang/acronym normalization (AITA β†’ "Am I the jerk", etc.)
  • Failover System: Falls back to local cold storage if all live sources fail

πŸŽ™οΈ Phase 2: Professional Audio Synthesis

  • Edge TTS Integration: Microsoft's neural voices for natural-sounding narration
  • Dynamic Voice Selection: Gender-matched voices (3 female variants, 1 male)
  • Word-Level Timing: Precise timestamp extraction for perfect subtitle synchronization
  • Fallback Mechanisms: Sentence-level heuristics if word boundaries fail

πŸŽ₯ Phase 3: Viral Video Composition

  • 9:16 Vertical Format: Optimized for mobile-first platforms
  • Dynamic Background Selection: Random gameplay footage (Minecraft, GTA 5)
  • Animated Subtitles:
    • Impact font with stroke for maximum readability
    • 2-word chunks with pop-in animations
    • Mathematically synced to audio timestamps
  • Smart Cropping: Automatic center-crop from 16:9 to 9:16
  • Random Start Points: Prevents repetitive background footage

πŸ”§ Production Features

  • Automated Cleanup: Removes temporary files after each run
  • Batch Management: Collects 7 videos before triggering upload alert
  • Email Notifications: Gmail SMTP alerts when batch is ready
  • Sanitized Filenames: OS-safe naming with ID-based uniqueness
  • Error Handling: Comprehensive try-catch blocks with detailed logging

πŸ—οΈ System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    MAIN PIPELINE ORCHESTRATOR                β”‚
β”‚                     (main_pipeline.py)                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
             β”‚
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚                 β”‚
    β–Ό                 β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Phase 1 │──────│ Phase 2 β”‚
β”‚ Scraper β”‚      β”‚  Audio  β”‚
β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
     β”‚                β”‚
     β”‚                β–Ό
     β”‚           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
     β”‚           β”‚ Phase 3 β”‚
     └───────────│  Video  β”‚
                 β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
                      β”‚
                      β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚  Cleanup &    β”‚
              β”‚  Notification β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ Project Structure

ViralContent/
β”œβ”€β”€ πŸ“œ main_pipeline.py      # Orchestrator - coordinates all phases
β”œβ”€β”€ πŸ” phase1.py             # Content acquisition & AI processing
β”œβ”€β”€ πŸŽ™οΈ phase2.py             # Audio synthesis & timestamp extraction
β”œβ”€β”€ πŸŽ₯ phase3.py             # Video composition & rendering
β”œβ”€β”€ πŸ“₯ yt_downloader.py      # Background footage downloader
β”œβ”€β”€ πŸ“§ reminder.py           # Batch management & email alerts
β”œβ”€β”€ βš™οΈ run_factory.bat       # Windows Task Scheduler entry point
β”œβ”€β”€ πŸ“¦ requirements.txt      # Python dependencies
β”œβ”€β”€ πŸ—„οΈ scripts.json          # Persistent story database
β”œβ”€β”€ 🎬 downloads/            # Background video assets
└── πŸ“€ reels/                # Final rendered videos

πŸ› οΈ Tech Stack

Category Technology Purpose
Language Python 3.11+ Core runtime
AI/LLM OpenRouter API Gender detection & hook generation
Voice Synthesis Edge-TTS Neural text-to-speech
Video Processing MoviePy 1.0.3 Compositing & rendering
Image Processing ImageMagick Text rendering backend
Web Scraping Requests Reddit API interaction
NLP langdetect Language filtering
Video Download yt-dlp Background footage acquisition
Email smtplib Gmail notifications
Environment python-dotenv Secure credential management

πŸ“¦ Installation

Prerequisites

# Required System Dependencies
- Python 3.11 or higher
- FFmpeg (for audio/video processing)
- ImageMagick (for subtitle rendering)
- Deno or Node.js (for yt-dlp)

Step 1: Clone the Repository

git clone https://github.com/indiser/ViralContent-factory.git
cd ViralContent-factory

Step 2: Install Python Dependencies

pip install -r requirements.txt

Step 3: Install System Dependencies

Windows (via winget):

winget install Gyan.FFmpeg
winget install ImageMagick.ImageMagick
winget install DenoLand.Deno

macOS (via Homebrew):

brew install ffmpeg imagemagick deno

Linux (Ubuntu/Debian):

sudo apt update
sudo apt install ffmpeg imagemagick
curl -fsSL https://deno.land/install.sh | sh

Step 4: Configure Environment Variables

Create a .env file in the project root:

# OpenRouter API (for LLM features)
OPENROUTER_API_KEY=your_openrouter_api_key_here

# Gmail SMTP (for notifications)
EMAIL_USER=your_email@gmail.com
EMAIL_APP_PASS=your_gmail_app_password

Note: For Gmail, you need to generate an App Password (not your regular password)

Step 5: Download Background Videos

python yt_downloader.py "https://youtube.com/watch?v=MINECRAFT_VIDEO_ID"
python yt_downloader.py "https://youtube.com/watch?v=GTA5_VIDEO_ID"

Or manually place 9:16 or 16:9 gameplay videos in the downloads/ folder.

Step 6: Configure ImageMagick Path (Windows Only)

Edit phase3.py line 5 to match your ImageMagick installation:

os.environ["IMAGEMAGICK_BINARY"] = r"C:\Program Files\ImageMagick-7.1.2-Q16-HDRI\magick.exe"

🎯 Usage

Manual Execution

python main_pipeline.py

Automated Daily Execution (Windows)

  1. Open Task Scheduler
  2. Create a new task:
    • Trigger: Daily at 3:00 AM
    • Action: Run run_factory.bat
  3. The system will automatically:
    • Generate 1 video per day
    • Collect 7 videos per week
    • Send email alert when batch is ready

Batch Management

python reminder.py

This checks if 7+ videos are ready and moves them to ready_to_upload/ folder.


πŸ“Š Workflow Example

1. [03:00 AM] Task Scheduler triggers run_factory.bat
2. [03:00:05] Phase 1 scrapes r/AmItheAsshole
3. [03:00:12] LLM generates viral hook: "Am I the jerk for refusing to attend my sister's wedding"
4. [03:00:15] Gender detected: Female β†’ Voice: en-US-AriaNeural
5. [03:00:45] Phase 2 generates audio + word timestamps
6. [03:01:30] Phase 3 renders 60-second vertical video
7. [03:02:00] Cleanup removes temporary files
8. [03:02:05] Reminder script checks inventory (3/7 videos)
9. [Day 7] Email sent: "🟒 FACTORY ALERT: Weekly Batch Ready"

🎨 Customization

Add More Subreddits

Edit phase1.py:

SUBREDDITS = [
    "AmItheAsshole",
    "YourNewSubreddit",  # Add here
]

Change Voice Models

Edit phase2.py:

WOMAN_VOICE_LIST = [
    "en-US-JennyNeural",
    "en-GB-SoniaNeural",  # Add British accent
]

Adjust Video Length

Edit phase1.py line 175:

if 120 < len(words) < 200:  # Change word count range

Modify Subtitle Style

Edit phase3.py lines 50-60:

txt_clip = TextClip(
    chunk_text,
    font="Arial",           # Change font
    fontsize=100,           # Increase size
    color="yellow",         # Change color
    stroke_width=8,         # Thicker outline
)

πŸ› Troubleshooting

Issue: "ImageMagick not found"

Solution: Update the path in phase3.py line 5 to match your installation

Issue: "No viable stories found"

Solution: The subreddit may have no posts matching criteria. The system will automatically try the next subreddit

Issue: "FFmpeg not found"

Solution: Ensure FFmpeg is in your system PATH. Run ffmpeg -version to verify

Issue: "Email sending failed"

Solution:

  1. Enable 2FA on Gmail
  2. Generate an App Password
  3. Use the App Password in .env, not your regular password

Issue: "Word boundaries missing"

Solution: The system automatically falls back to sentence-level timing. This is expected behavior for some voices


πŸ“ˆ Performance Metrics

  • Average Runtime: 2-3 minutes per video
  • Video Quality: 1080x1920 @ 30fps
  • Audio Quality: 192kbps MP3
  • Storage: ~15-25MB per final video
  • Success Rate: 95%+ (with failover systems)

πŸ”’ Security & Privacy

  • βœ… No user data collection
  • βœ… API keys stored in .env (gitignored)
  • βœ… Reddit scraping complies with API terms
  • βœ… All content is public domain (Reddit posts)
  • βœ… No personal information in generated videos

🚧 Roadmap

  • Multi-platform upload automation (TikTok, YouTube, Instagram APIs)
  • A/B testing for hooks and thumbnails
  • Analytics dashboard (views, engagement tracking)
  • GPU-accelerated rendering (NVENC support)
  • Cloud deployment (AWS Lambda + S3)
  • Web UI for manual overrides
  • Multi-language support (Spanish, French, etc.)

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments

  • Reddit API - Content source
  • Microsoft Edge TTS - Neural voice synthesis
  • OpenRouter - LLM infrastructure
  • MoviePy - Video processing framework
  • yt-dlp - Video download utility

πŸ“ž Contact

Project Link: [https://github.com/indiser/ViralContent-Factory]


⭐ If this project helped you, please consider giving it a star!

Made with ❀️ and Python

About

Autonomous AI pipeline that transforms Reddit stories into viral TikTok/YouTube Shorts. Features LLM-powered content curation, neural voice synthesis, and automated video composition. Built with Python, MoviePy, and Edge-TTS.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published