বাংলায় পড়ুন: এডিটর ছাড়াই ভিডিও এডিটিং: নিজের পিসিতে এআই এজেন্ট দিয়ে পুরো কাজ, কম টোকেনে →
Works in any agent harness: Claude Code, Google Antigravity, OpenCode, Command Code, or any agent that can read files and run commands, with a direct subscription or an OpenRouter key.
Tools: FFmpeg · HyperFrames · Whisper · Python · your agent
A short story: where did the timeline go?
For years, video editing for me meant DaVinci Resolve. A long timeline across the bottom of the monitor, the audio waveform above it, and the playhead dragged back and forth to find the exact word where a card should land. Placing eight or ten cards in a seven-minute video could take a whole evening. It worked, but every decision was made by eye and by hand.
Then came the DaVinci Resolve MCP server. Now the agent drove Resolve itself: cutting clips, placing titles. It sounded great. But the heavy application was still open in the background, eating RAM, and the agent was wrestling with an interface built for humans.
Fast-forward to today. I made my latest book review without opening a video editor at all. I had the camera footage, a separately processed WAV file and a terminal. No timeline on screen, no playhead. Just a text file listing what I said, second by second.
That’s exactly where the first problem showed up. The first time I transcribed with Whisper, many of my sentences simply vanished. Fed Bangla audio in 30-second windows, the model quietly dropped a lot of speech. In an editor I’d have spotted it at once; the waveform was right there. But the agent has no waveform. If a sentence isn’t in the transcript, then in the agent’s world it was never said. No card lands there, and no subtitle either.
That day I understood that the timeline hadn’t disappeared. It had moved. It used to be something you look at; now it’s something you read. And the backbone of this new timeline is two things: Whisper’s transcript and its timing.
This guide is the whole workflow, so you can do it on your own PC, by hand, and understand why each step exists.
1. The core idea: everything stays on your PC
The philosophy is the same as editing locally in DaVinci Resolve. Footage, audio and renders all stay on your own computer. No cloud rendering, no uploading footage. Only short text, and now and then one small image, goes to the model.
The one difference: there’s no editor. In its place are a few small tools, each very good at one job. FFmpeg cuts, grades, overlays cards and subtitles, and encodes. Whisper listens to your audio and writes timestamped text. HyperFrames turns HTML into animated cards rendered as transparent video. Small Python scripts do the sync and subtitle arithmetic. And the agent does the thinking.
The agent gets expensive when it watches things: long logs, big files, renders in progress. It’s cheap when it writes a small script once and then reads short summaries. So the work splits like this:
- You run the heavy, slow jobs on your own PC (transcription, card renders, the final encode).
- The agent does the thinking you can’t easily automate: cleaning the transcript, timing cards to what you said, and spotting problems in a contact sheet.
Name check: the speech‑to‑text model is Whisper (by OpenAI, open source). People often say “Wispr”, but “Wispr Flow” is a different product, a dictation app, so keep that in mind when searching. Whisper doesn’t change your audio; it only produces a transcript.
2. To the AI, the timeline is the transcript
This is the most important part of the guide. Every other step stands on it.
In an editor, the timeline is in front of your eyes. You see in the waveform where speech starts and stops; you drag the playhead and listen. The agent gets none of that. It doesn’t watch video or hear audio. To the agent, my whole video was a few hundred lines of text like this:
45.06 – 49.90 বইটা হচ্ছে 'বেতালপঞ্চবিংশতি'। (The book is 'Betal Panchabingshati'.)
113.72 – 119.76 যদিও এই বইটার foreword লিখেছেন সেলিনা হোসেন। (Its foreword is by Selina Hossain.)
Which card appears when, how long each subtitle stays: every decision the agent makes comes from these numbers. A wrong timestamp means a card in the wrong place. Two seconds early, and viewers read the answer before they hear it. Two seconds late, and the card arrives after you’ve moved on. And if a line is missing from the transcript, nothing lands there and nobody notices. That’s why, in this workflow, the Whisper model and the timing matter most. In an editor a timing mistake is visible; here it isn’t.
Three clocks
Something you never think about in an editor matters a lot here. Three different clocks are running:
| Clock | Where it’s used |
|---|---|
| Camera time | The video file in raw footage. The sync reference. |
| WAV time | Your processed audio. Every Whisper timestamp is on this clock. |
| Output time | The final video. Cards and subtitles are placed on this clock. |
Two formulas tie them together, and the sync script in Step 2 gives you both numbers:
camera time = WAV time + offset
output time = WAV time - wav_start
In my video, offset was 2.842 s and wav_start 2.058 s. So “the book is ‘Betal Panchabingshati’” is at 47.12 s in the WAV, 49.96 s in the camera file and 45.06 s in the final video. I put the book card at 44.74, about 0.3 s before the words, because the card’s entrance animation takes half a second; it should be fully visible when the sentence starts.
Write these formulas into SETTINGS.md once and the agent won’t mix the clocks up. If you don’t, one day it will place cards in WAV time, and every card will arrive two seconds late. Without a proof render, you won’t even notice.
Rules that keep the timing accurate
- Transcribe the processed WAV, not the camera audio. Clean audio gives accurate timestamps.
- For Bangla, Hindi, Arabic and similar languages, use 5–12 s chunks cut at pauses. Each chunk’s start time is added back to get the real time; the script in Step 3 does this for you.
- Whisper’s times can be off by a few hundred milliseconds. Snap subtitle starts and ends to real silences in the WAV (−50 dBFS).
- The text changes; the times don’t. When the agent cleans the script, it keeps each line’s start time.
- A card lands on the line where you say it. Its time is that line’s output time, slightly earlier to allow for the entrance.
- Check the first 60 seconds first. Before transcribing the whole file, compare the first minute’s text and times with the audio. Mistakes show up here.
How to “see” the timeline without an editor
You still have a live timeline; it’s just split across a few files:
| In an editor | Here |
|---|---|
| Audio track and waveform | asr_raw.txt and script.md: who said what, when |
| Title track | cards.json: which card appears when |
| Subtitle track | subs/cues.json |
| Project settings, colour page | settings.json and SETTINGS.md |
| Playhead and viewer | 15–30 s proof renders, HyperFrames preview |
Read as text, my video’s title track looks like this:
00:01.0 opening card Book · Betal Panchabingshati (with the first word)
00:44.7 book card Book · Betal Panchabingshati ← "The book is 'Betal Panchabingshati'."
01:53.3 foreword Selina Hossain ← "...its foreword is by Selina Hossain."
02:04.9 point card Great storytelling
04:22.6 point card How the story begins
06:25.8 end card Read it on Wikisource
07:01.5 end
To move a card by a second, change the number in cards.json and render a 15 s proof of that spot. To see a card’s design, npx hyperframes@0.10.4 preview <card> plays it live in Chrome, where you can scrub through it. In short, dragging a clip with the mouse has become changing a number. And you don’t need the agent to change a number; you can do it yourself.
3. What you need
| Tool | What it does here | Install (Windows) |
|---|---|---|
| FFmpeg | Sync analysis, grading, compositing, encoding | winget install Gyan.FFmpeg, or unzip the gyan.dev build and add bin to PATH |
| Node.js + HyperFrames | Renders animated cards (HTML/CSS/GSAP) as transparent video | Install Node LTS, then npx hyperframes@0.10.4 doctor |
Python 3 + numpy, Pillow |
Sync math, subtitle images | pip install numpy pillow |
Whisper via faster-whisper |
Transcription (CPU, or NVIDIA GPU) | pip install faster-whisper |
| (Optional) OpenVINO | Whisper on an Intel iGPU (Iris Xe / Arc) | pip install openvino-genai |
| An agent harness | Writes and fixes scripts, cleans the script, plans cards | Claude Code, Antigravity, OpenCode, Command Code, … |
macOS and Linux work the same way. Install with Homebrew or apt, and use whisper.cpp (Metal) on Apple Silicon if you prefer.
Disk tip: models are big (Whisper large‑v3 is about 3 GB). Put caches on your data drive:
$env:HF_HOME = "D:\AI-models\hf_cache"
$env:PIP_CACHE_DIR = "D:\AI-models\pip_cache"
4. Project folder
D:\MyVideo\
├── raw footage\ camera or screen recording (.mp4)
├── processed audio\ your final, mastered voice track (.wav)
├── cards\ one HyperFrames project per card + renders\
├── assets\ fonts, grade stills
├── scripts\ the small Python helpers below
├── final video\ deliverables
└── SETTINGS.md every decision for this video (offsets, grade, sizes)
Keep it on a local drive, not a synced cloud folder.
SETTINGS.md is your token saver. When a session ends, the next one (or a different harness) reads this one file instead of redoing the analysis.
5. Ground rules (put these in your agent’s rules file)
Every harness has a project instructions file: CLAUDE.md (Claude Code), AGENTS.md (OpenCode and many others), or a rules/instructions file (Antigravity, Command Code). Paste these rules in once:
- The WAV is final. Never normalise, EQ, compress or resample it. Only trim it and encode it to AAC.
- Remove the camera audio; use it only as the sync reference.
- A/V sync within ~1 ms; speech starts at 1.0 s; the tail ends 1.5 s after the last word.
- Show before rendering: stills → 15–30 s proof → full render, each approved.
- Card and subtitle text comes only from what the speaker said. Never invent quotes.
- Print summaries, not logs. Never read whole videos or long outputs into the chat.
- Record every decision in SETTINGS.md.
6. The workflow, step by step
Each step shows who does it and roughly how many tokens it costs.
Step 1: Inspect the inputs (you, 0 tokens)
ffprobe -v error -show_entries format=duration:stream=codec_type,codec_name,width,height,r_frame_rate,pix_fmt,sample_rate,channels -of compact "raw footage\clip.mp4"
ffprobe -v error -show_entries stream=codec_name,sample_rate,channels,duration -of compact "processed audio\voice.wav"
ffmpeg -i "raw footage\clip.mp4" -vf "fps=1/15,scale=320:-1,tile=6x5" -frames:v 1 assets\contact.jpg
Note the frame rate (keep it), the pixel format (yuvj420p = full range, yuv420p = TV range), and the durations. The contact sheet shows the shot and any burned‑in graphics.
Step 2: Sync the WAV to the camera (you run it, 0 tokens)
Your processed WAV almost never starts at the same moment as the camera. This script finds the offset in two stages: a loudness‑envelope match, then a sample‑accurate cross‑correlation. It also computes the head and tail.
scripts\sync.py
# usage: python sync.py "raw footage\clip.mp4" "processed audio\voice.wav" 30
import subprocess, sys, numpy as np
from numpy.lib.stride_tricks import sliding_window_view as win
cam, wav, fps = sys.argv[1], sys.argv[2], float(eval(sys.argv[3]))
def load(p, sr):
raw = subprocess.run(["ffmpeg", "-v", "error", "-i", p, "-vn", "-ac", "1", "-ar", str(sr), "-f", "f32le", "-"],
capture_output=True, check=True).stdout
return np.frombuffer(raw, np.float32)
# Stage A: coarse offset from 10 ms loudness envelopes
def env(x, sr):
h = sr // 100; n = len(x) // h
return np.log10(np.sqrt((x[:n*h].reshape(n, h) ** 2).mean(1)) + 1e-4)
v8, a8 = load(cam, 8000), load(wav, 8000)
ev, ea = env(v8, 8000), env(a8, 8000)
W = win(ev, 400); Wz = (W - W.mean(1, keepdims=True)) / (W.std(1, keepdims=True) + 1e-9)
offs = []
for t in range(10, len(ea) // 100 - 10, 20): # a 4 s window every 20 s
s = ea[t*100:t*100+400]; s = (s - s.mean()) / (s.std() + 1e-9)
c = Wz @ s / 400; o = int(c.argmax())
if c[o] > 0.7: offs.append((o - t*100) / 100)
coarse = float(np.median(offs))
print(f"coarse offset {coarse:+.2f} s from {len(offs)} windows; spread {min(offs):+.2f}..{max(offs):+.2f}")
print(" (a spread above ~0.05 s means the WAV was edited: sync each section separately)")
# Stage B: sample-accurate offset at 48 kHz, checked at 5 points
sr = 48000; v, a = load(cam, sr), load(wav, sr)
def fine(t):
sa = np.diff(a[int(t*sr):int((t+10)*sr)]); c0 = int((t + coarse - 0.3) * sr)
sv = np.diff(v[c0:c0 + int(10.6*sr)]); n = 1 << int(np.ceil(np.log2(len(sv) + len(sa))))
c = np.fft.irfft(np.fft.rfft(sv, n) * np.conj(np.fft.rfft(sa, n)), n)[:len(sv) - len(sa)]
return (c0 + np.argmax(np.abs(c))) / sr - t
dur = min(len(a) / sr, len(v) / sr - coarse) - 15
pts = [5 + dur * k / 4 for k in range(5)]
fo = [fine(t) for t in pts]
off = float(np.median(fo))
print("fine offsets (ms):", ", ".join(f"{x*1000:.2f}" for x in fo), f"-> drift {1000*(max(fo)-min(fo)):.1f} ms")
# Head and tail: speech starts at 1.0 s, tail 1.5 s after the last word
h = sr // 200; n = len(a) // h
db = 20 * np.log10(np.sqrt((a[:n*h].reshape(n, h) ** 2).mean(1)) + 1e-9)
sp = np.where(db > -50)[0]; first, last = sp[0] / 200, (sp[-1] + 1) / 200
src_frame0 = round((first - 1.0 + off) * fps)
wav_start = src_frame0 / fps - off
frames = round((last + 1.5 - wav_start) * fps)
print(f"\nvideo_time = wav_time + {off:.4f}")
print(f"src_frame0 = {src_frame0} wav_start = {wav_start:.3f} output_frames = {frames} ({frames/fps:.2f} s)")
print(f"output time = WAV time - {wav_start:.3f} (use this to re-time subtitles)")
Copy the last three lines into SETTINGS.md. That’s the only thing the agent needs to see. The three-clock formulas from section 2 come from here.
Step 3: Transcribe with Whisper (you run it; the agent reads only the text)
Transcribe the processed WAV (clean voice), never the camera audio.
Important for Bangla, Hindi, Arabic and other non‑Latin languages: split the audio into 5–12 s chunks cut at pauses. With Whisper’s normal 30 s window, these languages use so many tokens per word that Whisper silently drops most of the speech.
scripts\transcribe.py
# usage: python transcribe.py "processed audio\voice.wav" bn [cpu|cuda]
import subprocess, sys, json, numpy as np
from faster_whisper import WhisperModel
wav, lang = sys.argv[1], sys.argv[2]; dev = sys.argv[3] if len(sys.argv) > 3 else "cpu"
sys.stdout.reconfigure(encoding="utf-8")
sr = 16000
a = np.frombuffer(subprocess.run(["ffmpeg", "-v", "error", "-i", wav, "-ac", "1", "-ar", str(sr), "-f", "f32le", "-"],
capture_output=True, check=True).stdout, np.float32)
h = 320; n = len(a) // h # 20 ms frames
quiet = 20 * np.log10(np.sqrt((a[:n*h].reshape(n, h) ** 2).mean(1)) + 1e-9) < -45
cuts = [i for i in range(10, n - 10) if quiet[i-5:i+5].all()] # middle of a 200 ms pause
chunks, s = [], 0
while s < n:
ok = [c for c in cuts if 5 / 0.02 <= c - s <= 12 / 0.02]
e = ok[-1] if ok else min(s + 600, n); chunks.append((s, e)); s = e
m = WhisperModel("large-v3", device=dev, compute_type="int8" if dev == "cpu" else "float16")
out = []
for s, e in chunks:
segs, _ = m.transcribe(a[s*h:e*h], language=lang, beam_size=5, vad_filter=False,
condition_on_previous_text=False,
temperature=[0.0, 0.2, 0.4, 0.6], compression_ratio_threshold=2.0)
for g in segs:
o = {"start": round(s*0.02 + g.start, 2), "end": round(s*0.02 + g.end, 2), "text": g.text.strip()}
out.append(o); print(f"{o['start']:7.2f} {o['end']:7.2f} {o['text']}", flush=True)
json.dump(out, open("asr_raw.json", "w", encoding="utf-8"), ensure_ascii=False, indent=1)
open("asr_raw.txt", "w", encoding="utf-8").write("\n".join(f"{o['start']:.1f}\t{o['text']}" for o in out))
Speed and hardware:
| Your PC | Command / note | Rough speed |
|---|---|---|
| CPU only | python transcribe.py voice.wav bn cpu |
Slow with short chunks (several × real time on 8 cores) |
| NVIDIA GPU | python transcribe.py voice.wav bn cuda |
Much faster than real time |
| Intel iGPU (Iris Xe / Arc) | Use OpenVINO: model OpenVINO/whisper-large-v3-int8-ov, openvino_genai.WhisperPipeline(path, device="GPU") |
About 1–1.5× real time. Can loop on fast speech: redo those chunks on CPU |
| Apple Silicon | whisper.cpp with Metal |
Fast |
Tips:
- Run a 60 s test first (trim the WAV) and read it before committing to the whole file.
- Watch for looping (“and and and…”) and prompt leakage (if you give Whisper an
initial_prompt, it sometimes outputs that exact text on unclear audio). Re-run just those chunks. - On Windows/Python 3.14, faster-whisper’s own file loader may fail. Passing a numpy array, as above, avoids it.
Step 4: Clean the script (agent, the main token spend; worth it)
Give the agent only asr_raw.txt (plain text with times). Not the JSON, not the audio. A 7‑minute talk is a few thousand tokens.
Prompt (any harness):
Read asr_raw.txt (raw Whisper output, <language>, times in WAV seconds).
1. Rewrite it as a clean script, one line per thought, keeping each line's start time.
Fix misheard names and terms from context; smooth slips; never add ideas or quotes.
Keep English words I said in English (Latin script).
2. Give me a review list: time · raw text · your text · why. Mark every guess.
3. Propose cards (time · type · label · text) using only my own words, ≥ 1 s apart.
Write the result to script.md. Don't print it back in full.
Then you read script.md, fix the review list by hand (that’s faster and cheaper than going back and forth with the agent), and tell the agent “approved” once.
Notice the prompt says “keeping each line’s start time”. However polished the text, if the times are lost, the timeline is lost.
Step 5: Choose a look (you run it, 0 tokens; the agent may look at 1 small image)
Grab one frame and render 4–6 looks side by side. For dim footage, brighten the mid‑tones with a curve and protect the highlights:
ffmpeg -ss 30 -i "raw footage\clip.mp4" -frames:v 1 assets\src.png
ffmpeg -i assets\src.png -vf "hqdn3d=1.5:1.5:3:3,curves=all='0/0.03 0.25/0.31 0.5/0.60 0.75/0.84 1/0.98',colorbalance=rm=0.06:gm=0.01:bm=-0.06:rh=0.03:bh=-0.04,vibrance=intensity=0.30,eq=contrast=1.10:saturation=1.18" assets\look_vivid.png
ffmpeg -i assets\src.png -vf "hqdn3d=1.5:1.5:3:3,curves=all='0/0.03 0.25/0.31 0.5/0.60 0.75/0.84 1/0.98',vibrance=intensity=0.20,eq=contrast=1.04:saturation=1.08" assets\look_natural.png
Open them yourself, pick one, and paste its filter string into SETTINGS.md as GRADE.
Step 6: Build the cards in HyperFrames (agent writes once, you render)
A HyperFrames card is a small web page: HTML + CSS + a paused GSAP timeline, with a transparent background. HyperFrames renders it to a WebM with alpha, and FFmpeg overlays that on your video.
Ask the agent once for a generator script (e.g. make_cards.py) that writes one HyperFrames project per row of your card plan. After that, new cards cost no tokens: you edit cards.json and re-run the generator.
Minimal card (cards\my-card\index.html):
<!doctype html>
<html><head><meta charset="UTF-8">
<script src="https://cdn.jsdelivr.net/npm/gsap@3.15.0/dist/gsap.min.js"></script>
<style>
@font-face { font-family: "Body"; src: url("fonts/YourFont-Bold.ttf"); }
html, body { width:1920px; height:1080px; margin:0; background:transparent; }
#card { position:absolute; left:1110px; top:250px; color:#fff; font:700 84px/1.3 "Body";
text-shadow:0 3px 14px rgba(10,40,110,.75); }
#chip { display:inline-block; background:#2D7BEA; font-size:32px; padding:6px 20px; }
</style></head>
<body>
<div id="root" data-composition-id="main" data-start="0" data-duration="6" data-width="1920" data-height="1080">
<div id="card" class="clip" data-start="0" data-duration="6" data-track-index="0">
<div id="chip">KEY POINT</div><div class="ln">Your words here</div>
</div>
</div>
<script>
const tl = gsap.timeline({ paused: true });
tl.from("#chip", { x: -40, opacity: 0, duration: 0.55, ease: "expo.out" }, 0.1);
tl.from(".ln", { y: 34, opacity: 0, duration: 0.7, ease: "power3.out" }, 0.22);
tl.to("#card", { x: 60, opacity: 0, duration: 0.55, ease: "power2.in" }, 5.4);
window.__timelines["main"] = tl; tl.seek(0);
</script>
</body></html>
Then you run:
cd D:\MyVideo\cards
npx hyperframes@0.10.4 lint my-card
npx hyperframes@0.10.4 snapshot my-card --at 2.5 --no-end # one PNG still to check the design
npx hyperframes@0.10.4 render my-card --format webm --fps 30 --quality delivery --workers 2 -o renders\my-card.webm
Design defaults that hold up on 16:9 YouTube and Facebook:
- Point card headline about 84 px, label 32 px, on the side of the frame away from your face.
- Title bar in the upper third, top‑right, so it never fights the subtitles.
- Entries 0.45–0.8 s ease‑out, exits about 0.5 s slide + fade. No hard cuts, no neon.
- Before rendering, check each card position against 6–8 frames across the video (heads move).
Step 7: Subtitles (you run it, 0 tokens)
Let the agent turn script.md into an SRT once: max 2 lines, about 42 characters per line, 1.2–7 s per cue, timed from the Whisper segments. Then re-time it to the edited video (output time = WAV time − wav_start).
- Latin scripts: FFmpeg can burn the SRT directly:
subtitles=subs.srt:force_style='FontName=Lato,FontSize=26,…'. - Bangla, Hindi, Arabic and other complex scripts: don’t use FFmpeg’s
subtitlesfilter; it mis‑shapes conjuncts. Render each cue as a transparent PNG with Pillow’s RAQM layout engine:
scripts\subs_to_png.py
# usage: python subs_to_png.py subs_video_time.srt "assets\YourFont.ttf" → subs\NNN.png + subs\cues.json
import re, sys, json, os
from PIL import Image, ImageDraw, ImageFont
srt, font = sys.argv[1], sys.argv[2]
F = ImageFont.truetype(font, 50, layout_engine=ImageFont.Layout.RAQM)
def t(s): h, m, x = s.replace(",", ".").split(":"); return int(h)*3600 + int(m)*60 + float(x)
os.makedirs("subs", exist_ok=True); cues = []
for i, blk in enumerate(re.split(r"\n\s*\n", open(srt, encoding="utf-8").read().strip())):
L = blk.splitlines(); a, b = [t(x.strip()) for x in L[1].split("-->")]; lines = L[2:]
img = Image.new("RGBA", (1920, 1080), (0, 0, 0, 0)); d = ImageDraw.Draw(img)
asc, desc = F.getmetrics(); bh = asc + desc + 20; y = 1080 - 44
for ln in reversed(lines): # bottom line first
l, _, r, _ = d.textbbox((0, 0), ln, font=F); w = r - l; x0 = 860 - w // 2 - 26
d.rounded_rectangle((x0, y - bh, x0 + w + 52, y), 14, fill=(15, 23, 42, 205))
d.text((x0 + 26 - l, y - bh + 10), ln, font=F, fill="white"); y -= bh + 10
p = f"subs/{i:03d}.png"; img.save(p); cues.append({"png": p, "start": a, "end": b})
json.dump(cues, open("subs/cues.json", "w"), indent=1)
print(len(cues), "cues")
Step 8: Render (you run it; the agent writes the script once)
One FFmpeg pass: grade → cards → subtitles → encode. The audio is encoded separately and muxed afterwards, which avoids truncated tracks.
scripts\render.py
# usage: python render.py out.mp4 [start_s dur_s] (a window = a proof; no window = the full video)
import json, subprocess, sys
S = json.load(open("settings.json")) # values from SETTINGS.md (see below)
fps = S["fps"]; t0 = float(sys.argv[2]) if len(sys.argv) > 2 else 0.0
f0 = round(t0 * fps); nfr = round(float(sys.argv[3]) * fps) if len(sys.argv) > 3 else S["output_frames"] - f0
t0, dur = f0 / fps, nfr / fps
cards = [c for c in S["cards"] if c["at"] < t0 + dur and c["at"] + c["dur"] > t0]
subs = [c for c in json.load(open("subs/cues.json")) if c["start"] < t0 + dur and c["end"] > t0]
cmd = ["ffmpeg", "-y", "-ss", f"{(S['src_frame0'] + f0 - 0.5) / fps:.4f}", "-i", S["video"]]
fc = [f"[0:v]setpts=PTS-STARTPTS,{S['grade']},format=yuv420p[v0]"]; last, k = "v0", 1
for c in cards: # -c:v libvpx-vp9 keeps the WebM's alpha
cmd += ["-c:v", "libvpx-vp9", "-i", c["webm"]]
fc.append(f"[{k}:v]format=yuva420p,setpts=PTS-STARTPTS+{c['at'] - t0:.3f}/TB[c{k}]")
fc.append(f"[{last}][c{k}]overlay=0:0:eof_action=pass[v{k}]"); last = f"v{k}"; k += 1
for c in subs:
cmd += ["-i", c["png"]]
fc.append(f"[{last}][{k}:v]overlay=0:0:enable='between(t,{max(c['start'] - t0, 0):.3f},{c['end'] - t0:.3f})'[v{k}]")
last = f"v{k}"; k += 1
fc.append(f"[{last}]format={S['pix_fmt']}[out]")
cmd += ["-filter_complex", ";".join(fc), "-map", "[out]", "-frames:v", str(nfr), "-r", str(fps)] + S["encoder"] + [
"-color_range", "tv", "-colorspace", "bt709", "-color_primaries", "bt709", "-color_trc", "bt709", "v.mp4"]
subprocess.run(cmd, check=True)
subprocess.run(["ffmpeg", "-y", "-ss", f"{S['wav_start'] + t0:.6f}", "-t", f"{dur:.6f}", "-i", S["wav"],
"-c:a", "aac", "-b:a", "384k", "-ar", "48000", "-ac", "2", "a.m4a"], check=True)
subprocess.run(["ffmpeg", "-y", "-i", "v.mp4", "-i", "a.m4a", "-map", "0:v", "-map", "1:a",
"-c", "copy", "-movflags", "+faststart", sys.argv[1]], check=True)
settings.json (filled in from Steps 2, 5 and 6):
{
"video": "raw footage/clip.mp4", "wav": "processed audio/voice.wav",
"fps": 30, "src_frame0": 147, "wav_start": 2.058, "output_frames": 12645,
"grade": "hqdn3d=1.5:1.5:3:3,curves=all='0/0.03 0.25/0.31 0.5/0.60 0.75/0.84 1/0.98',vibrance=intensity=0.30,eq=contrast=1.10:saturation=1.18",
"cards": [ { "webm": "cards/renders/my-card.webm", "at": 44.7, "dur": 6 } ],
"pix_fmt": "yuv420p",
"encoder": ["-c:v", "libx264", "-preset", "medium", "-crf", "18"]
}
Pick the encoder your hardware has (check with ffmpeg -encoders | findstr /i "qsv nvenc videotoolbox"):
| Hardware | "encoder" |
"pix_fmt" |
|---|---|---|
| Any CPU | ["-c:v","libx264","-preset","medium","-crf","18"] |
yuv420p |
| Intel (Quick Sync) | ["-c:v","h264_qsv","-preset","slower","-global_quality","18"] |
nv12 |
| NVIDIA (NVENC) | ["-c:v","h264_nvenc","-preset","p5","-cq","19"] |
yuv420p |
| Apple Silicon | ["-c:v","h264_videotoolbox","-q:v","65"] |
yuv420p |
If your footage is full range (yuvj420p), add scale=in_range=full:out_range=tv after the grade.
Always render proofs first:
python scripts\render.py "final video\proof_start.mp4" 0 15 # the opening: lead-in, first card
python scripts\render.py "final video\proof_busy.mp4" 112 30 # the busiest 30 s
python scripts\render.py "final video\final.mp4" # only after you approve the proofs
Audio bitrate: AAC‑LC 384 kbps, 48 kHz stereo is YouTube’s recommended stereo spec, and Facebook and LinkedIn accept it. Every platform re-encodes anyway, so going higher gains nothing. Uploading a clean source is what protects your sound.
Step 9: QA (you run it; the agent reads a few numbers and one small image)
# frames and duration
ffprobe -v error -show_entries stream=codec_name,nb_frames,duration -of compact "final video\final.mp4"
# audio level must match your WAV (peak within ~0.3 dB; RMS identical)
ffmpeg -i "final video\final.mp4" -af astats=measure_perchannel=none -f null - 2>&1 | findstr /i "Peak.level RMS.level"
ffmpeg -ss <wav_start> -t <duration> -i "processed audio\voice.wav" -af astats=measure_perchannel=none -f null - 2>&1 | findstr /i "Peak.level RMS.level"
# contact sheet: one 4x4 image of the whole video
ffmpeg -i "final video\final.mp4" -vf "fps=1/27,scale=480:-1,tile=4x4" -frames:v 1 assets\final_sheet.jpg
Checklist:
- ☐ Speech starts at 1.0 s; the tail is about 1.5 s
- ☐ The audio peak matches the WAV; no camera audio
- ☐ Every card appears at the right line, clear of the face and inside the frame
- ☐ Subtitles are shaped correctly (check a few conjuncts) and clear of the cards
- ☐ The frame count matches
output_frames
7. Who does what (and where the tokens go)
| Task | You | Agent | Token cost |
|---|---|---|---|
| Install tools, folders | ✔ | 0 | |
| Probe files, contact sheet | ✔ | glances at 1 small image | very low |
Sync (sync.py) |
✔ run | reads 3 output lines | very low |
Transcribe (transcribe.py) |
✔ run | 0 | |
| Clean the script, review list, card plan | review | ✔ | main spend, worth it |
| Grade looks | ✔ pick | 0 | |
| Card generator | ✔ writes once | one-off | |
| Render cards, proofs, final | ✔ run | 0 | |
| QA | ✔ run | reads numbers + 1 sheet | low |
8. Token‑saving habits (any harness)
- Write it down once. Keep
SETTINGS.mdand your rules file current. A new session, or a different harness, starts from those two files, not from scratch. - Scripts, not conversations. Ask the agent for a reusable script once (sync, transcribe, cards, render). Every later video reuses it for free.
- Run long jobs yourself. Don’t let the agent sit watching a 10‑minute transcription or render. Run it in your own terminal and paste back only the last few lines.
- Summaries, not logs. FFmpeg and Whisper print a lot. Ask for
-v error,| tail -5, or a one-line summary. - Small images only. Show the agent a 4×4 contact sheet, not full frames, and never a video.
- Preview before you commit. Check the first 60 s of the transcript, 15–30 s video proofs, and one still per card design. Catching a mistake early is the biggest saving of all.
- Right model for the job (OpenRouter makes this easy): a cheaper, fast model for mechanical edits and script fixes; a stronger model for cleaning a messy non‑English transcript.
- Fix small things by hand. A typo in the script or a card position is faster to change in the file than to explain.
9. Troubleshooting (lessons from real runs)
| Symptom | Cause | Fix |
|---|---|---|
| Transcript is missing most sentences | 30 s Whisper windows on a non‑Latin language | 5–12 s chunks at pauses (Step 3) |
| “এবং এবং এবং…” or one word repeated | Whisper looping (common on GPU int8 models) | Re-run that chunk on CPU with temperature fallback |
| A line that is exactly your prompt text | initial_prompt leakage on unclear audio |
Delete it; listen to that spot |
| Every card is late by the same amount | Cards placed in WAV time, not output time | Subtract wav_start from every time (section 2) |
| Broken Bangla/Hindi letters in subtitles | FFmpeg subtitles filter (libass) |
Pillow + RAQM PNGs (Step 7) |
| Card shows a black box | The card was rendered as MP4, or decoded without alpha | WebM, plus -c:v libvpx-vp9 before that input |
| Audio shorter than the video | Audio and video muxed in one heavy pass | Encode audio separately, then mux with -c copy |
| Sync drifts by a few ms over the video | Camera and recorder clocks differ slightly | Under ~2 ms is invisible; never resample your mastered WAV to “fix” it |
| CPU at 100%, GPU idle | Your Whisper build doesn’t use your GPU | NVIDIA: device="cuda"; Intel: OpenVINO; Mac: whisper.cpp |
| CPU busy even when your job is on the GPU | Antivirus scanning newly downloaded models | Wait for the scan to finish |
10. One‑page summary
1. ffprobe + contact sheet (you)
2. python sync.py clip.mp4 voice.wav 30 (you) → offsets into SETTINGS.md
3. python transcribe.py voice.wav <lang> <device> (you) → asr_raw.txt = your timeline
4. Agent: clean script + review list + card plan (agent, main token spend)
5. Grade stills → pick one (you)
6. Agent writes card generator once; you render cards with HyperFrames
7. SRT → (complex scripts) PNG subtitles (you)
8. render.py: 15 s proof → 30 s proof → full (you)
9. QA numbers + contact sheet (you; agent glances)
Looking back, the biggest lesson from moving from DaVinci Resolve, to its MCP server, to no editor at all is this: the AI doesn’t watch your video, it reads it. The more accurate the transcript and the cleaner the timing, the better the video. Everything stays on your PC; the agent only sees short text and small images, and does the part that needs judgement.