Video 002 · 21 Oct 2026
Can code edit my videos for me?
My last video took three minutes to film. I posted sixty seconds of it. I didn't make a single cut. The code did.
Short answer: for a scripted talking-head video, yes. Whisper, a free AI speech model, writes down every word and when I said it. Plain Python does the rest. It keeps the last good take of each line, cuts the gaps and adds the captions.
Five restarts, and I fluffed the very first line. This is how it works, and the bit it got wrong.
How to automate video editing with Python and Whisper
- Film the whole script in one go. Mess up, pause, say the line again. Don't stop the camera.
- Write down every word and when I said it. Whisper does that, free, on my laptop.
ai_shorts/transcribe.py - Match each line to the script and keep the last good take. The matching is fuzzy on purpose, because I paraphrase and Whisper hears "Rightmove" as "write move". For 001 it dropped 62 words, starting with the line I fluffed.
ai_shorts/takes.py - Cut the gaps, then add the captions and the graphics. The captions follow what I actually said, with names and numbers spelled the way the script has them.
ai_shorts/trim.py,ai_shorts/captions.py
What it got wrong
The first cut of 001 played step three twice. I only caught it on rewatch.
Whisper had stretched the word "your" over three seconds, and hidden under those three seconds was a whole second take of step three that it never wrote down. The code kept the word, so the hidden take came along with it.
Now any word that runs over a pause or lasts far longer than a word should gets listened to again on its own. That bug's a test now, with the real timings from that take, so it can't come back. tests/test_refine.py
Then a different video played "one one" and "three three" and cut off "coin flip", and again I only heard it by ear. So now the code listens to its own finished video, compares it with the captions and flags any doubled, missing or stray words. ai_shorts/selfcheck.py