Local video editor for coding agents: 42 FFmpeg tools with a machine-readable contract and an MCP server, for Claude Code, Cursor and Codex. Cut, captions, reframe, loudness, platform exports. No cloud, no API keys.
Python agent-skillsai-agentsaudio-processingcaptionsclaude-codecodexcoding-agentcursorffmpegloudness-normalizationmcpmcp-servermodel-context-protocolpythonsubtitlestranscodingvideovideo-editingvideo-processingwhisper
fix: graphics.py slices an unbreakable overlong word at the column edge, matching caption.py (#259)
Shogo Kajiyamaa2c6e2eeae5d
diff --git a/docs/roadmap.md b/docs/roadmap.mdindex d04f718..94d0adb 100644--- a/docs/roadmap.md+++ b/docs/roadmap.md@@ -17,14 +17,15 @@ minor and `fix` PRs into a patch, so each block below is one or two `feat` PRs p- **planned** — not released. Nothing below a *planned* heading exists in any published version;the feature lines are the intent, not a description of the code.-The released version today is **1.19.1** — `multicam.py --write-project FILE` writes a+The released version today is **1.19.2** — `multicam.py --write-project FILE` writes a`render.py` project that reproduces the tool's own cut decision (eval 21's `mc2` gap, no morehand-translating cuts/offsets into `clips[]`), and `--filler` alone no longer jump-cuts unrelateddead-air silence (eval 19's `fw1`/`fw3`: "remove the ums" silently removed ~5s of unasked-forpauses too; fixed by skipping generic silence detection unless `--speech-aware` is also given).1.19.0 (the `--write-project` feature) is a `feat:` release, hence the minor bump; it does notstart the "1.19.0: observability, portability" theme further down this document, which remains-planned. 1.18.4 (the caption column-edge slice, `cs2`) is unchanged from before; see its own+planned. 1.19.2 is docs-only (SKILL.md's overlong-word and MCP core-12 rows, this same truth-up).+1.18.4 (the caption column-edge slice, `cs2`) is unchanged from before; see its ownsection below.| version | state | evidence |@@ -52,6 +53,7 @@ section below.| 1.18.4 | shipped, eval pending | eval 20's `cs2` (a 32-letter Spanish word still clipping the frame at `--min-size`): `scripts/_common/wrap.py` slices an atom at the column edge (preferring an existing hyphen) only when it does not fit alone even at the floor; `caption.py`'s burn path reports the new `broken_inside_word` stats key. A fitting Thai phrase or katakana run (1.16.1) is provably unchanged — the slice branch is unreachable for an atom that already fits. No new CLI flag, no script added, tool count still 42 || 1.19.0 | shipped, eval pending | `multicam.py --write-project FILE` (eval 21's `mc2` gap): writes a `render.py` project whose `clips[]` reproduces multicam's own cut decision exactly (`src`/`in`/`out` per cut, offset-shifted to each camera's own timeline), for `--switch energy`, a manual `--switch` spec, or `--auto` alike; multicam's own combined render and `--edl`/`--offsets-only` unchanged. `feat:` release, hence the minor bump — not the start of the "1.19.0" theme further down this document, which is unrelated and still planned || 1.19.1 | shipped, eval pending | eval 19's `fw1`/`fw3`: `silence.py --filler` alone (no `--speech-aware`) jump-cut unrelated dead-air silence gaps too, ~5s unasked. Fixed: generic silence detection is skipped unless `--speech-aware` is also given, so `--filler` alone removes only the timed filler-word spans; `--speech-aware` alone and `--filler --speech-aware` combined are unchanged |+| 1.19.2 | shipped, docs-only | SKILL.md rows for 1.18.3's MCP core-12 (previously undocumented) and 1.18.4's overlong-word column-edge slice, plus this document's own roadmap truth-up. No script changes || 1.21.0, 2.0.0 | planned | — |## 1.8.0 — one-call delivery, quieter checks, encoder flags (shipped + evaluated, eval 8)diff --git a/scripts/graphics.py b/scripts/graphics.pyindex bcc2489..9510855 100755--- a/scripts/graphics.py+++ b/scripts/graphics.py@@ -260,6 +260,8 @@ def main() -> int:usable = W - left - right - 2 * padreturn max(0.1, min(SAFE_WIDTH_FRACTION, usable / float(W))) if W else SAFE_WIDTH_FRACTION+ sliced_atoms: List[int] = []+def wrapped(text, size_px, frac=SAFE_WIDTH_FRACTION):"""A label broken to the frame's safe width (1.16).@@ -268,6 +270,12 @@ def main() -> int:the breaks in, at the same measured width and by the same four phrase rules caption.pyuses. A label that already fits comes back unchanged, which is why this is additive: theonly text it touches is text that used to run off the edge of the frame.++ `slice_overlong=True` matches caption.py's burn path (1.18.4): a single atom that is+ still wider than the column even alone -- a long hashtag/URL/name with no break point --+ is hard-sliced at the column's edge (preferring an existing hyphen) rather than left to+ render past the frame. An atom that already fits is never touched, so a fitting Thai+ phrase or katakana run comes through exactly as before."""text = str(text or "")if not text or not size_px:@@ -277,7 +285,8 @@ def main() -> int:return textout = []for para in text.split("\n"):- out.extend(wrap_text(para, max_em, mode=args.wrap, lang=args.lang) if para.strip() else [para])+ out.extend(wrap_text(para, max_em, mode=args.wrap, lang=args.lang,+ slice_overlong=True, sliced=sliced_atoms) if para.strip() else [para])return "\n".join(out)def add_text(text, drawtext, *, target=None, **el):@@ -587,6 +596,8 @@ def main() -> int:extra["ass"] = ass_pathif emoji_result:extra["emoji"] = emoji_result+ if sliced_atoms:+ extra["broken_inside_word"] = len(sliced_atoms)emit(output, **extra)return 0diff --git a/tests/test_picture.py b/tests/test_picture.pyindex 2b9c89c..23f4cc1 100644--- a/tests/test_picture.py+++ b/tests/test_picture.py@@ -2383,6 +2383,85 @@ class EmojiTests(unittest.TestCase):self.assertIn("A \\{b\\} c \\ d", dialogue)+class GraphicsSliceOverlongTests(unittest.TestCase):+ """graphics.py's own `wrapped()` helper (used by lower-third, title, sticker, hook and meme+ labels) now turns on the same `slice_overlong` escape hatch caption.py's burn path turned on+ in 1.18.4, so a single unbreakable overlong atom drawn through a template no longer renders+ past the frame's safe width."""++ @classmethod+ def setUpClass(cls):+ if not shutil.which("ffmpeg"):+ if os.environ.get("CI"):+ raise AssertionError("ffmpeg not on PATH -- in CI this is a broken install step")+ raise unittest.SkipTest("ffmpeg not on PATH")+ OUT.mkdir(parents=True, exist_ok=True)+ cls.src = OUT / "gfx_src.mp4"+ if not cls.src.exists():+ sh("ffmpeg", "-y", "-hide_banner", "-loglevel", "error", "-f", "lavfi",+ "-i", "testsrc2=size=640x360:rate=30", "-f", "lavfi", "-i", "sine=f=440",+ "-t", "6", "-c:v", "libx264", "-preset", "veryfast", "-crf", "24",+ "-pix_fmt", "yuv420p", "-c:a", "aac", cls.src)++ def _dialogue_lines(self, doc):+ ass = Path(doc["ass"]).read_text(encoding="utf-8-sig")+ dialogue = next(l for l in ass.splitlines() if l.startswith("Dialogue:"))+ text = dialogue.split(",", 9)[-1]+ text = re.sub(r"\{[^}]*\}", "", text) # strip the leading {\an5\pos(...)} override block+ return text.split("\\N")++ def _skip_without(self, script_code):+ from _common import script_font_status+ if script_font_status(script_code) != "available":+ raise unittest.SkipTest("no font on this machine covers %r; tests never install fonts"+ % script_code)++ def test_overlong_word_no_longer_clips_a_hook_title(self):+ """The same 32-letter Spanish word from caption's cs2 fixture, with no break point, drawn+ as a --template hook --title at a scale where it used to be kept whole and clip past the+ frame's safe width. Every produced line must now measure within the column."""+ from _common import text_width_em+ word = "Supercalifragilísticoespialidoso"+ out = OUT / "gfx_slice_hook.mp4"+ doc = json.loads(script("graphics.py", self.src, "--template", "hook", "--title", word,+ "--scale", "2", "--text-render", "ass", "-o", out, "--json").stdout)+ base = min(640, 360) * 2.0+ h1 = int(base * 0.085)+ max_em = (640 * 0.9) / h1 # SAFE_WIDTH_FRACTION default+ lines = self._dialogue_lines(doc)+ self.assertGreater(len(lines), 1, "the word should have been sliced into more than one line")+ for line in lines:+ self.assertLessEqual(text_width_em(line), max_em + 1e-6, lines)+ # no character was added, dropped or reordered+ self.assertEqual("".join(lines), word)+ self.assertEqual(doc.get("broken_inside_word"), 1, doc)++ def test_fitting_thai_phrase_stays_unbroken_through_graphics_wrapped(self):+ """A short-enough-to-fit Thai phrase with no natural break point must come back as one+ unbroken line -- the escape hatch is only reachable when an atom does NOT fit alone, and+ this must hold through graphics.py's `wrapped()` specifically, not just wrap.py itself."""+ self._skip_without("th")+ thai = "สวัสดีชาวโลก"+ out = OUT / "gfx_slice_thai.mp4"+ doc = json.loads(script("graphics.py", self.src, "--template", "hook", "--title", thai,+ "--text-render", "ass", "-o", out, "--json").stdout)+ lines = self._dialogue_lines(doc)+ self.assertEqual(lines, [thai], lines)+ self.assertNotIn("broken_inside_word", doc)++ def test_fitting_katakana_run_stays_unbroken_through_graphics_wrapped(self):+ """A short-enough-to-fit katakana run with no natural break point must also come back as+ one unbroken atom, unchanged, through graphics.py's `wrapped()`."""+ self._skip_without("ja")+ kata = "コンピューター"+ out = OUT / "gfx_slice_kata.mp4"+ doc = json.loads(script("graphics.py", self.src, "--template", "hook", "--title", kata,+ "--text-render", "ass", "-o", out, "--json").stdout)+ lines = self._dialogue_lines(doc)+ self.assertEqual(lines, [kata], lines)+ self.assertNotIn("broken_inside_word", doc)++class ShapingTests(unittest.TestCase):"""1.15: drawtext does bidi and Arabic joining on a fribidi build but never reorders orre-clusters. graphics.py routes what it cannot shape through libass; overlay.py refuses."""