auto-video-editor · Read It, Then Cut It
In a nutshell: Feed in a video, let it understand the content first, then edit it using a designed motion effects layer.
Two key differences from other "AI editing" tools:
- It understands first. Transcription, sentence segmentation, speaking rate, pauses, shot boundaries, where the person's face is in the frame — all quantified before deciding how to edit. The plan is based on data, not templates.
- It doesn't touch your original audio. The approach is "original video as base + web-based motion effects layer overlaid", captured frame-by-screen and composited via a direct pipeline. There is no AI face-swapping, voice-changing, or lip-sync modification. The audio envelope cross-correlation between the output and original video is normally ≥ 0.93.
What Comes Out of One Video
| Output | Description |
|---|---|
analysis.json | Structured facts: duration / aspect ratio / frame rate, transcription sentences, tempo, shot cuts, face safe zone, silence & speaking rate |
brief.md | Human-readable understanding brief (transcription timeline + tempo suggestions + hook candidates + effect candidates) |
plan.json | Rendering configuration, pure data, directly editable by hand (scene titles, color scheme, BGM, effects) |
plan.md | Creative plan (storyboard table + effect arrangement + how to modify) |
previews/storyboard.png | Storyboard overview: one representative frame per beat, preview before rendering |
previews/storyboard.html | Clickable storyboard |
out/NN_<style>.mp4 | Final video: 720×1280 / 30fps / original audio preserved |
covers/cover_3x4.png cover_9x16.png | Douyin covers (one large line + one small line + brand tag) |
Getting Started in Four Steps
cd <skill>/scripts
python3 doctor.py # 1) Environment self-check; tells you what's missing
python3 understand.py --input=video.MOV --job=my_job # 2) Understand it
python3 plan.py --job=my_job # 3) Generate plan + storyboard
python3 render.py --job=my_job --export=~/Downloads/delivery # 4) Render final video
<skill> = ~/.workbuddy/skills/auto-video-editor.
After step 3 creates the storyboard, preview it first before rendering: rendering a 30-second video takes about 2–4 minutes; editing plan.json is much cheaper than re-rendering.
How to Use It with an Agent (Important)
The scripts handle facts and defaults, creative decisions are left to the agent / human. So the standard workflow is:
- Run
understand.py, then readbrief.md(transcription may have mishearings, especially company names, amounts, jargon). - Fix obvious transcription errors in the text (you can customize your own terms in the glossary file
assets/glossary.json). - Use
plan.jsonto make creative decisions: break long ASR sentences into short on-screen phrases (≤ 12 characters is best), pick a hook for the cover title, changestyleif needed, modifypalette. - Run
plan.pyto create the storyboard → show it to the user → confirm →render.py.
The default title is "the most information-dense continuous segment from the original text" — it works but isn't aggressive enough. Manually editing
plan.json'sbeats[].titleis the most valuable step in this workflow.
20 Capability Points, 4 Commands
① understand — Understand
# Basic: local transcription (faster-whisper) + frame extraction + face detection + tempo
python3 understand.py --input=video.MOV --job=task_name
python3 understand.py --input=video.MOV --job=task_name --model=medium # More accurate, slower
python3 understand.py --input=video.MOV --job=task_name --lang=auto # Auto-detect language
python3 understand.py --input=video.MOV --job=task_name --no-transcribe # Only video/audio analysis
python3 understand.py --input=video.MOV --job=task_name --samples=24 # Number of face detection frames
Internally, it does this: ffprobe (PyAV) → extract 16k mono audio → faster-whisper transcription (VAD + word-level timestamps) → sentence segmentation by 'paragraph boundary → punctuation → length' → glossary error correction → frame-difference shot detection → frame extraction with Haar face detection to compute 'no-overlap face safe zone' → envelope-based silence/speaking rate calculation → DP splitting sentences into 4–8 beats → scoring and ranking motion effects.
② plan — Arrange
python3 plan.py --job=task_name
python3 plan.py --job=task_name --style=impact # Change effect (see table below)
python3 plan.py --job=task_name --beats=6 # Force 6 beats
python3 plan.py --job=task_name --hook="Cover Big Text" --nodes="Shenzhen,Chengdu,Hangzhou"
python3 plan.py --job=task_name --palette="#8DE0C2,#F5F2E9,#FF9B79"
python3 plan.py --job=task_name --brand-name=IMAI --brand-tagline="AI Digital Employee"
python3 plan.py --job=task_name --no-bgm --no-storyboard
③ render — Produce Final Video
python3 render.py --job=task_name
python3 render.py --job=task_name --styles=route,impact,dashboard # Multiple styles from one source
python3 render.py --job=task_name --max-seconds=8 # Render only first 8 seconds, quick test
python3 render.py --job=task_name --fit=blur # Blur background for horizontal source, don't crop
python3 render.py --job=task_name --crf=17 --preset=slow # Higher quality
python3 render.py --job=task_name --export=~/Downloads/delivery # Copy to delivery directory
④ cover — Cover (can also be regenerated separately)
python3 cover.py --job=task_name
python3 cover.py --job=task_name --ratios=9x16 --big="3 Steps to Get Customers" --small="AI Does the Work"
Motion Effect Library
| id | Name | Suitable For | Visual Actions | Impact |
|---|---|---|---|---|
route | Route Landing | Recruitment / City / Growth / Store Expansion | Route grows, nodes light up in sequence with beat, ripples spread | 4/5 |
impact | Impact Big Text | Opinions / Twists / Emotion / Highlights | Big text slams in, diagonal color blocks wipe in offset, light bursts | 5/5 |
editorial | Minimalist Chapters | Knowledge talking-head / Explanation / Tutorial | Thin line draws in, chapter numbers fade in, tight letter spacing | 2/5 |
dashboard | Data Dashboard | Data / Performance / Cost / Efficiency | Grid fades in, bar charts grow, metrics scroll | 3/5 |
magazine | Magazine Editorial | People / Brand stories / Interviews / Weddings | Masthead pushes in, serif title rises, outline border draws in | 3/5 |
plan.py reads the transcription text, number density, speaking rate, scores each style and ranks them (stored in analysis.json's recommend.candidates). To add a new style: see references/motion-templates.md.
Key Design Decisions (All Learned the Hard Way)
- Face safe zone is calculated, not guessed. 16 frames are extracted for Haar detection, bounding boxes are merged into a single union box, expanded by 8% to create the "no-overlap face safe zone." The motion effects layer then computes two available layout areas (above and below) and automatically selects the wider side for placing cards. For selfie composition (face in lower half), cards go on top, and vice versa. Cards never overflow the safe zone.
- Per-frame screen capture direct pipeline. Each frame PNG is written from Playwright directly into ffmpeg's stdin, saving no intermediate frame files. A 30-second stream of 720×1280 alpha frame sequences would occupy 1GB+ on disk, inevitably filling the disk (manifesting as mysterious browser
TargetClosedError). - Two-step audio loudness normalization. First,
loudnorm print_format=jsonmeasuresinput_i. Then, the measured value is fed back into the secondloudnormpass +alimiteras a fallback. Single-pass normalization is unreliable. - Background music with built-in side chain. BGM is synthesized with numpy by BPM (no copyrighted material), and the spoken audio track's envelope reduces BGM volume by 70% during speech — music automatically ducks when someone talks, no manual adjustment needed.
- Chinese title line-breaking by semantic chunks. Breaking characters one by one would split "客服销售" into "客服销/售". Instead, text is first segmented into chunks (number+unit / English strings / punctuation / 2-character Chinese group), then packed into lines, scaling font size down step by step.
- Sentence segmentation by "paragraph boundary → punctuation → length." Hard-cutting by length alone would break a title mid-sentence ("2026年企业省钱最快的方法不是"). VAD paragraph boundaries naturally fall at breath points, so they are the highest priority; then whisper is given a prompt to "please add punctuation."
- Screenshots must have alpha.
page.screenshot(omit_background=True)+body{background:transparent}, otherwise the effects layer will render the original video completely black. - Headless browsers don't support emoji (rendered as tofu blocks), so templates use pure text only.
- Don't use
nohup … &for long-running tasks in a sandbox — they can be killed by external signals. Use managed background tasks. mkdir(exist_ok=True)can still raise EEXIST when a workspace directory already exists (sandbox broker behavior). So directory creation always goes throughpaths.ensure_dir()(check first, then create).
Where Are the Output Files?
~/AutoVideoEditor/
└── jobs/<task_name>/
├── analysis.json brief.md plan.json plan.md
├── audio/voice.wav audio/music.wav audio/mix.m4a
├── frames/s_*.jpg Sample frames (face detection + storyboard)
├── previews/storyboard.png previews/beat_*.png previews/storyboard.html
├── work/base.mp4 Normalized base video (can be deleted)
├── covers/firstframe.jpg covers/cover_*.png
└── out/NN_<style>.mp4 ✅ Final video
To change workspace: export AVE_WORKSPACE=/path/to/disk.
Output Specifications
| Item | Value |
|---|---|
| Video | 720×1280 / 30fps / H.264 (horizontal source automatically gets blurred background padding, no cropping) |
| Audio | AAC 192k / 48kHz / stereo, original speech as main track + synthesized BGM |
| Loudness | Target -15 LUFS, true peak -1.7 dBFS (two-step method) |
| Quality Control | Audio envelope cross-correlation between output and original video; normally ≥ 0.93; below 0.9 indicates original audio was altered, requiring investigation |
When to Use / When Not to Use
| Scenario | Use or Not |
|---|---|
| Talking-head video needs motion effects, subtitles, music, covers | ✅ Right use |
| One source needs multiple style versions in batch | ✅ Right use (--styles=a,b,c) |
| Need to "understand" video content before deciding how to edit | ✅ Right use |
| Need to change spoken content, replace words, or dub | ❌ Not its job |
| Need to splice multiple clips at edit points | ❌ It does "whole-video packaging", not clip splicing |
Privacy
By default, everything runs locally. Transcription uses local faster-whisper, image understanding uses frame extraction + frame difference + face detection. It calls no cloud models, and video/audio never leaves your machine. Internet connection is only needed for the first download of the Whisper model (approximately 460MB).
Troubleshooting
First, run python3 doctor.py. If it still hangs, see references/troubleshooting.md. For architecture and data flow, see references/architecture.md. To add motion effects, see references/motion-templates.md.