AI automation · Case study

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.

7 stagesfully automated
1 commandtopic → upload
1080×1920Shorts-ready output
~45–70sper generated video

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.

Compound interest62s · voiceover + captions
5 investing mistakes58s · voiceover + captions
Compound interest, take 251s · different storyboard
Investing mistakes, take 250s · different storyboard

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.

Python Claude API · Sonnet + Haiku FLUX via fal.ai Pexels API ElevenLabs / Kokoro TTS FFmpeg Pillow YouTube Data API · OAuth 2.0 Reddit API Supabase

Running cost

Built to run daily on a small budget.

ServiceUsed forApprox. cost
Anthropic ClaudeScoring + storyboard~$0.01–0.05 per video
fal.ai FLUXHook, reveal and thumbnail images~$0.04 per image
PexelsStock video clipsFree
YouTube Data APIPublishingFree 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