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 格式输出。
Python agent-skillsai-videoaigc-detectionclaude-codecodexffmpegprompt-engineeringremotionreverse-engineeringshort-videoshot-detectionsubtitlesvideo-analysisvideo-breakdownvideo-editingvideo-generationvideomdvlm
Place overview tiles by change, skip looks that add nothing
june6ed9ff2c273a
diff --git a/docs/cli.md b/docs/cli.mdindex 59302d5..ac86742 100644--- a/docs/cli.md+++ b/docs/cli.md@@ -96,7 +96,7 @@ rea-video capsule-draft out/ref/breakdown.json --capsule-root $CC --capsule-name| 命令 | 作用 ||---|---|| `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` 可设成默认 |-| `survey VIDEO [-o OUT_DIR] [--vlm] [--no-detail] [--workers N]` | 先看后拆:第一轮把全片按剪辑快慢等距排成一张小格总览图(只为找切点,格子小省 token),问每两格之间是同一画面、画面变化多、硬切、转场还是看不清;转场和看不清的地方下一轮放大逐帧再看(转场按变化最大的帧抽,同一轮的任务可以并发,最多三轮);切点定下来后每镜都上关键帧图(动作多的镜头出候选帧,短镜头几格),让 AI 挑出关键帧、标明是哪一种,并判断画面是怎么做出来的。每张图都填到模型不缩图的大小(约 1568 px / 1.15 MP),一张能放多少格就放多少。问答是 JEV 格式:`state` 放材料,问题带 `criteria`,答案只写选项和概率。结果写进 `survey/timeline.json`(切点、转场时长、每镜关键帧、镜头长度、画面变化曲线、每段底层画面判断),decompose 按它切镜,报告和拆片包的「节奏与关键帧」也来自它。没有 VLM 时由 agent 回答:命令输出要看的图和要写的答案文件,答完再跑同一条命令;`--vlm` 用配置的模型自动答;decompose 开了 VLM 时会自动先跑(`--no-survey` 跳过) |+| `survey VIDEO [-o OUT_DIR] [--vlm] [--no-detail] [--workers N]` | 先看后拆:第一轮把全片排成一张小格总览图(只为找切点,格子小省 token;张数按剪辑快慢定,一半等距、一半放在画面变化多的地方),问每两格之间是同一画面、画面变化多、硬切、转场还是看不清;转场和看不清的地方下一轮放大逐帧再看(总览上已经够密的转场、相邻两帧之间的看不清不再放大,由画面变化曲线定)(转场按变化最大的帧抽,同一轮的任务可以并发,最多三轮);切点定下来后每镜都上关键帧图(动作多的镜头出候选帧,短镜头几格),让 AI 挑出关键帧、标明是哪一种,并判断画面是怎么做出来的。每张图都填到模型不缩图的大小(约 1568 px / 1.15 MP),一张能放多少格就放多少。问答是 JEV 格式:`state` 放材料,问题带 `criteria`,答案只写选项和概率。结果写进 `survey/timeline.json`(切点、转场时长、每镜关键帧、镜头长度、画面变化曲线、每段底层画面判断),decompose 按它切镜,报告和拆片包的「节奏与关键帧」也来自它。没有 VLM 时由 agent 回答:命令输出要看的图和要写的答案文件,答完再跑同一条命令;`--vlm` 用配置的模型自动答;decompose 开了 VLM 时会自动先跑(`--no-survey` 跳过) || `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/survey.py b/rea_video/survey.pyindex 0b4367f..21c6cfa 100644--- a/rea_video/survey.py+++ b/rea_video/survey.py@@ -1,10 +1,12 @@"""Survey: look at the whole video once, then look closer only where it needs it.-Round 1 lays evenly spaced frames of the whole video on one overview sheet of small tiles (index, how much the picture-changes in each gap, the cut detector's cuts marked): its only job is to find the shots, which small tiles do as well-as large ones. Every gap between two tiles gets a typed question. Gaps answered "transition" or "unsure" get a zoom+Round 1 lays frames of the whole video on one overview sheet of small tiles (index, how much the picture changes in+each gap, the cut detector's cuts marked): its only job is to find the shots, which small tiles do as well as large+ones. The tiles are placed by the change curve, half evenly and half where the picture changes, so a slow morph is+seen through and a still stretch costs few tiles. Every gap between two tiles gets a typed question. Gaps answered "transition" or "unsure" get a zoomblock in the next round, at a larger tile size: frames picked where the picture changes most, about every frame-through a transition. Blocks are packed onto as few sheets as fit; sheets of a round are independent, so they can be+through a transition; a transition the overview already showed closely, and a gap between two neighbouring frames+(nothing more to see), are not zoomed. Blocks are packed onto as few sheets as fit; sheets of a round are independent, so they can beanswered in parallel. At most three rounds. Then every shot is shown once at the closer size: its key frames arepicked and named, and how its picture was made is judged there, where the texture can be seen.@@ -92,7 +94,7 @@ DETAIL_INSTRUCTIONS = """你是动画原画师,在挑关键帧。图里每一- 要改的镜头写 frames 和 missing:frames 只写是关键帧的格子,"格子编号": "角色 概率",例如 {"02": "extreme .8", "05": "enter"},角色从 roles 里选;missing 写漏了关键帧的相邻两格,例如 ["03-04"](动作在两格之间转折了、有元素一闪而过)。- 第一格一般是 first;动作的转折和极值最重要,宁多勿漏。"""-ZOOM_INSTRUCTIONS = """你是视频节奏审阅员,这一轮是放大细看:图里每一块(标题写着段编号和时间范围)是要细看的地方(上一轮标出的,或工具从画面变化里找到的渐变段),按变化最大的帧密集抽取,+ZOOM_INSTRUCTIONS = """你是视频节奏审阅员,这一轮是放大细看:图里每一块(标题写着段编号和时间范围)是上一轮要细看的地方,按变化最大的帧密集抽取,转场里基本逐帧。格子左上角是编号(时间在 state 里),底部橙色条是到下一格画面变化多大,右边红色竖线是切镜检测器的切点。gap 编号写成 段编号.NN,例如 r2_01.03 是这一段第 03 格和第 04 格之间。@@ -384,50 +386,6 @@ def overview_times(track: FrameTrack, dur: float, n: int) -> list[float]:return [round(_t(track, i), 3) for i in idx]-def tool_windows(track: FrameTrack) -> list[tuple[float, float, str]]:- """Stretches the change curve alone shows to be gradual scene changes, zoomed in round 1 next to the overview- instead of after it: the picture keeps changing (several frames of change, not one cut frame, which the detector- places exactly) and ends as something else (the frames before and after differ, unlike motion inside a shot)."""- score = change_score(track)- nf = len(score)- w = max(1, int(round(0.1 * track.fps)))- on = np.array([score[max(0, i - w):i + w + 1].max() > 0.06 for i in range(nf)])- out: list[tuple[float, float, str]] = []- i = 0- while i < nf:- if not on[i]:- i += 1- continue- j = i- while j < nf and on[j]:- j += 1- a, z = max(0, i - 1), min(nf - 1, j)- if int((score[i:j] > 0.06).sum()) >= 3 and _differ(track, a, z):- t0, t1 = _t(track, a), _t(track, z)- if out and t0 - out[-1][1] < 0.2:- out[-1] = (out[-1][0], t1, "tool")- else:- out.append((t0, t1, "tool"))- i = j- split = []- for t0, t1, why in out:- n = max(1, int(math.ceil((t1 - t0) / ZOOM_SPAN)))- split += [(t0 + (t1 - t0) * k / n, t0 + (t1 - t0) * (k + 1) / n, why) for k in range(n)]- return split---def _differ(track: FrameTrack, a: int, z: int) -> bool:- """Frames a and z show different pictures: brightness histograms apart, or the pixels."""- fa, fz = track.thumbs[a], track.thumbs[z]- ga = fa if fa.ndim == 2 else cv2.cvtColor(fa, cv2.COLOR_RGB2GRAY)- gz = fz if fz.ndim == 2 else cv2.cvtColor(fz, cv2.COLOR_RGB2GRAY)- ha = cv2.calcHist([ga], [0], None, [32], [0, 256]).ravel()- hz = cv2.calcHist([gz], [0], None, [32], [0, 256]).ravel()- hist = 0.5 * float(np.abs(ha / max(ha.sum(), 1) - hz / max(hz.sum(), 1)).sum())- pix = float(np.abs(fa.astype(float) - fz.astype(float)).mean() / 255)- return hist >= 0.1 or pix >= 0.07--def overview_task(video: str, info: VideoInfo, track: FrameTrack, shots: list[Shot], sdir: Path) -> dict:dur = info.duration or _t(track, track.n - 1)n = max(8, int(round(dur / overview_every(track, shots, dur))))@@ -787,9 +745,6 @@ def run(video: str | Path, out: Path, track: FrameTrack, shots: list[Shot], info_reset(sdir)meta = {"version": VERSION, "source": src, "rounds": [["overview"]]}_write_task(sdir, overview_task(video, info, track, shots, sdir))- for t in zoom_tasks(video, info, track, shots, sdir, tool_windows(track), 1): # alongside, no need to wait- _write_task(sdir, t)- meta["rounds"][0].append(t["id"])write_json(meta_p, meta)def answer(tasks: list[dict], reader) -> None:diff --git a/skills/rea-video/SKILL.md b/skills/rea-video/SKILL.mdindex e601e90..53f95eb 100644--- a/skills/rea-video/SKILL.md+++ b/skills/rea-video/SKILL.md@@ -32,7 +32,7 @@ VLM(能看图的多模态模型)建议配,不强制,配置方法也在 `# ⓪ 先看记住了什么:用户偏好(默认引擎、是否开 VLM、给你的偏好说明)和常见纠正类型rea-video memory# ① 先看后拆(能看图、没开 VLM 时):小格总览图只定切点和转场,看不清的地方逐帧放大再看,最后逐镜挑关键帧、判断画面怎么做的。-# 按输出的 images 看图,把答案写进 waiting 里的文件,再跑同一条命令,直到 status 是 done;同一轮的任务互不相关,可以分给几个子 agent 并发。+# 按输出的 images 看图,把答案写进 waiting 里的文件,再跑同一条命令,直到 status 是 done;同一轮的图自己一次看完、一起答(最省 token);图多(4 张以上)再分给几个子 agent 并发。# 答案按 JEV 格式只写选项和概率,是 same 的 gap 不写;关键帧图上整张写一次 look,不用改的镜头不写。开了 VLM 时 decompose 会自动做这一步rea-video survey ref.mp4 -o out/ref# ② 拆解(产出 out/<名>/VIDEO.md + video/(给你读的拆片包)、report.html / report.md(给用户看)、breakdown.json、storyboard.jpg、audio.png、shots/、stems/)