Most AI video tools charge monthly subscriptions, cap your exports, and still leave you doing the boring glue work: checking if a topic is repetitive, trimming awkward audio cutoffs, stitching an outro, writing YouTube tags, and scheduling.

So I built APEX CINEGEN PRO — a self-hosted Python pipeline that turns a single tap in Telegram into a mastered, scheduled YouTube Short.

What the Pipeline Does End-to-End

  1. Story Ideation: Brainstorms 10 dialogue-dense concepts.
  2. Gemini 2.5 Flash Virality Audit: Scores each concept for 2-Clip (20s) or 3-Clip (30s) pacing, checks used_topics.json to prevent repeats, and auto-rerolls weak ideas.
  3. Automated Google Flow Calibration (Playwright CDP): Disables Flow Agent on fresh projects, falls back to Omni 1.1 Flash / .duration-slider if 10s isn't exposed, locks Video · 720p · 10s · 9:16 · x1, and captures the MP4 via expect_download().
  4. FFmpeg Mastering: Stitches your custom outro with a smooth 0.3s afade audio transition and extracts cover frames.
  5. Telegram Mobile Studio + YouTube Data API v3: Delivers the playable MP4 straight to your phone with inline buttons (Approve & Schedule (9 PM IST), View Tags & Info, Publish Instantly) and packs up to 24+ tags inside YouTube's 480-character quote-aware limit.

3 Engineering Lessons That Made It Reliable

  • The 1.5s Breathing Buffer: AI video clips love cutting off the last word at 10.0s. Enforcing 22–26 words/clip plus a 1.5s silent visual tail solved it.
  • UI Fallback Calibration: Web UIs change selectors and model defaults. Having an automatic fallback from Omni 1.2 Flash to Omni 1.1 Flash + slider control kept batch runs (2x–10x) from stalling.
  • Quote-Aware Tag Packing: Naively joining tags blows past YouTube's 500-char limit once multi-word tags get quoted.

Check Out the Repo

Full architecture diagram, live demo MP4s, and quickstart are on GitHub:
https://github.com/mehaksandhudev/apex-cinegen-pro

If you're building multi-step AI pipelines or Playwright CDP automations, I'd love your feedback in the comments!