DEV Community

CODEPRACTICENOTES
CODEPRACTICENOTES

Posted on

How I Built a Zero-CapCut Dark-Mode Coding Shorts Engine with Python, Headless Chrome & NumPy

If you've ever tried running a coding YouTube Shorts or Instagram Reels channel, you know the hardest part isn't writing the code snippet—it's video editing.

Spending 90 minutes in CapCut just to animate 4 lines of Python kills consistency by Day 4. Here's the lightweight local pipeline I built to render 1080×1920 30fps dark-mode coding videos—complete with typing cursor animations and synthesized mechanical keyboard clicks—in ~15 seconds per video.

Step 1: HTML/CSS as a Motion Graphics Layout Engine

Instead of fighting FFmpeg drawtext filters (which are painful for syntax highlights, tables, and responsive font sizing), I render each slide in headless Chrome:

  • One screenshot with the code visible (full.png)
  • One screenshot with .reveal { visibility: hidden; } (blank.png)

Step 2: Zero-Config Character Typing via Pixel Diff

By taking ImageChops.difference(full, blank) in Pillow + NumPy, we automatically detect every line row and glyph column without measuring font metrics manually:

changed = np.asarray(ImageChops.difference(full, blank)).max(axis=2) > 45
Enter fullscreen mode Exit fullscreen mode

Then we paste progressive horizontal crops from full onto blank with a blinking accent cursor—giving smooth, native browser typography with authentic terminal typing motion.

Step 3: Procedural Mechanical Keystroke Audio in NumPy

Instead of licensing audio loops, a 25-line NumPy function synthesizes soft damped sine bursts + filtered noise aligned to the exact frame timestamps where each character appears, mixed over a gentle 4-chord ambient bed.

Step 4: Automating Publishing with YouTube Data API v3

Once render_batch.py renders 30 Shorts + 30 Reels (60 MP4s), a small google-api-python-client script reads 30_day_calendar.csv and schedules every Short at Tier-1 global peak times (12:00 PM EST).

Live Demo & Full Kit

Let me know if you want a deep dive into the NumPy mechanical click synthesizer or headless Chrome timing tricks!

Top comments (0)