Local-TikTok-Factory

A fully local, self-running pipeline that scrapes Reddit, rewrites stories as short-form scripts, generates voice + karaoke subtitles, and renders 9:16 MP4 videos for TikTok, YouTube Shorts, and Instagram Reels — no cloud APIs required.

Overview

Local-TikTok-Factory is an autonomous video factory. It scrapes Reddit for stories, uses a local LLM to rewrite them into short-form scripts, generates narration with TTS and karaoke subtitles aligned to the audio, then renders the result as a vertical 9:16 MP4 — all on your own hardware. Comes with a web dashboard for monitoring the pipeline, generating videos on demand, and tuning prompts.

Architecture

All pipeline stages run as threads inside a single Python daemon process (factory.py). Redis carries jobs between stages using a reliable queue pattern (atomic BLMOVE) so no job is ever silently lost — even on hard kill.

  • Scraper: Selenium/Chromium → Reddit, with 4 fallback scraping strategies if the primary selector set breaks → pushes stories to scoring queue
  • Scorer/Rewriter: Ollama LLM (3 parallel workers) scores and rewrites stories as scripts
  • TTS: 3 interchangeable engines — Kokoro / pyttsx3 / espeak-ng — generate narration audio
  • Subtitles: Whisper/WhisperX aligns text to audio with word-level timing → ASS karaoke highlighting
  • Renderer: FFmpeg composites into 9:16 MP4
  • Monitor: Reports queue stats every 60s; dead threads auto-restarted

A separate FastAPI service (web/server.py) reads and writes the same Redis structures to provide a live control panel with Server-Sent Events for real-time progress. Runs via Docker Compose with optional GPU passthrough for Whisper/TTS.

Web Dashboard

A zero-auth, local-only control panel at http://localhost:8080:

  • Dashboard: Live queue depths, active/orphaned job inspection with recovery controls, config editor, quick actions (Run Cycle Now, Restart, Reset)
  • Videos: Browse, search, sort, filter, organize into folders, and delete finished videos
  • Video detail: Play the video, view/edit its script, or remake it (re-runs TTS → subtitles → render on edited script)
  • Generate: Manually kick off a new video from a Reddit URL or pasted text, with live SSE progress
  • Prompts: Edit the LLM scoring and rewriting prompts and upload reference files
  • Logs: Tail factory, Ollama, and Redis logs from the browser

Technologies

Python Redis Selenium Ollama Kokoro Whisper FFmpeg FastAPI Docker vibe coded

Interesting Details

  • Reliable queue pattern using Redis BLMOVE: each pop atomically moves a job into a per-queue processing list, so hard-killed workers never lose jobs
  • Orphaned job detection: workers killed mid-job leave visible "orphaned" entries that can be re-launched from the dashboard
  • Multi-part thread generator: splits one long Reddit post into several "Part N" videos with independent progress tracking
  • Remake flow: edit a video's script from the dashboard and re-run TTS → subtitles → render cleanly, replacing the old output