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 格式输出。

Localize image labels and pick a compatible Python on install

junea3a33af30a14
diff --git a/docs/cases/dual_role/report_en.md b/docs/cases/dual_role/report_en.md
index 1422460..6482779 100644
--- a/docs/cases/dual_role/report_en.md
+++ b/docs/cases/dual_role/report_en.md
@@ -9,7 +9,7 @@
- Confidence (duration-weighted): 74%; method: deterministic forensics fused with a vision model (VLM)
- VLM active (gemini-3.1-pro-preview, gemini-3.1-pro-preview-pc, gcp-gemini-3-pro-preview); the agent (claude) visually reviewed 1 of 10 shots, merged into the verdict
-![storyboard](storyboard.jpg)
+![storyboard](storyboard_en.jpg)
## Production method share
@@ -107,7 +107,7 @@ One Remotion / HTML project rebuilt from the text tracks and layout (text and UI
## Audio breakdown
-![audio](audio.png)
+![audio](audio_en.png)
- Overall loudness −16.8 dBFS, peak −3.5 dBFS
- **Voice**: present, 79% of duration, fundamental about 247.8 Hz (reads female)
diff --git a/rea_video/visual.py b/rea_video/visual.py
index 5cedf4b..65f4701 100644
--- a/rea_video/visual.py
+++ b/rea_video/visual.py
@@ -7,6 +7,7 @@ import cv2
import numpy as np
from PIL import Image, ImageDraw, ImageFont
+from .i18n import LangDict, T
from .util import fmt_time
LABEL_COLOR = {
@@ -16,11 +17,15 @@ LABEL_COLOR = {
"film_footage": (190, 18, 60),
}
# short names for the storyboard strip (the full names are too long for a 200px cell)
-LABEL_SHORT = {
+LABEL_SHORT = LangDict({
"live_action": "实拍", "ai_video": "AI 视频", "avatar": "数字人", "cg_3d": "3D 渲染", "code_render": "代码渲染",
"screen_capture": "录屏/截图", "still_motion": "静图推拉", "static_hold": "静帧", "anim_2d": "2D 动画",
"stop_motion": "定格动画", "film_footage": "影视片段",
-}
+}, en={
+ "live_action": "Live action", "ai_video": "AI video", "avatar": "Avatar", "cg_3d": "3D render", "code_render": "Code render",
+ "screen_capture": "Screen cap", "still_motion": "Pan/zoom", "static_hold": "Still", "anim_2d": "2D anim",
+ "stop_motion": "Stop motion", "film_footage": "Film clip",
+})
_FONT_CANDIDATES = [
"/System/Library/Fonts/PingFang.ttc", "/System/Library/Fonts/STHeiti Medium.ttc", "/System/Library/Fonts/STHeiti Light.ttc", "/System/Library/Fonts/Hiragino Sans GB.ttc",
"/usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc", "/usr/share/fonts/noto-cjk/NotoSansCJK-Regular.ttc",
@@ -38,6 +43,15 @@ def _font(size: int):
return ImageFont.load_default()
+def _fit_font(d: ImageDraw.ImageDraw, text: str, size: int, max_w: int, min_size: int = 13):
+ """Largest font from `size` down to `min_size` whose rendering of `text` fits in `max_w` pixels."""
+ f = _font(size)
+ while size > min_size and d.textlength(text, font=f) > max_w:
+ size -= 1
+ f = _font(size)
+ return f
+
+
def _to_pil(bgr: np.ndarray) -> Image.Image:
return Image.fromarray(cv2.cvtColor(bgr, cv2.COLOR_BGR2RGB))
@@ -69,7 +83,6 @@ def storyboard(items: list[tuple[np.ndarray, str, str, float, float]], out: Path
"""items: (frame, label, title, start, end)."""
if not items:
return None
- font = _font(21)
small = _font(15)
cells = []
for frame, label, title, st, en in items:
@@ -81,7 +94,7 @@ def storyboard(items: list[tuple[np.ndarray, str, str, float, float]], out: Path
d = ImageDraw.Draw(cell)
color = LABEL_COLOR.get(label, (80, 80, 80))
d.rectangle([0, im.height, cell_w, im.height + bar], fill=color)
- d.text((8, im.height + 4), title, fill=(255, 255, 255), font=font)
+ d.text((8, im.height + 4), title, fill=(255, 255, 255), font=_fit_font(d, title, 21, cell_w - 14))
d.text((8, im.height + 33), f"{st:.1f}–{en:.1f}s", fill=(255, 255, 255), font=small)
d.line([(cell_w - 1, 0), (cell_w - 1, im.height + bar)], fill=(255, 255, 255), width=2) # gap between cells
cells.append(cell)
@@ -125,7 +138,7 @@ def face_presence(frames: list[np.ndarray]) -> float:
def audio_timeline(audio: dict, sfx: list[dict], cuts: list[float], duration: float, out: Path, width: int = 1200) -> Path:
"""Lanes: loudness curve, voice, music (+beats), sfx markers, picture cuts."""
lane_h, top = 26, 24
- lanes = ["响度", "人声", "音乐", "音效", "切镜"]
+ lanes = [T("响度", "Level"), T("人声", "Voice"), T("音乐", "Music"), T("音效", "SFX"), T("切镜", "Cuts")]
h = top + lane_h * len(lanes) + 20
im = Image.new("RGB", (width, h), (250, 250, 249))
d = ImageDraw.Draw(im)
diff --git a/scripts/install_skill.sh b/scripts/install_skill.sh
index cb8a85b..49ea187 100755
--- a/scripts/install_skill.sh
+++ b/scripts/install_skill.sh
@@ -10,11 +10,24 @@ if ! command -v ffmpeg >/dev/null 2>&1 || ! command -v ffprobe >/dev/null 2>&1;
fi
# ---- Python >= 3.10 ----
+# 依赖 onnxruntime 只给已发布的 Python 版本出预编译包;太新的解释器(如刚发布的 3.15)装不上。
+# 自动选择时优先 3.10–3.14,没有才退回更新的版本。
py_ok() { "$1" -c 'import sys; sys.exit(sys.version_info < (3, 10))' 2>/dev/null; }
+py_known() { "$1" -c 'import sys; sys.exit(not ((3, 10) <= sys.version_info[:2] <= (3, 14)))' 2>/dev/null; }
+CANDIDATES="python3 python3.14 python3.13 python3.12 python3.11 python3.10"
PY="${PYTHON_BIN:-}"
if [ -z "$PY" ]; then
- for c in python3 python3.13 python3.12 python3.11 python3.10; do
- if command -v "$c" >/dev/null 2>&1 && py_ok "$c"; then PY="$c"; break; fi
+ for c in $CANDIDATES; do
+ if command -v "$c" >/dev/null 2>&1 && py_known "$c"; then PY="$c"; break; fi
+ done
+fi
+if [ -z "$PY" ]; then
+ for c in $CANDIDATES; do
+ if command -v "$c" >/dev/null 2>&1 && py_ok "$c"; then
+ PY="$c"
+ echo "⚠ 只找到 $("$c" --version 2>&1),依赖 onnxruntime 可能还没有这个版本的安装包。装不上的话装一个 3.12,再 PYTHON_BIN=python3.12 bash $0" >&2
+ break
+ fi
done
fi
if [ -z "$PY" ] || ! py_ok "$PY"; then
@@ -22,6 +35,16 @@ if [ -z "$PY" ] || ! py_ok "$PY"; then
echo " macOS: brew install [email protected];Ubuntu: sudo apt install python3.12 python3.12-venv;然后 PYTHON_BIN=python3.12 bash $0" >&2
exit 1
fi
+echo "使用 $PY($("$PY" --version 2>&1))"
+install_failed() {
+ echo "✗ 安装失败,见上面的输出。" >&2
+ if ! py_known "$PY"; then
+ echo " $("$PY" --version 2>&1) 太新,onnxruntime 等依赖可能还没有对应的安装包。换一个 3.10–3.14 的解释器:PYTHON_BIN=python3.12 bash $0" >&2
+ else
+ echo " 可以换个解释器重试:PYTHON_BIN=python3.12 bash $0" >&2
+ fi
+ exit 1
+}
# rapidocr 依赖 opencv-python,和 rea-video 的 opencv-python-headless 共用 cv2 目录,后装的覆盖先装的。
# 只留 headless 一套:删掉 opencv-python 后强制重装 headless(删除会带走共用文件)。
@@ -41,11 +64,11 @@ if "$PY" -m pip install -e "$ROOT[ocr]" 2>&1 | tee "$log"; [ "${PIPESTATUS[0]}"
elif grep -qi "externally-managed" "$log"; then
echo "系统 Python 不允许直接 pip 安装(PEP 668),改用隔离环境。" >&2
if command -v pipx >/dev/null 2>&1; then
- pipx install --force --python "$PY" -e "$ROOT[ocr]"
+ pipx install --force --python "$PY" -e "$ROOT[ocr]" || install_failed
dedupe_cv pipx runpip rea-video
else
- "$PY" -m venv "$ROOT/.venv"
- "$ROOT/.venv/bin/python" -m pip install -e "$ROOT[ocr]"
+ "$PY" -m venv "$ROOT/.venv" || install_failed
+ "$ROOT/.venv/bin/python" -m pip install -e "$ROOT[ocr]" || install_failed
dedupe_cv "$ROOT/.venv/bin/python" -m pip
mkdir -p "$HOME/.local/bin"
ln -sfn "$ROOT/.venv/bin/rea-video" "$HOME/.local/bin/rea-video"
@@ -53,8 +76,7 @@ elif grep -qi "externally-managed" "$log"; then
case ":$PATH:" in *":$HOME/.local/bin:"*) ;; *) echo "⚠ ~/.local/bin 不在 PATH 里,把它加进 shell 配置。" >&2 ;; esac
fi
else
- echo "✗ pip 安装失败,见上面的输出。" >&2
- exit 1
+ install_failed
fi
# ---- 链接 skill:只链到已经装了的 agent(都没装就链到 ~/.claude/skills) ----
diff --git a/skills/rea-video/references/setup.md b/skills/rea-video/references/setup.md
index a647606..ccd278a 100644
--- a/skills/rea-video/references/setup.md
+++ b/skills/rea-video/references/setup.md
@@ -11,6 +11,8 @@ rea-video --help
pip 报 `externally-managed-environment`(Homebrew / 新版 Ubuntu 的系统 Python)时,不要加 `--break-system-packages`,改用
`pipx install "rea-video[ocr] @ git+https://github.com/JuneYaooo/rea-video"`,或直接跑 `install_skill.sh`(会自动改用 pipx 或仓库内 `.venv`)。
+报 `onnxruntime` 找不到匹配的安装包(如 `no wheels with a matching Python ABI tag`)时,是默认 Python 太新、依赖还没出对应版本:换一个 3.10–3.14 的解释器,`pipx install --python python3.12 "rea-video[ocr] @ git+https://github.com/JuneYaooo/rea-video"` 或 `PYTHON_BIN=python3.12 bash scripts/install_skill.sh`。`install_skill.sh` 自动选解释器时已经优先 3.10–3.14。
+
手动装了 `[ocr]` 时,OCR 依赖会再装一套 `opencv-python`,和 rea-video 用的 `opencv-python-headless` 抢同一个 `cv2` 目录。装完跑一次:
`pip uninstall -y opencv-python && pip install --force-reinstall --no-deps "opencv-python-headless>=4.8,<5"`(`install_skill.sh` 会自动做)。
diff --git a/tests/test_i18n.py b/tests/test_i18n.py
index 2932907..8253879 100644
--- a/tests/test_i18n.py
+++ b/tests/test_i18n.py
@@ -1,3 +1,5 @@
+import re
+
from rea_video.i18n import LangDict, T, join, set_lang
from rea_video.classify import LABEL_ZH
@@ -26,3 +28,16 @@ def test_unknown_language_rejected():
with pytest.raises(ValueError):
set_lang("fr")
+
+
+def test_image_labels_follow_language():
+ from rea_video.visual import LABEL_SHORT
+
+ try:
+ set_lang("en")
+ assert LABEL_SHORT["code_render"] == "Code render"
+ assert not any(re.search(r"[㐀-鿿]", v) for v in LABEL_SHORT.values())
+ set_lang("zh")
+ assert LABEL_SHORT["code_render"] == "代码渲染"
+ finally:
+ set_lang("zh")