Skip to content

Reverse-engineer any video, shot by shot: filmed, AI-generated or coded, and how to remake it. Breakdowns in the open VIDEO.md format. 逆向一切视频,逐个镜头看是拍的、AI 生成的还是代码做的,再告诉你怎么复刻;拆解结果按 VIDEO.md 格式输出。

Keep Chinese punctuation and model-name notes out of English reports

Christopher Pruijsen49b2c4f33b26
diff --git a/rea_video/i18n.py b/rea_video/i18n.py
index 4b34f3c..337f289 100644
--- a/rea_video/i18n.py
+++ b/rea_video/i18n.py
@@ -12,6 +12,7 @@ The language is set once per run (`set_lang`), from `--lang` / prefs, and stored
from __future__ import annotations
import contextvars
+import re
from collections.abc import Mapping
from typing import Iterator
@@ -38,6 +39,12 @@ def T(zh: str, en: str | None = None, **kw) -> str:
return s.format(**kw) if kw else s
+def model_name(name: str | None) -> str | None:
+ if not name or _lang.get() == "zh":
+ return name
+ return re.sub(r"\s*(([^)]*))", lambda m: "" if re.search(r"[\u3400-\u9fff]", m[1]) else f" ({m[1]})", name)
+
+
def sep() -> str:
"""List separator: 、 in Chinese, ", " in English."""
return "、" if _lang.get() == "zh" else ", "
diff --git a/rea_video/plan.py b/rea_video/plan.py
index 0b361e0..131ed7f 100644
--- a/rea_video/plan.py
+++ b/rea_video/plan.py
@@ -7,7 +7,7 @@ from pathlib import Path
import yaml
-from .i18n import LangDict, T, join, semi
+from .i18n import LangDict, T, join, model_name, semi
CAP = Path(__file__).resolve().parent / "capabilities"
@@ -266,7 +266,7 @@ class Planner:
continue
zh, rule_id, how = AI_EDITS[e["kind"]]
zh_en, how_en = AI_EDITS_EN[e["kind"]]
- names = [self.models[m]["name"] for m in (self.rules.get(rule_id) or {}).get("prefer", [])
+ names = [model_name(self.models[m]["name"]) for m in (self.rules.get(rule_id) or {}).get("prefer", [])
if m in self.models and self.models[m]["status"] != "shutdown"][:3]
out.append({"kind": e["kind"], "kind_zh": T(zh, zh_en), "evidence": str(e.get("evidence", ""))[:120], "rule": rule_id,
"how": T(how, how_en) + (T("({n})", " ({n})", n=" / ".join(names)) if names else "")})
@@ -275,7 +275,7 @@ class Planner:
def plan_shot(self, label: str, shot: dict, video: dict, engine: str = "seedance2.0") -> dict:
rule_id, executor, gen_type = LABEL_ROUTE.get(label, ("R14-ambient-broll", "capsule_cinema", "text_to_video"))
rule = self.rules.get(rule_id, {})
- candidates = [{"id": m, "name": self.models[m]["name"], "status": self.models[m]["status"]}
+ candidates = [{"id": m, "name": model_name(self.models[m]["name"]), "status": self.models[m]["status"]}
for m in rule.get("prefer", []) if m in self.models and self.models[m]["status"] != "shutdown"]
plan = {"label": label, "rule": rule_id, "route": rule.get("route", []), "candidates": candidates,
"verify": rule.get("verify", []), "executor": executor, "note": NOTE.get(label, "")}
diff --git a/rea_video/probe.py b/rea_video/probe.py
index 1f90cbc..7feada2 100644
--- a/rea_video/probe.py
+++ b/rea_video/probe.py
@@ -169,9 +169,9 @@ def provenance(info: VideoInfo) -> dict:
# cameras (Pixel, Leica ...) sign C2PA too: only a generator named alongside the manifest counts as AI
named = hints["generator_weak"]
evidence.append({"kind": "c2pa", "detail": T("发现 C2PA/JUMBF 内容凭证盒", "C2PA / JUMBF content-credential box found")
- + (f"({', '.join(named)})" if named else ""), "weight": "strong" if named else "medium"})
+ + (T("({n})", " ({n})", n=", ".join(named)) if named else ""), "weight": "strong" if named else "medium"})
if named:
- hints["generator"].append(T("C2PA 凭证", "C2PA credential") + ":" + ", ".join(n.rstrip("?") for n in named))
+ hints["generator"].append(T("C2PA 凭证", "C2PA credential") + T(":", ": ") + ", ".join(n.rstrip("?") for n in named))
if hints["camera"]:
evidence.append({"kind": "camera_tags", "detail": "; ".join(hints["camera"][:4]), "weight": "strong"})
diff --git a/rea_video/production.py b/rea_video/production.py
index aa55bed..86a4d11 100644
--- a/rea_video/production.py
+++ b/rea_video/production.py
@@ -10,7 +10,7 @@ Edit shots (cut detection) are the facts; making them is organised differently:
"""
from __future__ import annotations
-from .i18n import LangDict, T, join, semi
+from .i18n import LangDict, T, join, model_name, semi
from pathlib import Path
@@ -299,7 +299,7 @@ def _unit(seg: list[dict], k: int, lim: dict, model: dict | None, style: str, ca
unit = {"id": f"G{k}", "kind": "generate", "label": label, "label_zh": LABEL_ZH[label],
"shots": [r["index"] for r in seg], "start": round(t0, 3), "end": round(t1, 3), "duration": dur,
"ranges": [[round(a, 3), round(z, 3)] for a, z in ranges],
- "mode": mode, "calls": parts, "model": (model or {}).get("id"), "model_name": (model or {}).get("name"),
+ "mode": mode, "calls": parts, "model": (model or {}).get("id"), "model_name": model_name((model or {}).get("name")),
"generate_s": max(dur, lim["min"], unit_min if len(seg) == 1 else 0), "refs": refs, "continuity": cont,
"prompt": T("。", ". ").join(head) + T("。\n", ".\n") + "\n".join(lines),
"prompt_en": "\n".join(lines_en) if len(lines_en) == len(seg) else "",
@@ -400,7 +400,7 @@ def production_plan(b: dict, out: Path, engine: str = "seedance2.0") -> dict:
units.sort(key=lambda u: u["start"])
for k, u in enumerate(units, 1):
u["id"] = f"G{k}"
- plan: dict = {"model": (model or {}).get("id"), "model_name": (model or {}).get("name"),
+ plan: dict = {"model": (model or {}).get("id"), "model_name": model_name((model or {}).get("name")),
"model_limits": {k: lim[k] for k in ("max", "min", "multi_shot", "ref_video", "native_audio")},
"rules": {"hardcut_s": hard, "same_scene_distance": thr}, "units": units}
gen_shots = sum(len(u["shots"]) for u in units)
@@ -410,9 +410,9 @@ def production_plan(b: dict, out: Path, engine: str = "seedance2.0") -> dict:
plan["gen_shots"] = gen_shots
if eng and model and eng["id"] != model["id"]:
plan["engine_note"] = T("默认引擎 {e} 不支持一次多镜头,用它要逐镜生成 {n} 次;这里按 {m} 规划(单次 ≤{mx:.0f}s、可一次出多镜头),共 {c} 次",
- "The default engine {e} cannot generate several shots in one call; with it you would generate shot by shot, {n} times. "
+ "The default engine {e} cannot generate several shots in one call; with it you would generate shot by shot, {n} time{ns}. "
"This plan is for {m} (≤{mx:.0f}s per call, multi-shot in one call), {c} call{cs} in total",
- e=eng["name"], n=gen_shots, m=model["name"], mx=lim["max"], c=calls, cs=_s(calls))
+ e=model_name(eng["name"]), n=gen_shots, ns=_s(gen_shots), m=model_name(model["name"]), mx=lim["max"], c=calls, cs=_s(calls))
voice = ((b.get("audio") or {}).get("voice") or {}).get("present")
if lim["native_audio"]:
plan["audio_note"] = T("模型可以同时生成动作音效和环境声", "the model can generate action sound effects and ambience along with the picture") + \
diff --git a/rea_video/report.py b/rea_video/report.py
index 7ba785b..843b996 100644
--- a/rea_video/report.py
+++ b/rea_video/report.py
@@ -420,7 +420,7 @@ def packaging_md(b: dict) -> list[str]:
why.append(T("跨切镜不变", "unchanged across a cut"))
if st.get("disappears_mid_shot"):
why.append(T("镜头中途出现又消失", "appears and disappears mid-shot"))
- conf = CONF_ZH.get(st.get("confidence"), st.get("confidence", "")) + (("(" + join(why) + ")") if why else "")
+ conf = CONF_ZH.get(st.get("confidence"), st.get("confidence", "")) + (T("({w})", " ({w})", w=join(why)) if why else "")
rows.append([f"{st['t0']:.2f}–{st['t1']:.2f}s", st["kind_zh"], where, dyn, conf, f"![{st['id']}]({st['image']})" if st.get("image") else "—"])
L += ["", T("**贴纸 / 动图 / 画中画**", "**Stickers / GIFs / picture-in-picture**")]
L += _table([T("时间", "Time"), T("类型", "Kind"), T("位置", "Position"), T("动态", "Motion"), T("置信", "Confidence"), T("截图", "Crop")], rows)
@@ -496,7 +496,7 @@ def _shot_detail_md(r: dict) -> list[str]:
base = r["base"]
L = [f"![{r['id']}]({r['assets']['sheet']})", ""]
probs = sorted(base["probs"].items(), key=lambda kv: -kv[1])[:3]
- L.append(T("- 概率:", "- Probabilities: ") + T(",", ", ").join(f"{LABEL_ZH[k]} {v:.0%}" for k, v in probs) + f"({base['decided_by']})")
+ L.append(T("- 概率:", "- Probabilities: ") + T(",", ", ").join(f"{LABEL_ZH[k]} {v:.0%}" for k, v in probs) + T("({d})", " ({d})", d=base["decided_by"]))
for key, name in (("uncertain", T("待确认", "To confirm")), ("disputed", T("有分歧", "Disputed"))):
if base.get(key):
L.append(f"- ⚠️ {name}{_colon()}{base[key]}")
diff --git a/tests/test_production.py b/tests/test_production.py
index b7eaa8f..5b4a3d4 100644
--- a/tests/test_production.py
+++ b/tests/test_production.py
@@ -1,9 +1,11 @@
"""Production plan: AI shots grouped into generation units, filmed shots into shooting setups."""
+import re
from pathlib import Path
import cv2
import numpy as np
+from rea_video.i18n import set_lang
from rea_video.plan import Planner
from rea_video.production import _limits, _split_run, pick_model, production_plan
@@ -120,3 +122,14 @@ def test_framing_goes_into_capsule_prompt():
assert _with_framing("女生在厨房切菜", zh) == zh + "。女生在厨房切菜"
assert _with_framing("近景,略俯拍,主体在画面下部左侧,镜头推,切菜", zh).startswith("近景,略俯拍,主体") # nothing added twice
assert _with_framing("", zh) == ""
+
+
+def test_english_engine_note_has_no_chinese(tmp_path):
+ set_lang("en")
+ try:
+ plan = production_plan(_b([_shot(1, 0.0, 3.0, "ai_video", KITCHEN, tmp_path)]), tmp_path)
+ finally:
+ set_lang("zh")
+ note = plan["engine_note"]
+ assert "shot by shot, 1 time." in note
+ assert not re.search(r"[\u3000-\u303f\u4e00-\u9fff\uff00-\uffef]", note + plan["model_name"])
diff --git a/tests/test_report.py b/tests/test_report.py
index 692a27f..f7a3d75 100644
--- a/tests/test_report.py
+++ b/tests/test_report.py
@@ -99,6 +99,15 @@ def test_markdown_without_vlm_still_complete(breakdown):
set_lang("zh")
+def test_english_markdown_has_no_chinese_punctuation(media, tmp_path):
+ try:
+ md_en = markdown(decompose(media["edit"], tmp_path / "edit", use_vlm=False, ocr=False, stems=False, lang="en"))
+ finally:
+ set_lang("zh")
+ assert "Probabilities: " in md_en
+ assert not re.findall(r"[():,、;]", md_en)
+
+
def test_html_is_rendered_from_markdown(breakdown):
b, _ = breakdown
set_lang("zh")