--- name: seams description: Check the quality of every cut boundary in an edit, the micro-fragments, clipped words, mouth sounds and pre-speech faces left at a splice that make an edit feel artificial or "AI-edited". Use for "seams", "/seams", "these cuts feel choppy", "awkward cut", "it doesn't feel natural", "sounds artificial", "words getting cut off", "micro fragments", or when the creator calls out a specific cut. Runs on its own and as the boundary pass inside /edit's review step. Not for jump cuts (those are fine) and not for whether a line belongs (that's /edit). --- You are checking whether every cut in the edit is **clean in and clean out**. `/video-review` asks whether the cut is broken. `/seams` asks whether it's *graceful*. ## What the defect is (and isn't) **Jump cuts aren't the problem.** Viewers are fine with a locked-off talking head that jumps. What gives an edit away is the broken bits left at a splice: a tiny fragment of a word, a word cut off, a mouth click, a face visibly loading up to speak. Those are the tells that make people say "this was cut by a machine." A boundary is clean when **all four** hold: 1. **The outgoing side ends in silence.** No tail of an abandoned word, no mouth sound. 2. **The incoming side begins in silence.** Not on the tail of a half-heard previous sentence. 3. **No micro-fragment survives on either side.** No 100-400 ms burst of sound stranded by a pause. 4. **The face isn't already moving into the next sentence** at the moment of the cut. A cut can be acoustically perfect and still read wrong because the speaker is visibly about to talk. What this is NOT: - **Not a dissolve problem.** A short cross-dissolve over a jump cut does nothing for a seam. Don't reach for one. - **Not** whether a line earns its place. That's `/edit`. ## The defect classes, in words - **Clipped word.** The edge lands inside a word: its last consonant, or its first syllable, is gone. - **Leak.** The next word in the source starts before the audio stops. With `/edit`'s 0.30 s L-cut trail, a cut that ends cleanly on the picture can still carry the first syllable of the next sentence into the next shot. - **Micro-fragment.** A short burst of sound at the very start or end of a piece, cut off from the rest of the piece by a pause. Usually the end of the previous word, a breath, a lip smack, or "I" from a sentence that was never said. - **Mouth sound or breath at the edge.** Sits below speech level but above room tone, so a level threshold on the finished render can't separate it from every other breath. Measure it on the **source**, piece by piece. - **Silent face.** The picture returns to the speaker and they sit there before talking (more than ~0.4 s), or hold after their last word (more than ~0.6 s). - **Loading face.** The mouth opens, the brows lift, the head tips forward just before the cut. Visual only. - **Stumble.** A false start left in: the same few words said twice in a row. ## Why measure at the source, not the render Render-side detectors fail here. On a finished mix, the half-word you hear sits at the same level as every ordinary breath, and music covers it. Reading each voice piece's **own source audio** at its edges, against that clip's room tone, separates them. And Whisper word times aren't cut points: they clip final consonants and stretch across pauses. **The waveform decides, the transcript names the word.** ## Run the check Needs only ffmpeg, numpy, the cut list and the transcripts `/edit` already writes (`edl/_edl.json` or `edl/.json`, and `transcript/.json` with word timestamps). Write this to `render/_review/seam_check.py` once, then run it from the workspace folder: ``` mkdir -p render/_review python3 render/_review/seam_check.py edl/_edl.json transcript/ ``` ```python import json, os, re, subprocess, sys import numpy as np E = json.load(open(sys.argv[1])); TD = sys.argv[2] if len(sys.argv) > 2 else "transcript" SR, F, TRAIL = 16000, 160, 0.30 # 10 ms frames; TRAIL matches assemble.py AUD, FLOOR, HITS = {}, {}, [] def hit(t, msg): HITS.append((t, msg)) def db(x): return 20 * np.log10(max(1e-6, float(np.sqrt(np.mean(x * x)))) if len(x) else 1e-6) def ts(t): return f"{int(t // 60)}:{t % 60:05.2f}" def audio(src): if src not in AUD: raw = subprocess.run(["ffmpeg", "-v", "error", "-i", src, "-vn", "-ac", "1", "-ar", str(SR), "-f", "f32le", "-"], capture_output=True).stdout AUD[src] = a = np.frombuffer(raw, np.float32) FLOOR[src] = np.percentile([db(a[i:i + F]) for i in range(0, len(a) - F, F)], 10) # the clip's room tone return AUD[src] def words(src): p = os.path.join(TD, os.path.splitext(os.path.basename(src))[0] + ".json") if not os.path.exists(p): return [] W = [(re.sub(r"[^\w']", "", w["word"].lower()), w["start"], w["end"]) for s in json.load(open(p))["segments"] for w in s.get("words", [])] return [w for w in W if w[0]] # Whisper emits punctuation as empty tokens # 1. Audible pieces: shots whose sound plays, joined where one shot's audio carries straight on into the next. P, off = [], 0.0 for s in E["timeline"]: mode = s.get("mode", "nat") if s.get("asrc") and mode == "mute": mode = "voice" src, t = (s["asrc"][0], float(s["asrc"][1])) if s.get("asrc") else (s["src"], float(s["sin"])) trail = TRAIL if s.get("trail") is None else float(s["trail"]) if mode in ("voice", "react", "hook", "resolve"): if P and P[-1]["src"] == src and abs(P[-1]["t"] + P[-1]["dur"] - t) < 0.02 and abs(P[-1]["at"] + P[-1]["dur"] - off) < 0.02: P[-1]["dur"] += s["dur"]; P[-1]["trail"] = trail else: P.append({"at": off, "src": src, "t": t, "dur": s["dur"], "trail": trail}) off += s["dur"] kept = [] # the words the viewer hears, in film order for p in P: a, W, t0, t1 = audio(p["src"]), words(p["src"]), p["t"], p["t"] + p["dur"] name, at, end = os.path.basename(p["src"]), p["at"], p["at"] + p["dur"] x = a[int(t0 * SR):int((t1 + p["trail"]) * SR)] e = np.array([db(x[i:i + F]) for i in range(0, max(0, len(x) - F), F)]) if len(x) > F else np.zeros(1) floor = FLOOR[p["src"]]; thr = floor + 12 # 2. Edge rule: sound on BOTH sides of a cut edge means the edge lands inside speech. for edge, side, tl in ((t0, "IN ", at), (t1, "OUT", end)): i, w = int(edge * SR), 640 # 40 ms each side before, after = db(a[max(0, i - w):i]), db(a[i:i + w]) if before > thr and after > thr: hit(tl, f"{side} EDGE-IN-SPEECH {name}@{edge:.2f} {before:.0f}/{after:.0f} dB (floor {floor:.0f})") # 3. Words: an edge cutting through a word, the next word leaking into the trail, a silent lead or tail. for w, ws, we in W: for edge, side, tl in ((t0, "IN ", at), (t1, "OUT", end)): if ws < edge - 0.04 and we > edge + 0.04: hit(tl, f"{side} CUTS-THROUGH '{w}' ({ws:.2f}-{we:.2f}) {name}") if t1 < ws < t1 + p["trail"]: hit(end, f"OUT LEAK '{w}' starts {ws - t1:.2f}s into the trail {name}") inside = [w for w in W if w[1] >= t0 - 0.02 and w[2] <= t1 + 0.02] kept += inside if inside: lead, tail = inside[0][1] - t0, t1 - inside[-1][2] if lead > 0.40: hit(at, f"IN SILENT-LEAD {lead:.2f}s before '{inside[0][0]}' {name}") if tail > 0.60: hit(end, f"OUT SILENT-TAIL {tail:.2f}s after '{inside[-1][0]}' {name}") # 4. Fragment rule: a first or last run of sound of 400 ms or less, cut off from the rest by 120 ms or more. on, runs, i = e > thr, [], 0 while i < len(on): if on[i]: j = i while j < len(on) and on[j]: j += 1 if runs and i - runs[-1][1] < 6: runs[-1] = (runs[-1][0], j) # gaps under 60 ms are inside a word else: runs.append((i, j)) i = j else: i += 1 if len(runs) >= 2: (a0, a1), (b0, _) = runs[0], runs[1] if a0 <= 3 and a1 - a0 <= 40 and b0 - a1 >= 12: hit(at + a0 / 100, f"IN FRAGMENT {(a1 - a0) * 10} ms then {(b0 - a1) * 10} ms pause {name}@{t0 + a0 / 100:.2f}") (y0, y1), (z0, z1) = runs[-2], runs[-1] if len(on) - z1 <= 3 and z1 - z0 <= 40 and z0 - y1 >= 12: hit(at + z0 / 100, f"OUT FRAGMENT {(z1 - z0) * 10} ms after {(z0 - y1) * 10} ms pause {name}@{t0 + z0 / 100:.2f}") # 5. Stumbles: the same 1-4 words said twice in a row in what the viewer hears (a false start left in). k = [w[0] for w in kept] for n in (4, 3, 2, 1): for i in range(len(k) - 2 * n + 1): if k[i:i + n] == k[i + n:i + 2 * n] and (n > 1 or len(k[i]) > 3): hit(-1, f"STUMBLE '{' '.join(k[i:i + n])}' twice: ...{' '.join(k[max(0, i - 4):i + 2 * n + 4])}...") for t, m in sorted(HITS): print((" ... " if t < 0 else ts(t)) + " " + m) print(f"checked {len(P)} audible pieces, {len(kept)} words") ``` Every line it prints is a film timecode, the edge (IN or OUT), the class and the source position. It covers points 1 to 3 and the stumbles. The threshold is the clip's own room tone plus 12 dB, so it works on a lav, a phone mic or a noisy street without tuning. If a whole clip is wall-to-wall speech or wind, its "room tone" is high and the edge rule goes quiet: lean on the word checks for that clip. **Read each hit, don't just count them.** A real short word ("Yes." "Thanks.") after a pause can trip the fragment rule and be fine. A LEAK on the last shot before music or a mute shot is still audible, so it still counts. Confirm a doubtful hit by transcribing a 5 s window around it on its own, which is far more reliable than the whole-clip transcript. ## The face check (point 4): a look, not a measurement For each cut where the picture is on the speaker, pull a strip of frames around the boundary and LOOK: ``` ffmpeg -v error -ss -i render/.mp4 -vf "fps=24,scale=320:-1,tile=8x1" -frames:v 1 render/_review/seam_.jpg ``` The strip covers about a third of a second and the cut lands near the 8th frame. Flag a mouth already opening, a breath in, brows lifting or a head tipping into the next sentence on the outgoing side, and a frozen smile before the first word on the incoming side. ## Fixes, in order of preference 1. **Move the cut into clean silence.** OUT earlier, IN later. This fixes most seams. Cut into nothing, then go into the new sentence. 2. **Shorten or kill the trail** where the next word leaks: set `trail` on that shot so `out + trail` stops ~0.05 s before the next word starts, or `0` for back-to-back jump cuts in the same clip. 3. **L or J cut.** Carry the audio across the picture cut so sound and picture don't change on the same frame. Often the answer to a loading face: cut the picture away a beat early while the line finishes. `/edit`'s renderer gives you a short L-cut through `trail` and a floated line through `asrc`; longer splits are done in Final Cut after `/finalcut`. 4. **Take the other take.** If the clean version of the line exists elsewhere in the footage, use it. 5. **Never a dissolve** to hide a seam. After a fix, re-run the check and re-look at the strip. Don't report a seam fixed until the measurement agrees. ## How the creator judges seams A seam is judged **inside the film**, with the sentence before it and the shot after it. Reels of isolated 2-second clips around every cut look like a mess even when the cuts are fine, and they hide exactly the context the judgement needs. So: use clips and strips as YOUR instrument to confirm a fix landed, and hand the creator the film (or the FCPXML) with a short list of timecodes to look at. If one seam needs their ear, give them one timecode, not a clip. **When a check says the file is catastrophically broken, suspect the check first.** Verify against the source before you show anyone. ## Where it sits - **Standalone:** whenever the creator says a cut feels off, run the check on that cut's EDL and look at the strips. - **Inside `/edit`:** part of the review step, after `assemble.py` and alongside `/video-review`, before the creator watches any render. ## My style (Empty. When the creator calls a cut good or bad, write down where it is, in their words, and what made it so. Anchor on the words either side of the cut, not the timecode: timecodes drift with every re-cut, the words don't. Over time this becomes the creator's own standard.)