raw-cut — Dual-Mode (Audio & Video) Raw Take → Clean Cut
Output:
- Video Mode (
--mode video): one clean.mp4where every line is said once, by the best take, with short even pauses (≈0.15–0.3 s by ear), frame-locked lip-sync, and nothing else changed. - Audio-Only Mode (
--mode audio/--audio-only): one clean 48 kHz stereo PCM.wav(and/or.mp3via--also-mp3) with zero video processing — never encodesmaster.mov, never builds video contact sheets, and never touches video streams even if the input is an.mp4!
Script: scripts/rawcut.py inside this skill folder (skills/raw-cut/scripts/rawcut.py in the full pipeline, or <skill-dir>/scripts/rawcut.py when installed standalone via npx skills add). Requires Python 3 + numpy + ffmpeg 7+ (Pillow needed only in video mode). Always set PYTHONIOENCODING=utf8 on Windows. Run long commands in the background.
Standalone vs. Full Pipeline Paths: Inside the full
agent-video-editorworkspace, write clean outputs tooutputs/audio/clean_cuts/oroutputs/video/clean_cuts/and cache towork/<slug>. When installed standalone as a skill in any other folder, write clean outputs next to the input file (for example<name>_clean.wavor<name>_clean.mp4) and cache in./work/<slug>.
Skill Hygiene Rule: This skill folder contains instructions (
SKILL.md) and scripts (scripts/rawcut.py) ONLY — never store media assets, outputs, or cache files insideskills/raw-cut/.
0. Pick the Right Mode (Audio vs Video)
| User Request | Flag | Behavior | Output Path |
|---|---|---|---|
| "শুধু audio raw cut করো" / "voice clean করো" / faceless video voiceover | --mode audio (or --audio-only) |
0% video work (source_audio.wav only, 5–10× faster, smooth audio crossfades, audio-only verify) |
outputs/audio/clean_cuts/<slug>_clean.wav (add --also-mp3 for .mp3 too) |
| "video সহ raw cut করো" / talking-head or screen-record clean cut | --mode video |
Constant-30 fps master.mov, video contact sheets, xfade + acrossfade, 0-frame lip-sync verify |
outputs/video/clean_cuts/<slug>_clean.mp4 |
| Mode not specified | --mode auto (default) |
Audio output ext (.wav/.mp3/.m4a/.flac) OR audio input OR no video stream → audio; otherwise → video |
Routed automatically |
1. Check the Machine — Once, Not Every Time
$env:PYTHONIOENCODING="utf8"
python skills/raw-cut/scripts/rawcut.py doctor
- The result is cached for 30 days in the OS temp folder (never pollutes the skill folder).
runcalls it automatically. Usedoctor --forceonly when something failed, or when you changed PC, key, or model. - Checks: ffmpeg/ffprobe, Pillow, CPU/RAM/disk, encode speed, API key + audio comprehension test, and latency.
- FAIL → stop and tell the user the exact problem and fix. Never guess-cut with a broken setup.
- WARN → tell the user once, then continue.
Transcription engine order (cheapest reliable option first):
| # | Engine | When | Setup |
|---|---|---|---|
| 1 | Local faster-whisper large-v3 |
NVIDIA GPU + faster-whisper installed |
pip install faster-whisper |
| 2 | Free API: Google AI Studio Gemini (gemini-flash-latest) |
Free key | GEMINI_API_KEY=... (aistudio.google.com) |
| 3 | Router / paid API: OpenAI-compatible audio model | Key set | RAWCUT_BASE_URL+RAWCUT_API_KEY (+RAWCUT_MODEL) |
| – | Local on CPU | Last resort only | Slow (~4× realtime) and weak on Bangla |
Overrides: RAWCUT_ENGINE=local|api, RAWCUT_LOCAL_MODEL, RAWCUT_LANG (default bn). Put keys in env or .env. Never print a key.
A weak model is the #1 cause of missing lines: if speech coverage drops below 88% or any window fails, run prints TRANSCRIPT WEAK and stops safely.
2. Cut — One Command
Audio-Only Mode (Zero Video Processing)
python skills/raw-cut/scripts/rawcut.py run "inputs/raw_audio/<raw>.mp3" "outputs/audio/clean_cuts/<slug>_clean.wav" "work/<slug>" --mode audio --also-mp3
(Works identically even if <raw> is an .mp4 — --mode audio ignores the video track completely. Add --denoise if you want the cut taken from the denoised clean.wav instead of the untouched source_audio.wav.)
Video Mode (Frame-Locked A/V)
python skills/raw-cut/scripts/rawcut.py run "inputs/raw_video/<raw>.mp4" "outputs/video/clean_cuts/<slug>_clean.mp4" "work/<slug>" --mode video
- Steps:
prep→transcribe(24 s overlapping windows, parallel, cached) →takes(group retakes, pick defaults) →cut→verify. - Safe to re-run and resumable from
work/<slug>. - Never overwrites an edited
keep.json. Deletekeep.jsonto re-pick defaults, or deletewindows/+phrases.jsonto re-transcribe. - Single steps:
prep,transcribe,takes,cut W out [--denoise] [--also-mp3],verify W out [--quick].
3. Review Retakes (The Only Judgment Step)
- Audio Mode: Review the printed retake groups and
work/<slug>/takes.json(text, timing, dB, completeness). Default pick is the last complete, full-length take. Changework/<slug>/keep.jsononly if an earlier take is clearly cleaner or more complete, then re-runcut+verify. - Video Mode: Open each contact sheet printed by
run(start | middle | endper attempt). Change the pick only if the default misses words/stumbles OR has eyes closed, hand over face, or big posture shift (prefer lowermove;joinbreaks ties).
Always apply without being asked:
- Drop non-content filler: "ok", "হয়ে গেছে", mic tests, talking off-camera.
- Keep anything carrying new information, even if said once.
- Never reorder lines unless the user asks.
- Partial rescue (first half of one take + second half of another) only at a real pause — tell the user if you do it.
4. Verify — What Must Be True
| Check | Audio Mode | Video Mode |
|---|---|---|
| Duration sync | audio … edl … diff ≤ 50 ms |
video … audio … diff ≤ 33 ms |
| Lip-sync | (skipped — audio-only) | picture offset in frames: all 0 |
joins inside speech |
none |
none |
clips < 0.35 s (stutter) |
none |
none |
pauses > 0.4 s (clear speech) |
none (or one borderline) |
none (or one borderline) |
Fresh transcript (unless --quick) |
Every line once, in order, nothing missing | Every line once, in order, nothing missing |
Report briefly to the user in their language: output path(s), final duration, final clean script, any non-obvious retake drops/choices, and (in video mode) any big head jumps worth hiding with a zoom later.
Why the Script Does What It Does (Don't Undo These)
- Audio-only isolation. Audio mode never decodes or encodes video, writes lossless 48 kHz stereo PCM WAV (
source_audio.wav), and uses smooth 40 ms triangularacrossfadeat silent soft joins so Remotion and DAWs get sample-accurate, click-free audio. - Video sync. Phone video is VFR and often offsets video vs audio start time. Video
prepmakes a constant-30 fps master and trims both streams by time (never frame index). - Transcribe in context. 24 s overlapping windows prevent hallucination; cut points always come from the loudness envelope, never raw transcript timestamps.
- Background voices. Any phrase ≥ 12 dB quieter than the speaker (or tagged background) is dropped.
- Pauses judged by ear. Clear speech (
STRONG_DB15) drives pause planning; short onset/tail (TAIL_IN0.06 /TAIL_OUT0.12 s) prevents clipped syllables; inner pauses > 0.30 s compress to ≈ 0.13 s. - No clipped or leaking retakes. Cut points settle into silence and never cross a dropped neighbour attempt's quietest dip (
lim_lo/lim_hi). - No stutter clips. Joins removing < 0.15 s or leaving clips < 0.35 s merge back when the gap is pure silence.
- Dissolve joins (video). 4-frame
xfade+acrossfadewhen gap < 3 s, head jump < 12, and both sides silent; hard cut otherwise.
