Communitygithub.com

lijianguo1121-bit/auto-video-editor

A talking-head video editing workspace: 'Read it, then cut it.' Drop in a talking-head video, and it automatically understands the content (local transcription, sentence segmentation, frame extraction, shot detection, face safe zone, silence & speaking rate) to produce an editing plan and storyboard. After selecting motion effects, it renders the final video frame-by-frame and generates Douyin covers. 100% preserves original audio and lip sync, all processing stays local.

What is auto-video-editor?

Auto Video Editor is a local-first AI agent skill designed for editing talking-head short videos (like those for Douyin/TikTok). Its core philosophy is 'understand before cutting' — it first analyzes a video to extract structured facts (transcription with word-level timestamps, sentence segmentation, speaking rate, silence gaps, shot boundaries, face safe zones) into a JSON analysis. Then, it generates a human-readable brief and a configurable plan (plan.json) that is easy to manually tweak. The skill is notable for preserving the original audio track entirely; it never uses AI voice cloning, lip-sync modification, or speech replacement. Instead, it overlays a web-based motion effects layer on top of the original video, capturing frames via Playwright and piping them directly into ffmpeg—no intermediate frame files are saved to disk, which avoids disk space issues. It uses a built-in motion effect library (5 styles: route, impact, editorial, dashboard, magazine) that it scores and recommends based on video content. It also generates Douyin covers automatically. The skill is fully local: transcription runs via faster-whisper, facial detection uses OpenCV Haar cascades, and no data leaves the machine. It supports command-line workflows (understand → plan → render → cover) and produces output in a structured job directory. Key design decisions include: computing face safe zones from detected bounding boxes, two-step loudness normalization (loudnorm + alimiter), Chinese text line-breaking by semantic chunks (not character-by-character), and side-chain compression for background music that automatically ducks during speech. The skill is ideal for adding effects, subtitles, music, and covers to a single talking-head video, but it is not designed for splicing multiple clips or altering spoken content.

Works with~Claude Code~Codex CLI~Cursor
npx skills add lijianguo1121-bit/auto-video-editor

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

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:

  1. 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.
  2. 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

OutputDescription
analysis.jsonStructured facts: duration / aspect ratio / frame rate, transcription sentences, tempo, shot cuts, face safe zone, silence & speaking rate
brief.mdHuman-readable understanding brief (transcription timeline + tempo suggestions + hook candidates + effect candidates)
plan.jsonRendering configuration, pure data, directly editable by hand (scene titles, color scheme, BGM, effects)
plan.mdCreative plan (storyboard table + effect arrangement + how to modify)
previews/storyboard.pngStoryboard overview: one representative frame per beat, preview before rendering
previews/storyboard.htmlClickable storyboard
out/NN_<style>.mp4Final video: 720×1280 / 30fps / original audio preserved
covers/cover_3x4.png cover_9x16.pngDouyin 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:

  1. Run understand.py, then read brief.md (transcription may have mishearings, especially company names, amounts, jargon).
  2. Fix obvious transcription errors in the text (you can customize your own terms in the glossary file assets/glossary.json).
  3. Use plan.json to make creative decisions: break long ASR sentences into short on-screen phrases (≤ 12 characters is best), pick a hook for the cover title, change style if needed, modify palette.
  4. Run plan.py to 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's beats[].title is 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

idNameSuitable ForVisual ActionsImpact
routeRoute LandingRecruitment / City / Growth / Store ExpansionRoute grows, nodes light up in sequence with beat, ripples spread4/5
impactImpact Big TextOpinions / Twists / Emotion / HighlightsBig text slams in, diagonal color blocks wipe in offset, light bursts5/5
editorialMinimalist ChaptersKnowledge talking-head / Explanation / TutorialThin line draws in, chapter numbers fade in, tight letter spacing2/5
dashboardData DashboardData / Performance / Cost / EfficiencyGrid fades in, bar charts grow, metrics scroll3/5
magazineMagazine EditorialPeople / Brand stories / Interviews / WeddingsMasthead pushes in, serif title rises, outline border draws in3/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)

  1. 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.
  2. 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).
  3. Two-step audio loudness normalization. First, loudnorm print_format=json measures input_i. Then, the measured value is fed back into the second loudnorm pass + alimiter as a fallback. Single-pass normalization is unreliable.
  4. 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.
  5. 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.
  6. 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."
  7. Screenshots must have alpha. page.screenshot(omit_background=True) + body{background:transparent}, otherwise the effects layer will render the original video completely black.
  8. Headless browsers don't support emoji (rendered as tofu blocks), so templates use pure text only.
  9. Don't use nohup … & for long-running tasks in a sandbox — they can be killed by external signals. Use managed background tasks.
  10. mkdir(exist_ok=True) can still raise EEXIST when a workspace directory already exists (sandbox broker behavior). So directory creation always goes through paths.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

ItemValue
Video720×1280 / 30fps / H.264 (horizontal source automatically gets blurred background padding, no cropping)
AudioAAC 192k / 48kHz / stereo, original speech as main track + synthesized BGM
LoudnessTarget -15 LUFS, true peak -1.7 dBFS (two-step method)
Quality ControlAudio 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

ScenarioUse 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.

Related Skills