Trending topic in.
Published YouTube Short out.
ViralFlow is an end-to-end AI video pipeline I designed and built. One command finds trending topics, scores them with Claude, writes the storyboard, generates images and voiceover, assembles a captioned 1080×1920 video with FFmpeg and uploads it to YouTube. No human in the loop.
How the pipeline works
Each stage is its own Python module, so any step can be swapped (a different LLM, image model, voice provider or upload target) without touching the rest.
Trends
YouTube Shorts and Reddit, with an evergreen fallback list
Score
Claude Haiku rates each topic 1–10 for viral potential
Storyboard
Claude writes the hook, steps, on-screen text and voiceover
Visuals
FLUX images plus real Pexels stock clips per step
Voice
ElevenLabs or Kokoro TTS narration
Assemble
FFmpeg + Pillow: trim, overlay text, mix audio
Publish
YouTube upload with title, description and thumbnail
Real output, untouched
These videos came straight out of the pipeline with no manual editing. This run was set to the personal-finance niche; the niche is one environment variable.
Engineering decisions
Getting an LLM to write a script is easy. Making a pipeline that runs unattended, controls cost and doesn't fall over when one API fails is the real work.
Cost-aware model routing
Topics scoring 8+ get Claude Sonnet and ElevenLabs. Everything else uses Claude Haiku and Kokoro TTS. Premium spend goes only to the topics most likely to perform.
Graceful degradation
If thumbnail generation fails, it reuses the "after" image. If voiceover fails, the video ships with music only. A failure on one topic is logged and the run continues with the next.
No duplicate content
Every produced topic is recorded and filtered out of future runs, so a daily schedule never publishes the same idea twice.
Safe to test
--dry-run prints the storyboard without spending on media. --no-publish builds the video without uploading. --topic skips trend discovery.
Structured LLM output
Claude returns a strict JSON storyboard (hook, steps, visual keywords, image prompts, voiceover lines, CTA) that every downstream stage consumes directly.
Optional persistence
When Supabase is configured, each video's topic, score, title, status and YouTube URL is stored for analytics. Without it, the pipeline still runs from local files.
# full run: trends → score → storyboard → media → assemble → upload $ python orchestrator.py # preview storyboards only, no media spend $ python orchestrator.py --dry-run # one specific topic, build locally without uploading $ python orchestrator.py --topic "the compound interest trick" --videos 1 --no-publish
Running cost
Built to run daily on a small budget.
| Service | Used for | Approx. cost |
|---|---|---|
| Anthropic Claude | Scoring + storyboard | ~$0.01–0.05 per video |
| fal.ai FLUX | Hook, reveal and thumbnail images | ~$0.04 per image |
| Pexels | Stock video clips | Free |
| YouTube Data API | Publishing | Free quota |
Based on provider list prices. Voiceover cost depends on the TTS provider chosen.
Need something like this for your business?
I'm Noman, a senior AI & backend engineer. I build AI automations, agents, RAG assistants and the Python/Node backends behind them.
- Content and video automation pipelines
- LLM agents wired into your APIs and tools
- RAG assistants over your documents
- FastAPI / Django / Node.js backends