aixsam.dev / tools / pipeline
My reel pipeline
I don't film my reels and I don't open a video editor. Claude writes the script, an AI voice reads it, code works out when every word is spoken, a cartoon mascot moves its mouth with the voice, and the whole reel is a web page that a browser turns into a video, frame by frame. This page gives you a free starter kit with the same core and every command to run it. Honest note: I still check the script, the facts and the final video myself. The code does the editing, not the thinking.
How it works
What you need
- A computer: Mac, Linux, or Windows. Everything runs on your own machine.
- Python 3.9+ and ffmpeg (installed in step 0).
- A voice: an AI voice (ElevenLabs, or any text-to-speech) or your own voice recorded on your phone. Both work.
- Claude (the free plan is fine) or Claude Code, for the script. Optional: you can write it yourself.
- Your own mascot: two PNG pictures, mouth closed and mouth open (step 4). The kit comes with a simple placeholder face so you can test first.
- Cost: the kit and every tool here are free. ElevenLabs has a free plan with a monthly limit; check its terms before you earn money from the videos.
Pro: one prompt, Claude does it all₹99 · one-time
Don't want to run the steps yourself? The Pro kit sets Claude up to work exactly like I do. You upload the kit and paste one prompt, give it the reference reel and the tool link, and it researches, writes the script for your approval, waits for your voice, then times, animates and renders the reel. You also get the cover and caption.
Works best in Claude Code (the Code tab in the Claude desktop app). In Claude chat it does everything up to the video, and if the render can't run there, it gives you the folder and the commands to run. Delivered instantly after payment. Stuck within 7 days? DM me with your payment ID for help or a refund.
Step by stepcopy each command with the button on the right
Download the kit
reel-kit.zip has 6 files:
build.py,reel.html,render.py,script.txtand two placeholder mascot pictures. Unzip it into a new folder and open a terminal in that folder.Install ffmpeg
Mac (with Homebrew):
brew install ffmpegLinux / WSL:
sudo apt install -y ffmpegWindows (PowerShell):
winget install Gyan.FFmpegCheck it worked:
ffmpeg -versionprints a version. On Windows, open a new terminal first.Install the Python parts
pip install pocketsphinx numpy playwright python3 -m playwright install chromiumPocketSphinx does the word timing (its English model comes inside the package, nothing else to download). Playwright drives the browser that renders the frames. On Windows, type
pythoninstead ofpython3everywhere on this page.Test the kit before changing anything
The kit comes with a script but no voice. Record yourself reading
script.txton your phone (or make it with any AI voice), put the file in the folder, then:ffmpeg -i voice.mp3 -ac 1 -ar 44100 vo.wav python3 build.py python3 render.pyYou get
reel.mp4: captions in sync, the face talks, and cards pop in on "shoot", "edit", "code" and "pipeline". If that works, everything is installed.
Ask Claude for the script
Paste this into Claude and fill in the brackets. The rules in it are the ones I use: a hook with a real before → after, short lines, and no made-up numbers.
Write a 35–45 second Instagram reel script (about 100 words) about [tool / topic]. Sources: [GitHub link / official page]. Read them first. Rules: - First sentence = the hook: who, what they do, the result, and a TRUE before → after (example: "I replaced a ₹2,000/month app with a free GitHub repo"). - Every number must come from the sources. If you can't find it, leave it out. - One idea per sentence. Simple words. Language: [English / Hinglish]. - End with: Comment "[WORD]" and I'll send you the link. Then list each fact you used with the place you found it.Check the facts list it gives you. That's the "main approve karta hoon" part, and it's the step you should never skip.
Save it as script.txt
Put exactly the words the voice will say into
script.txt. Write numbers as words (three, not3) so the timing step can match them. Hinglish is fine: write it in English letters, the way it sounds.
Make the voice and convert it
Paste
script.txtinto ElevenLabs (or record yourself), download the MP3, put it in the folder, and convert it:ffmpeg -i voice.mp3 -ac 1 -ar 44100 vo.wavToo slow? Speed it up without changing the pitch:
ffmpeg -i voice.mp3 -af atempo=1.15 -ac 1 -ar 44100 vo.wav(1.1–1.2 still sounds natural).Check the AI didn't change your words
python3 build.py checkIt prints what it hears, 5 seconds at a time. AI voices sometimes add or skip words (one of mine added a whole sentence). If a line is different, change
script.txtto what was actually said.The listening model is English, so Hindi words come out as English-sounding guesses. Look at the English words and the length of each line; the real test is the next step.
Time every word
python3 build.pyIt lines your script up with the audio (forced alignment) and writes
data.js: the start and end of every word, plus for every frame whether the mouth is open. It prints something likeok: 98 words, 41.2s.If it says
matched 90 of 98 words, the script and the voice don't match yet. Runpython3 build.py checkand fixscript.txt.What's inside build.py
You don't need to change it. It's here so you can see there's no magic.
Show build.py
"""Turns your voice into timings for the reel. python3 build.py check -> prints what the recording actually says (catch a voice AI that changed your words) python3 build.py -> data.js: when every word is spoken + when the mouth is open (30 fps) Needs: script.txt (exactly what the voice says, numbers written as words) and vo.wav.""" import json, re, subprocess, sys import numpy as np from pocketsphinx import Decoder FPS = 30 pcm = subprocess.run(['ffmpeg', '-v', 'error', '-i', 'vo.wav', '-ac', '1', '-ar', '16000', '-f', 's16le', '-'], capture_output=True, check=True).stdout if sys.argv[1:] == ['check']: # free listening, 5 seconds at a time; compare with script.txt by eye d = Decoder(samprate=16000) for i in range(0, len(pcm), 160000): d.start_utt(); d.process_raw(pcm[i:i + 160000], full_utt=True); d.end_utt() print(f'{i // 32000:3d}s', ' '.join(s.word.split('(')[0] for s in d.seg() if s.word[0] not in '<[')) sys.exit() # 1. word timings: force-align the script to the recording shown = open('script.txt', encoding='utf-8').read().split() # words as they appear in captions words = [re.sub(r"[^a-z']", '', w.lower()) for w in shown] assert all(words), 'write numbers as words in script.txt (3 -> three)' G2P = [('chh', 'CH'), ('aa', 'AA'), ('ai', 'EH'), ('au', 'AO'), ('ee', 'IY'), ('oo', 'UW'), ('ei', 'EY'), ('kh', 'K'), ('gh', 'G'), ('ch', 'CH'), ('sh', 'SH'), ('th', 'T'), ('dh', 'D'), ('bh', 'B'), ('ph', 'F'), ('jh', 'JH'), ('a', 'AH'), ('e', 'EY'), ('i', 'IH'), ('o', 'OW'), ('u', 'UH'), ('y', 'Y'), ('k', 'K'), ('g', 'G'), ('j', 'JH'), ('t', 'T'), ('d', 'D'), ('n', 'N'), ('p', 'P'), ('b', 'B'), ('m', 'M'), ('r', 'R'), ('l', 'L'), ('v', 'V'), ('w', 'W'), ('s', 'S'), ('h', 'HH'), ('z', 'Z'), ('f', 'F'), ('c', 'K'), ('q', 'K'), ('x', 'K S')] def g2p(w): # rough spelling -> sounds, for Hindi/Hinglish words and names the English dictionary doesn't know w, out, i = w.replace("'", ''), [], 0 while i < len(w): for k, p in G2P: if w.startswith(k, i): out.append(p); i += len(k); break else: i += 1 return ' '.join(out) d = Decoder(samprate=16000, bestpath=False) keys = [] for w in words: if d.lookup_word(w) is None: if d.lookup_word('x_' + w) is None: d.add_word('x_' + w, g2p(w), True) w = 'x_' + w keys.append(w) d.set_align_text(' '.join(keys)) d.start_utt(); d.process_raw(pcm, full_utt=True); d.end_utt() times = [(s.start_frame / 100, (s.end_frame + 1) / 100) for s in d.seg() if s.word not in ('<s>', '</s>', '<sil>', '(NULL)')] assert len(times) == len(words), f'matched {len(times)} of {len(words)} words: run "python3 build.py check" and fix script.txt' # 2. mouth: open on the loud peak of each syllable, closed in the dips and silences a = np.frombuffer(pcm, np.int16).astype(np.float32) / 32768 hop = 16000 // FPS rms = np.array([np.sqrt(np.mean(a[i:i + hop] ** 2)) for i in range(0, len(a), hop)]) rms /= np.percentile(rms[rms > .01], 90) peak = np.array([rms[max(0, i - 3):i + 4].max() for i in range(len(rms))]) mouth = ''.join('o' if r > .12 and r / (p + 1e-6) > .6 else 'c' for r, p in zip(rms, peak)) data = {'words': [[round(s, 2), round(e, 2), w] for (s, e), w in zip(times, shown)], 'mouth': mouth, 'duration': round(len(a) / 16000 + 1, 2)} open('data.js', 'w').write('window.DATA=' + json.dumps(data) + ';') print(f"ok: {len(words)} words, {data['duration']}s, mouth open {mouth.count('o') * 100 // len(mouth)}% of frames")
Make two pictures of the same character
Use any image AI (ChatGPT, Gemini…) to make your character: chest up, facing the camera, plain or transparent background. Then ask the same chat: "Same image, change nothing except: mouth open, like talking."
Save them as
mascot-closed.pngandmascot-open.png(replace the placeholder ones), same size, about 800×800.If the AI moves the whole picture a little, the face will jump. Fix: in any photo editor, copy just the mouth area from the open picture onto the closed one and save that as
mascot-open.png. That's what I do. Background not transparent? Remove it with a free background remover first.
Add your cards
Open
reel.htmlin any text editor. Every card is one line.data-at="@word"= it pops in when that word is spoken,data-out="@word"= it disappears on that word:<div class=card data-at="@free" style="top:200px">💸 ₹0</div> <div class=card data-at="@link" data-out="@comment" style="top:450px;background:#ffd23f">🔗 github.com/…</div>Same word twice in the script?
@free#2means the second time. Changetopto move a card down the screen (the video is 1080×1920). Put any HTML in a card: an<img>of a screenshot works too.Preview while you work
Open
reel.htmlin Chrome, press F12 for the console, and typesetT(5)to see the frame at 5 seconds. That's exactly what the render will see.The full reel.html
Show reel.html
<!doctype html> <html><head><meta charset="utf-8"> <style> html,body{margin:0;width:1080px;height:1920px;overflow:hidden;background:#111;font-family:Poppins,Arial,sans-serif;color:#fff} .card{position:absolute;left:80px;right:80px;padding:40px 50px;border-radius:30px;background:#fff;color:#111; font-size:72px;font-weight:900;border:6px solid #000;box-shadow:12px 12px 0 #000;opacity:0} #cap{position:absolute;top:960px;left:40px;right:40px;text-align:center;font-size:84px;font-weight:900;line-height:1.1; -webkit-text-stroke:14px #000;paint-order:stroke fill;z-index:2} #cap .now{color:#ffd23f} #cap .later{opacity:.35} .sam{position:absolute;left:140px;bottom:-40px;width:800px;display:none} </style></head><body> <!-- YOUR SCENE. Any element with data-at="@word" pops in when that word is spoken. data-out="@word" hides it again. Same word twice? "@pipeline#2" = the 2nd time. --> <div class=card data-at="@shoot" data-out="@whole" style="top:150px;transform:rotate(-3deg)">🎥 shoot ✗</div> <div class=card data-at="@edit" data-out="@whole" style="top:420px;transform:rotate(2deg)">✂️ edit ✗</div> <div class=card data-at="@code" data-out="@want" style="top:300px;background:#2fcf6a;font-size:110px;text-align:center">100% CODE</div> <div class=card data-at="@pipeline#2" style="top:300px;background:#ffd23f;font-size:100px;text-align:center">comment<br>PIPELINE</div> <div id=cap></div> <img class=sam id=closed src="mascot-closed.png"><img class=sam id=open src="mascot-open.png"> <script src="data.js"></script> <script> const W = DATA.words, FPS = 30; const norm = s => s.toLowerCase().replace(/[^a-z0-9]/g, ''); function cue(at) { // "@word" or "@word#2" -> the second when it's spoken const [w, n] = at.slice(1).split('#'); const hit = W.filter(x => norm(x[2]) === norm(w))[(n || 1) - 1]; if (!hit) throw new Error('cue word not in script.txt: ' + at); return hit[0]; } const ITEMS = [...document.querySelectorAll('[data-at]')].map(e => ({ e, at: cue(e.dataset.at), out: e.dataset.out ? cue(e.dataset.out) : 1e9, base: e.style.transform || '' })); const CHUNKS = []; // captions: 3 words at a time for (let i = 0; i < W.length; i += 3) CHUNKS.push(W.slice(i, i + 3)); function setT(t) { // draw the frame at time t (seconds) for (const it of ITEMS) { const p = Math.min(1, Math.max(0, (t - it.at) / .25)), back = 1 + 2.7 * Math.pow(p - 1, 3) + 1.7 * Math.pow(p - 1, 2); it.e.style.opacity = t >= it.out ? 0 : Math.min(1, p * 4); it.e.style.transform = it.base + ` scale(${t < it.at ? .5 : .5 + .5 * back})`; } const c = CHUNKS.find((c, i) => t >= c[0][0] - .05 && t < (CHUNKS[i + 1] ? CHUNKS[i + 1][0][0] : c[c.length - 1][1] + .5)); document.getElementById('cap').innerHTML = c ? c.map(w => `<span class="${t < w[0] ? 'later' : t < w[1] ? 'now' : ''}">${w[2]}</span>`).join(' ') : ''; const open = DATA.mouth[Math.floor(t * FPS)] === 'o'; document.getElementById('open').style.display = open ? 'block' : 'none'; document.getElementById('closed').style.display = open ? 'none' : 'block'; } window.setT = setT; window.DURATION = DATA.duration; setT(0); </script></body></html>
Make the video
python3 render.pyA hidden browser draws every frame (30 per second), ffmpeg glues them to
vo.wav, and you getreel.mp4(1080×1920), ready for Instagram, YouTube Shorts and TikTok. A 45-second reel is about 1,350 frames; expect a few minutes.Show render.py
"""python3 render.py -> reel.mp4 (1080x1920, 30 fps). A browser draws every frame of reel.html, ffmpeg glues them + vo.wav. python3 render.py shots 2,5,9 -> shot_2.0.jpg ... test frames to check before the full render.""" import sys import subprocess from pathlib import Path from playwright.sync_api import sync_playwright FPS = 30 with sync_playwright() as p: browser = p.chromium.launch() page = browser.new_page(viewport={'width': 1080, 'height': 1920}) errors = []; page.on('pageerror', lambda e: errors.append(str(e))) page.goto(Path('reel.html').resolve().as_uri()); page.wait_for_load_state('networkidle') assert not errors, errors if sys.argv[1:2] == ['shots']: for t in sys.argv[2].split(','): page.evaluate(f'setT({t})'); page.screenshot(path=f'shot_{float(t):.1f}.jpg', type='jpeg', quality=85) browser.close(); sys.exit('saved test frames') n = int(page.evaluate('DURATION') * FPS) ff = subprocess.Popen(['ffmpeg', '-v', 'error', '-y', '-f', 'image2pipe', '-c:v', 'mjpeg', '-r', str(FPS), '-i', '-', '-i', 'vo.wav', '-c:v', 'libx264', '-crf', '18', '-pix_fmt', 'yuv420p', '-af', 'apad', '-c:a', 'aac', '-b:a', '192k', '-shortest', '-movflags', '+faststart', 'reel.mp4'], stdin=subprocess.PIPE) for i in range(n): page.evaluate(f'setT({i / FPS})') ff.stdin.write(page.screenshot(type='jpeg', quality=92)) if i % 150 == 0: print(f'frame {i}/{n}') ff.stdin.close(); ff.wait(); browser.close() print('done: reel.mp4')Post it
Upload reel.mp4, add a trending sound at low volume in the app, and turn on Instagram's AI label (the voice and mascot are AI).
Describe the scene, let it write the HTML
Open Claude Code in the kit folder and ask in plain words:
Read script.txt and reel.html. Add a card for every key moment in the script: pop each one in on the word it belongs to (data-at="@word"), hide it when the next one comes (data-out), keep text at least 60px, and nothing below top:900px so the captions and mascot stay clear. Then run build.py and render.py.
What my own reels add on top
- A half-open mouth between closed and open, and blinks every few seconds (a third and fourth picture).
- Many poses (pointing, thumbs up, shocked) that switch on key words, and a laptop pose with a real screenshot on the screen.
- Sound effects (pop, whoosh, thud) generated from the same cue list, so every card makes a sound on its word.
- Count-ups, typing terminals, crossed-out prices and a different background color per scene.
- Rendering in 3 parts at the same time, which is how a 60-second reel renders in about 3–4 minutes.
- From the same script: a cover, a 10-slide carousel, the caption, and a setup page like this one.
The free kit is the core those are built on. The Pro kit has all of them ready, plus the one-prompt setup.
Stuck?
"matched 90 of 98 words"
The words in script.txt and the recording are different: the AI voice added, skipped or changed something, or a number is written as a digit. Run python3 build.py check, find the line, and change script.txt to what was actually said.
Captions are a bit early or late
Usually a word the dictionary doesn't know (a brand name, Hindi words) got squeezed. Write it closer to how it sounds in script.txt (for example eleven labs instead of ElevenLabs), then run build.py again. Clear recordings with no music behind them align best.
The mouth flickers too much or barely moves
In build.py, the line that makes mouth has two numbers: .12 (how loud counts as talking) and .6 (how close to the loudest point the mouth opens). Raise .6 to .7 for less flicker, lower it to .5 for more movement.
"cue word not in script.txt: @word"
A card in reel.html waits for a word you never say. Check the spelling in data-at against script.txt. Punctuation and capitals don't matter.
Playwright: "Executable doesn't exist"
The browser isn't installed yet. Run python3 -m playwright install chromium.
pip install pocketsphinx fails
Update pip first (python3 -m pip install --upgrade pip) and try again. Still failing on Windows? Use WSL (Linux on Windows) and the Linux commands.
Can I use my own recorded voice?
Yes, it works the same. Record in a quiet room, convert it with the same ffmpeg line, and the mascot talks with your voice.
Questions people ask
Do I need ElevenLabs?
No. Any voice works: your own recording, a free text-to-speech voice, or ElevenLabs. The starter kit was tested end to end with a free Piper voice.
Do I need a graphics card?
No. The reel is a web page that a headless browser screenshots frame by frame, and ffmpeg joins the frames. A normal laptop is enough.
How long does a render take?
My 40–60 second reels render in about 3 minutes, split into three parts that run at the same time.
Does it work for Hindi or Hinglish?
Yes. The kit's aligner handles Hinglish written in English letters, which is how I make my Hinglish reels.
Still stuck?
DM me on Instagram with a screenshot of the error and which step you're on.
DM @aixsamdevMore setup guides
MoneyPrinterTurbo
Give it one topic and it makes the whole short video: script, stock footage, voice, subtitles, music.
FREEClaude Code for $0
Run Claude Code on free models through OpenRouter instead of paying $20 a month.
INSTAGRAMInstagram Agent Skill
13 free Claude skills for your Instagram. Nothing posts without you.
DEVClaude Code Dev Team
Five free tools that turn Claude Code from one developer into a full team.