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

Add --ocr-lang ko: Korean subtitle OCR

Choihello76162e7114d9
diff --git a/docs/cli.md b/docs/cli.md
index 2bb94a0..e91c7ca 100644
--- a/docs/cli.md
+++ b/docs/cli.md
@@ -92,7 +92,7 @@ rea-video capsule-draft out/ref/breakdown.json --capsule-root $CC --capsule-name
| 命令 | 作用 |
|---|---|
-| `decompose VIDEO [--vlm] [--no-ocr] [--ocr-lang zh\|ja] [--lang zh\|en] [--no-packaging] [--max-vlm-shots N] [--no-asr] [--asr-lang auto\|bn] [--no-speakers]` | 拆解,输出 breakdown.json、report.html/md、拆片包(`VIDEO.md` + `video/`)、storyboard.jpg、每镜首尾帧,`packaging/`(字幕 SRT、带样式的 ASS、包装时间轴、贴纸截图),以及 `sfx/`(每处音效从原片剪出的一小段,报告音效表里可直接试听);`--lang en` 让结论、报告、`summary` 输出和 VLM 描述都用英文(默认中文;agent 按用户提问的语言选,`rea-video prefs lang en` 可设成默认;breakdown.json 里的 `*_zh` 字段名保留,内容跟报告语言走);`--no-packaging` 跳过包装层(省约每分钟 30–50 秒);`--ocr-lang ja` 用日文识别模型读字幕和花字(首次使用自动下载约 10 MB 到 `$REA_VIDEO_MODELS`,离线时可用 `$REA_OCR_REC_MODEL` 指向本地模型),`rea-video prefs ocr_lang ja` 可设成默认;`--max-vlm-shots N` 是最多发给 VLM 的调用数(默认 60),镜头更多时先看最拿不准的,其余只靠确定性取证,`VLM:` 一行会写明送了多少个;装了可选的 `rea-video[asr]` 时会在人声干声上做本地语音识别,带时间的台词写进 `speech.lines` 和报告的脚本表(机器听写,未校对),`--no-asr` 跳过;台词是孟加拉语时加 `--asr-lang bn`,换用孟加拉语识别模型(SenseVoice 不认孟加拉语,会听成英/日/韩文;首次使用自动下载约 90 MB 到 `$REA_VIDEO_MODELS`),`rea-video prefs asr_lang bn` 可设成默认 |
+| `decompose VIDEO [--vlm] [--no-ocr] [--ocr-lang zh\|ja\|ko] [--lang zh\|en] [--no-packaging] [--max-vlm-shots N] [--no-asr] [--asr-lang auto\|bn] [--no-speakers]` | 拆解,输出 breakdown.json、report.html/md、拆片包(`VIDEO.md` + `video/`)、storyboard.jpg、每镜首尾帧,`packaging/`(字幕 SRT、带样式的 ASS、包装时间轴、贴纸截图),以及 `sfx/`(每处音效从原片剪出的一小段,报告音效表里可直接试听);`--lang en` 让结论、报告、`summary` 输出和 VLM 描述都用英文(默认中文;agent 按用户提问的语言选,`rea-video prefs lang en` 可设成默认;breakdown.json 里的 `*_zh` 字段名保留,内容跟报告语言走);`--no-packaging` 跳过包装层(省约每分钟 30–50 秒);`--ocr-lang ja` 用日文识别模型读字幕和花字(首次使用自动下载约 10 MB 到 `$REA_VIDEO_MODELS`,离线时可用 `$REA_OCR_REC_MODEL` 指向本地模型),`rea-video prefs ocr_lang ja` 可设成默认;`--ocr-lang ko` 同理用韩文识别模型(PP-OCRv5,约 14 MB),并关掉文字方向分类(它会把韩文行误判成倒置、读成乱码);`--max-vlm-shots N` 是最多发给 VLM 的调用数(默认 60),镜头更多时先看最拿不准的,其余只靠确定性取证,`VLM:` 一行会写明送了多少个;装了可选的 `rea-video[asr]` 时会在人声干声上做本地语音识别,带时间的台词写进 `speech.lines` 和报告的脚本表(机器听写,未校对),`--no-asr` 跳过;台词是孟加拉语时加 `--asr-lang bn`,换用孟加拉语识别模型(SenseVoice 不认孟加拉语,会听成英/日/韩文;首次使用自动下载约 90 MB 到 `$REA_VIDEO_MODELS`),`rea-video prefs asr_lang bn` 可设成默认 |
| `review OUT_DIR` | 给能看图的 agent 生成逐镜看图任务(review_tasks.json)和答案模板(review_answers.json) |
| `apply-review OUT_DIR [ANSWERS] [--by NAME] [--lang zh\|en]` | 把 agent 看图的答案和确定性结果融合,重写 breakdown.json 和报告;`--lang` 可以在这一步换报告语言(结论、证据和报告文字重新生成,VLM 已写好的描述和提示词保持原语言) |
| `correct OUT_DIR --shots N --label L [--real yes/no] [--note]` | 用户指出判错:改正结论和报告,并记入记忆(以后同一文件自动套用,同类镜头复核时提示) |
diff --git a/rea_video/cli.py b/rea_video/cli.py
index 17a9dd7..ed829c0 100644
--- a/rea_video/cli.py
+++ b/rea_video/cli.py
@@ -614,7 +614,7 @@ def main(argv: list[str] | None = None) -> int:
d.add_argument("--no-vlm", action="store_true", help="本次不开 VLM(覆盖 prefs 里的 vlm=on)")
d.add_argument("--no-whole", action="store_true", help="跳过整片结构/文案 VLM 分析")
d.add_argument("--no-ocr", action="store_true", help="不做 OCR(字幕/花字时间轴也会跳过,只剩贴纸检测)")
- d.add_argument("--ocr-lang", choices=OCR_LANGS, help="字幕/花字的语言:zh 中英(默认)、ja 日文(首次使用自动下载识别模型);也可用 prefs ocr_lang 设成默认")
+ d.add_argument("--ocr-lang", choices=OCR_LANGS, help="字幕/花字的语言:zh 中英(默认)、ja 日文、ko 韩文(后两种首次使用自动下载识别模型);也可用 prefs ocr_lang 设成默认")
d.add_argument("--no-packaging", action="store_true", help="跳过剪辑包装层(整片字幕时间轴、花字、贴纸/动图、音效卡点);省掉约每分钟 30–50 秒")
d.add_argument("--lang", choices=LANGS, help="报告、结论和 VLM 描述的语言:zh(默认)/ en;按用户提问的语言选,也可用 prefs lang 设成默认")
d.add_argument("--workers", type=int, default=3)
diff --git a/rea_video/memory.py b/rea_video/memory.py
index 5798d2b..fc02eec 100644
--- a/rea_video/memory.py
+++ b/rea_video/memory.py
@@ -26,7 +26,7 @@ PREF_KEYS = {
"env_file": "默认的 VLM 配置文件(等同每次加 --env-file)",
"stems": "decompose 是否默认做人声/配乐分离:on / off",
"reviewer": "apply-review 默认的复核者名字",
- "ocr_lang": "字幕/花字 OCR 的语言:zh(中英,默认)/ ja(日文,首次使用自动下载约 10 MB 识别模型)",
+ "ocr_lang": "字幕/花字 OCR 的语言:zh(中英,默认)/ ja(日文,首次使用自动下载约 10 MB 识别模型)/ ko(韩文,首次使用自动下载约 14 MB 识别模型)",
"asr_lang": "本地语音识别的语言:auto(SenseVoice 自动识别中/英/日/韩/粤,默认)/ bn(孟加拉语,首次使用自动下载约 90 MB 识别模型)",
"capsule_root": "capsule-cinema 仓库位置(remake-plan / remake-run / capsule-draft 的 --capsule-root;也可设 $CAPSULE_CINEMA_ROOT)",
"lang": "报告和结论的语言:zh(默认)/ en;agent 应按用户提问的语言选,用户明确指定时以指定为准",
diff --git a/rea_video/overlay.py b/rea_video/overlay.py
index 7a0f025..0c704f5 100644
--- a/rea_video/overlay.py
+++ b/rea_video/overlay.py
@@ -24,7 +24,16 @@ _REC_MODELS = {
"ja": ("japan_PP-OCRv4_rec_mobile.onnx",
"https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/v3.10.0/onnx/PP-OCRv4/rec/japan_PP-OCRv4_rec_mobile.onnx",
"e1075a67dba758ecfc7ebc78a10ae61c95ac8fb66a9c86fab5541e33f085cb7a"),
+ # PP-OCRv5: the v5 Korean recognizer is smaller than v4 (13.5 vs 24 MB) and read more lines exactly on
+ # Korean subtitles drawn over real frames (see _NO_ANGLE_CLS for the other half of making Korean work)
+ "ko": ("korean_PP-OCRv5_rec_mobile.onnx",
+ "https://www.modelscope.cn/models/RapidAI/RapidOCR/resolve/v3.10.0/onnx/PP-OCRv5/rec/korean_PP-OCRv5_rec_mobile.onnx",
+ "cd6e2ea50f6943ca7271eb8c56a877a5a90720b7047fe9c41a2e541a25773c9b"),
}
+# Languages read without the text-direction classifier. The bundled classifier flips many Hangul line crops
+# by 180 degrees, and the recognizer then reads the upside-down line as noise ("단 3분 만에 완성되는 초간단
+# 레시피" -> "피 극궁어") or drops it under the score floor. Subtitles and captions are upright anyway.
+_NO_ANGLE_CLS = {"ko"}
_OCR: dict = {} # language -> RapidOCR instance, or None when it could not be loaded
@@ -73,12 +82,14 @@ class _RapidOCR3:
"""rapidocr 3.x (used on Python >= 3.13, where rapidocr-onnxruntime has no release) behind the
rapidocr-onnxruntime call shape: ocr(img) -> ([[box, text, score], ...] or None, elapse)."""
- def __init__(self, rec_model_path: str | None = None):
+ def __init__(self, rec_model_path: str | None = None, use_cls: bool | None = None):
from rapidocr import RapidOCR # type: ignore
params = {"Global.log_level": "warning"}
if rec_model_path: # its character list is read from the ONNX metadata, as with rapidocr-onnxruntime
params["Rec.model_path"] = rec_model_path
+ if use_cls is not None:
+ params["Global.use_cls"] = use_cls
self._ocr = RapidOCR(params=params)
def __call__(self, img):
@@ -102,6 +113,8 @@ def get_ocr():
if lang not in _OCR:
try:
kwargs = {"rec_model_path": str(rec_model(lang))} if lang in _REC_MODELS else {}
+ if lang in _NO_ANGLE_CLS:
+ kwargs["use_cls"] = False # rapidocr-onnxruntime takes it as a constructor option too
_OCR[lang] = _ocr_engine(**kwargs)
except Exception as exc: # pragma: no cover - optional dependency / offline
LOG.warning("OCR disabled (pip install 'rea-video[ocr]' to enable; lang=%s): %s", lang, exc)
diff --git a/rea_video/util.py b/rea_video/util.py
index 75725a9..5a1d3a0 100644
--- a/rea_video/util.py
+++ b/rea_video/util.py
@@ -9,7 +9,7 @@ from pathlib import Path
from typing import Any, Iterable
LOG = logging.getLogger("rea_video")
-OCR_LANGS = ("zh", "ja") # subtitle/huazi OCR languages; zh is the bundled recognizer, others are in overlay._REC_MODELS
+OCR_LANGS = ("zh", "ja", "ko") # subtitle/huazi OCR languages; zh is the bundled recognizer, others are in overlay._REC_MODELS
ASR_LANGS = ("auto", "bn") # speech recognition: auto is SenseVoice (zh/en/ja/ko/yue, detected per line); bn is speech.BN_MODEL_DIR
diff --git a/skills/rea-video/SKILL.md b/skills/rea-video/SKILL.md
index 2634b28..caa498b 100644
--- a/skills/rea-video/SKILL.md
+++ b/skills/rea-video/SKILL.md
@@ -32,7 +32,7 @@ VLM(能看图的多模态模型)建议配,不强制,配置方法也在 `
# ⓪ 先看记住了什么:用户偏好(默认引擎、是否开 VLM、给你的偏好说明)和常见纠正类型
rea-video memory
# ① 拆解(产出 out/<名>/VIDEO.md + video/(给你读的拆片包)、report.html / report.md(给用户看)、breakdown.json、storyboard.jpg、audio.png、shots/、stems/)
-rea-video --env-file <你的 .env> decompose ref.mp4 -o out/ref --vlm --lang <zh|en> # --lang 按用户提问的语言选(见「交付给用户」);没有 VLM 配置就去掉 --env-file 和 --vlm;字幕/花字是日文就加 --ocr-lang ja;台词是孟加拉语就加 --asr-lang bn
+rea-video --env-file <你的 .env> decompose ref.mp4 -o out/ref --vlm --lang <zh|en> # --lang 按用户提问的语言选(见「交付给用户」);没有 VLM 配置就去掉 --env-file 和 --vlm;字幕/花字是日文就加 --ocr-lang ja,是韩文就加 --ocr-lang ko;台词是孟加拉语就加 --asr-lang bn
# ② 看紧凑摘要:低置信镜头会被标出;先看 VLM: 那一行确认 VLM 是否生效
rea-video summary out/ref/breakdown.json
```
diff --git a/tests/test_ocr_lang.py b/tests/test_ocr_lang.py
index 45276fb..12e7102 100644
--- a/tests/test_ocr_lang.py
+++ b/tests/test_ocr_lang.py
@@ -47,6 +47,45 @@ def test_ja_uses_japanese_recognizer(monkeypatch, tmp_path, fake_rapidocr):
assert fake_rapidocr == [{"rec_model_path": str(model)}, {}] # one instance per language
+def test_ko_uses_korean_recognizer_without_angle_classifier(monkeypatch, tmp_path, fake_rapidocr):
+ model = tmp_path / "korean.onnx"
+ model.write_bytes(b"x")
+ monkeypatch.setenv("REA_OCR_REC_MODEL", str(model))
+ monkeypatch.setenv("REA_OCR_LANG", "ko")
+ overlay.get_ocr()
+ monkeypatch.setenv("REA_OCR_LANG", "ja")
+ overlay.get_ocr()
+ # the classifier flips Hangul lines upside down, so only ko turns it off
+ assert fake_rapidocr == [{"rec_model_path": str(model), "use_cls": False}, {"rec_model_path": str(model)}]
+
+
+def test_ko_model_is_pinned():
+ name, url, sha = overlay._REC_MODELS["ko"]
+ assert url.startswith("https://") and url.endswith("/" + name)
+ assert len(sha) == 64 and int(sha, 16) >= 0
+
+
+def test_rapidocr3_turns_off_angle_classifier_for_ko(monkeypatch, tmp_path):
+ made = []
+
+ class RapidOCR:
+ def __init__(self, params=None):
+ made.append(params)
+
+ monkeypatch.setitem(sys.modules, "rapidocr_onnxruntime", None) # import raises ImportError
+ monkeypatch.setitem(sys.modules, "rapidocr", types.SimpleNamespace(RapidOCR=RapidOCR))
+ monkeypatch.setattr(overlay, "_OCR", {})
+ model = tmp_path / "korean.onnx"
+ model.write_bytes(b"x")
+ monkeypatch.setenv("REA_OCR_REC_MODEL", str(model))
+ monkeypatch.setenv("REA_OCR_LANG", "ko")
+ overlay.get_ocr()
+ monkeypatch.setenv("REA_OCR_LANG", "zh")
+ overlay.get_ocr()
+ assert made[0]["Rec.model_path"] == str(model) and made[0]["Global.use_cls"] is False
+ assert "Global.use_cls" not in made[1] # other languages keep rapidocr's default
+
+
def test_cached_model_with_matching_checksum_is_not_downloaded(monkeypatch, tmp_path):
monkeypatch.delenv("REA_OCR_REC_MODEL", raising=False)
monkeypatch.setenv("REA_VIDEO_MODELS", str(tmp_path))