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

Pace the overview by the edit and batch closer looks

junec0dd647ae95a
diff --git a/rea_video/cli.py b/rea_video/cli.py
index 8f8e1d0..549588e 100644
--- a/rea_video/cli.py
+++ b/rea_video/cli.py
@@ -401,7 +401,7 @@ def cmd_remake(args) -> int:
out = Path(args.out_dir)
if not (out / "breakdown.json").is_file():
raise SystemExit(f"rea-video: {out} 下没有 breakdown.json,先运行 decompose")
- print(json.dumps(remake(out, code=not args.no_code, overlays=not args.no_overlays), ensure_ascii=False, indent=1))
+ print(json.dumps(remake(out, code=args.code, overlays=not args.no_overlays), ensure_ascii=False, indent=1))
return 0
@@ -813,9 +813,9 @@ def main(argv: list[str] | None = None) -> int:
cp.add_argument("-o", "--out", help="输出目录:compare.json 和 compare_worst.jpg")
cp.set_defaults(func=cmd_compare)
- rm = sub.add_parser("remake", help="一条命令出复刻:代码渲染镜头重画、静图按运动重建、已生成 / 你给的镜头剪进去,其余原片占位;输出成片、对比视频和逐镜进度(remake/status.md)")
+ rm = sub.add_parser("remake", help="一条命令出复刻:静图按运动重建(代码渲染镜头默认原片占位,加 --code 出快速草稿)、已生成 / 你给的镜头剪进去,其余原片占位;输出成片、对比视频和逐镜进度(remake/status.md)")
rm.add_argument("out_dir", help="decompose 的输出目录")
- rm.add_argument("--no-code", action="store_true", help="不重画代码渲染镜头")
+ rm.add_argument("--code", action="store_true", help="用 code-remake 给代码渲染镜头出快速草稿(粒子 / 数据可视化类画面接近原片;插画动画建议交给 HyperFrames 等 HTML 视频框架)")
rm.add_argument("--no-overlays", action="store_true", help="换掉的镜头上不叠回字幕 / 花字")
rm.set_defaults(func=cmd_remake)
diff --git a/rea_video/pipeline.py b/rea_video/pipeline.py
index 51384c5..01091c1 100644
--- a/rea_video/pipeline.py
+++ b/rea_video/pipeline.py
@@ -597,6 +597,13 @@ def _vlm_gate(rec: dict, vprobs: dict | None, vctx: dict) -> dict | None:
and bool(facts.get("big_face") or facts.get("lowlight") or facts.get("face_area", 0) >= RULES["big_face"]["area"]))
if v in UNMEASURED: # 2D animation / stop motion: the tools cannot score them, so they cannot back them either
return vprobs
+ # the overview is the only reader and reads the whole video as one way of making it: where the tools hold no hard
+ # evidence (no repeated frames; not sure either, as an AIGC label would make them; a sharpness rhythm alone proves
+ # nothing), that consistency decides. A shot that looks generated or filmed among rendered ones is the case the
+ # overview is for (the tools read the textures of a hand-drawn vector animation as photo or AI)
+ survey_only = bool(rec.get("survey_look")) and not rec.get("vlm") and not rec.get("review")
+ if survey_only and vprobs.get(v, 0.0) >= 0.7 and facts.get("pulldown") in (None, "interpolated") and dp < 0.65:
+ return vprobs
# the tools are undecided when no label reaches 0.4 and the reader's pick trails the runner-up by a hair:
# a lip macro with no face found scores 3D 0.35 / AI 0.27 / live 0.22 (issue #8 #22-#27), which is no call
undecided = dp < 0.4 and vprobs.get(v, 0.0) > 0 and rec["deterministic"]["probs"].get(v, 0.0) >= 0.15 \
diff --git a/rea_video/plan.py b/rea_video/plan.py
index e093cdf..eb433dc 100644
--- a/rea_video/plan.py
+++ b/rea_video/plan.py
@@ -31,7 +31,7 @@ NOTE = LangDict({
"live_action": "原片为实拍:按拍摄方案(景别/机位/打光)重新拍摄;没有拍摄条件时才用 AI 图生视频近似(以首帧为参考)",
"avatar": "数字人口播:先克隆/合成配音,再用数字人模型由人像 + 音频驱动",
"cg_3d": "3D 渲染:可以用视频模型近似(见复刻方案的生成单元);需要精确多角度时走 3D 建模 + Blender 渲染",
- "code_render": "代码渲染:用 Remotion/HTML 按文字轨与版式重建,100% 可控,不需要生成模型",
+ "code_render": "代码渲染:用 HTML 视频框架(如 HyperFrames、Remotion)按节奏表、关键帧和版式重建,100% 可控,不需要生成模型",
"screen_capture": "录屏/截图:用真实界面录屏或网页截图重建",
"still_motion": "静态图推拉:用一张图 + 测得的缩放/平移参数在本地 ffmpeg 精确复刻",
"static_hold": "静帧:一张图定格即可",
@@ -43,7 +43,7 @@ NOTE = LangDict({
"live_action": "Source is live action: reshoot per the shooting plan (shot size / camera setup / lighting); only fall back to AI image-to-video (first frame as reference) when a shoot is not possible",
"avatar": "Digital-avatar talking head: clone or synthesize the voice first, then drive an avatar model from a portrait + the audio",
"cg_3d": "3D render: a video model gives an approximation (see the generation units); for precise multiple angles, model in 3D and render in Blender",
- "code_render": "Code render: rebuild in Remotion / HTML from the text tracks and layout, 100% controllable, no generative model needed",
+ "code_render": "Code render: rebuild in an HTML video framework (such as HyperFrames or Remotion) from the rhythm, key frames and layout, 100% controllable, no generative model needed",
"screen_capture": "Screen recording / screenshot: rebuild from a real screen recording or web screenshot",
"still_motion": "Still-image move: one image + the measured zoom / pan parameters, reproduced exactly with local ffmpeg",
"static_hold": "Static frame: one held image is enough",
diff --git a/rea_video/production.py b/rea_video/production.py
index 0935202..06505f1 100644
--- a/rea_video/production.py
+++ b/rea_video/production.py
@@ -603,15 +603,16 @@ def report_md(plan: dict) -> list[str]:
L.append("")
if plan["code"]:
L += ["", T("### 代码合成", "### Code composition"), "",
- T("一个 Remotion/HTML 工程,按文字轨和版式重建(文字、界面 100% 可控,改文案只改数据);可以让 LLM 直接写这个工程。",
- "One Remotion / HTML project rebuilt from the text tracks and layout (text and UI are 100% controllable; changing copy is a data "
- "change). An LLM can write this project directly."), "",
- T("先跑 `rea-video code-remake <拆解目录>`:按下面每个场景的采样点 / 抠图、运动和背景光写出 `code/spec.json` + `code/render.py`,"
- "逐场景对齐原片的量和亮度后渲染出 `code/remake.mp4` 并打分。从这一版改起(改 spec.json、换采样点、或照它改写成 Remotion),不要从零写。",
- "Start with `rea-video code-remake <breakdown folder>`: it writes `code/spec.json` + `code/render.py` from each scene's sampled "
- "points / cut-out, motion and background glow below, matches each scene's amount and brightness to the original, renders "
- "`code/remake.mp4` and scores it. Work from that version (edit spec.json, swap the points, or port it to Remotion) instead of "
- "writing one from scratch."), ""]
+ T("用 HTML 视频框架(如 HyperFrames、Remotion)重做一个工程:切点、转场和每镜关键帧照「节奏与关键帧」,版式、配色和元素照下面的场景;"
+ "文字、界面 100% 可控,改文案只改数据,可以让 AI 编程助手直接写。",
+ "Rebuild it as one project in an HTML video framework (such as HyperFrames or Remotion): cuts, transitions and each shot's key "
+ "frames from \"Rhythm and key frames\", layout, colours and elements from the scenes below. Text and UI are 100% controllable, "
+ "changing copy is a data change, and an AI coding assistant can write the project."), "",
+ T("`rea-video code-remake <拆解目录>` 只出一版快速草稿:按每个场景的采样点 / 抠图、运动和背景光渲染出 `code/remake.mp4` 并打分。"
+ "粒子、点云、数据可视化这类暗底图形能接近原片;插画角色的动作和形变转场出不来。",
+ "`rea-video code-remake <breakdown folder>` only makes a quick draft: it renders `code/remake.mp4` from each scene's sampled "
+ "points / cut-out, motion and background glow and scores it. Particles, point clouds and data visualisations on a dark ground "
+ "come close; an illustrated character's acting and morph transitions do not."), ""]
for c in plan["code"]:
L.append(T("- {id}:镜头 {sh}({a:.1f}–{z:.1f}s)", "- {id}: shots {sh} ({a:.1f}–{z:.1f}s)",
id=c["id"], sh=shot_ids(c["shots"]), a=c["start"], z=c["end"])
diff --git a/rea_video/remake.py b/rea_video/remake.py
index 2ff2822..5f63f38 100644
--- a/rea_video/remake.py
+++ b/rea_video/remake.py
@@ -315,7 +315,9 @@ def _next_step(sh: dict, plan: dict | None = None) -> str:
if lab == "film_footage":
return T("影视片段:找到原片对应片段(有版权),或换成自己拍的", "film clip: find it in the source (rights apply) or shoot your own")
if lab == "code_render":
- return T("代码渲染:rea-video code-remake 没跑成,先单独跑它看报错", "code render: code-remake did not run; run it alone to see why")
+ return T("代码渲染:交给 HTML 视频框架(如 HyperFrames)按 video/rhythm.md 的节奏和关键帧重做,做好的片段写进 mine.json;要快速草稿加 --code",
+ "code render: rebuild it in an HTML video framework (such as HyperFrames) from the rhythm and key frames in video/rhythm.md "
+ "and add the clip to mine.json; --code makes a quick draft")
return T("提供素材", "provide the footage") + tail
@@ -337,9 +339,10 @@ def _code_score(scores: list[dict], sh: dict) -> dict | None:
return best
-def remake(out: Path, code: bool = True, overlays: bool = True) -> dict:
+def remake(out: Path, code: bool = False, overlays: bool = True) -> dict:
"""The whole remake in one pass, as far as it can go without paid generation or the user's own footage:
- code-rendered shots are redrawn (code-remake), stills are rebuilt from the measured move, clips already
+ with `code`, code-rendered shots get a quick redraw (code-remake; otherwise they are left to an HTML video
+ framework and keep the original, unless a code-remake is already there), stills are rebuilt from the measured move, clips already
generated (remake/results.json from remake-run) or supplied (remake/mine.json, {"results": {"<shot>": {"video": path}}})
are cut in, everything else keeps the original as a stand-in. Writes remake/remake.mp4, remake/compare.mp4 and
remake/status.md (per shot: how it is made now and what is still to do). Run it again whenever a clip comes in."""
diff --git a/rea_video/survey.py b/rea_video/survey.py
index 50c4bfd..ca18c2d 100644
--- a/rea_video/survey.py
+++ b/rea_video/survey.py
@@ -30,13 +30,14 @@ from .shots import FrameTrack, Shot
from .util import fmt_time, read_json, write_json
from .visual import _font, _to_pil
-VERSION = 1
+VERSION = 2
TILE_W = 240
COLS = 8
-MAX_TILES = 48 # tiles on one overview sheet
-MAX_SHEETS = 4 # overview sheets; past MAX_TILES * MAX_SHEETS tiles the spacing grows
-OVERVIEW_EVERY = 1.0 # seconds between overview tiles when the video is short enough
-ZOOM_MAX = 16 # tiles on one zoom sheet
+MAX_TILES = 64 # tiles on one overview image (8 x 8)
+OVERVIEW_TILES = 192 # overview tiles at most; a longer video gets wider spacing
+OVERVIEW_MIN, OVERVIEW_MAX = 0.33, 3.0 # overview spacing (s), set by how often the video changes (overview_every)
+ZOOM_MAX = 16 # tiles for one stretch looked at closer (two rows)
+ZOOM_PER_SHEET = 3 # stretches stacked on one zoom image
ZOOM_SPAN = 4.0 # longest stretch one zoom sheet covers
MAX_ROUNDS = 3
RHYTHM_STEP = 0.25 # seconds per value of the change curve
@@ -68,14 +69,18 @@ KEY_ROLES = {
"light": "颜色、光线、底色突变(闪白、换底色、亮起)",
"beat": "卡在节拍 / 音效上的画面变化",
}
-DETAIL_INSTRUCTIONS = """你是动画原画师,在挑关键帧。图里是一个镜头的候选帧,每格左上角是编号和时间。
+DETAIL_INSTRUCTIONS = """你是动画原画师,在挑关键帧。图里每一条是一个镜头(标题栏写着 shot 编号和时间)的候选帧,每格左上角是编号和时间。
关键帧 = 用最少的帧把这段画面定下来,其余帧都能从它们插值出来:状态的起点、终点和转折点,不是"变了多少就取一张"。
-按 JEV 格式回答,只回 JSON,不写解释:
-- frames:是关键帧的格子写 {"格子编号": {"answer": 角色, "p": {角色: 概率}}},角色从 roles 里选;不是关键帧的不写。
-- missing:哪两格之间还漏了关键帧(例如动作在两格之间转折了、有元素一闪而过),写成 ["03-04", ...];没有就写 []。
-- 第一格一般是 first;动作的转折和极值最重要,宁多勿漏。
-- 这个镜头很简单、候选帧已经够用时,只回 {"accept": true}。"""
+按 JEV 格式回答,只回 JSON,不写解释:{"shots": {"shot_001": {...}, ...}}
+- 候选帧已经够用的镜头不用写(等于接受)。
+- 要改的镜头写 frames 和 missing:frames 只写是关键帧的格子,"格子编号": "角色 概率",例如 {"02": "extreme .8", "05": "enter"},
+ 角色从 roles 里选;missing 写漏了关键帧的相邻两格,例如 ["03-04"](动作在两格之间转折了、有元素一闪而过)。
+- 第一格一般是 first;动作的转折和极值最重要,宁多勿漏。"""
+ZOOM_INSTRUCTIONS = """这一轮是放大细看:图里每一段(标题栏写着段编号和时间范围)是上一轮要细看的地方,按变化最大的帧密集抽取。
+gap 编号写成 段编号.NN,例如 r2_01.03 是这一段第 03 格和第 04 格之间。
+
+"""
SOURCE_CRITERIA = {
"live_action": "真实摄像机 / 手机实拍", "ai_video": "AI 生成视频(形变、纹理闪烁、物理不合理)", "avatar": "数字人口播",
"cg_3d": "3D 渲染(Blender / C4D / UE,几何干净、光影一致)",
@@ -91,8 +96,8 @@ INSTRUCTIONS = """你是视频节奏审阅员。图里是按时间等距排开
编号 gNN 表示第 NN 格和下一格之间。格子底部的橙色条是这段里画面变化有多大(越长越大),右边红色竖线 + CUT 表示切镜检测器在这段里找到了切点。
按 JEV 格式回答:只回 JSON,不写解释。
-- gaps:每个 gap 从 criteria 里选一项,写成 {"answer": 选项, "p": {选项: 概率, ...}};是 "same" 的 gap 不用写,但画了红线的 gap 必须写。
-- 选 cut / transition 的,再加 "kind"(从 kinds 里选)。一个转场跨几个 gap 时,这几个 gap 的 kind 写成一样;
+- gaps:每个 gap 从 criteria 里选一项,简写成 "选项 [kind] 概率",例如 {"g06": "transition zoom .85", "g09": "cut", "g12": "busy .7"};
+ 是 "same" 的 gap 不用写,但画了红线的 gap 必须写。选 cut / transition 的,kind 从 kinds 里选。一个转场跨几个 gap 时,这几个 gap 的 kind 写成一样;
紧接着又是另一个转场(A 变成 B,B 马上又变成 C),换一个 kind,或者在 B 停留的那格写 busy。
- source:按底层画面的制作方式分段(格子编号范围 + 选项 + 概率)。
- 拿不准就选 unsure,会在那里加密抽帧再看一轮;不要猜。
@@ -225,35 +230,56 @@ def _grab(video: str, info: VideoInfo, times: list[float], width: int = TILE_W)
return [f if f is not None else fill for f in got]
-def _sheet(frames: list[np.ndarray], labels: list[str], bars: list[float], cuts: list[bool], out: Path, cols: int = COLS) -> Path:
- """Tiles in rows; under each tile a bar for the change in the gap after it; a red edge + ✂ for detector cuts."""
- font = _font(15)
+def _grid(frames: list[np.ndarray], labels: list[str], bars: list[float], cuts: list[bool], cols: int = COLS,
+ tile_w: int = TILE_W) -> Image.Image:
+ """Tiles in rows; under each tile a bar for the change in the gap after it; a red edge + CUT for detector cuts."""
+ font = _font(15 if tile_w >= 200 else 13)
cells = []
for f, lab, bar, cut in zip(frames, labels, bars, cuts):
im = _to_pil(f)
- im = im.resize((TILE_W, max(1, int(im.height * TILE_W / im.width))))
- cell = Image.new("RGB", (TILE_W, im.height + 10), (24, 24, 24))
+ im = im.resize((tile_w, max(1, int(im.height * tile_w / im.width))))
+ cell = Image.new("RGB", (tile_w, im.height + 10), (24, 24, 24))
cell.paste(im, (0, 0))
d = ImageDraw.Draw(cell)
w = int(d.textlength(lab, font=font)) + 8
- d.rectangle([0, 0, w, 19], fill=(0, 0, 0))
+ d.rectangle([0, 0, w, 18], fill=(0, 0, 0))
d.text((4, 1), lab, fill=(255, 255, 255), font=font)
- d.rectangle([0, im.height + 2, int((TILE_W - 2) * min(1.0, bar)), im.height + 8], fill=(245, 158, 11))
+ d.rectangle([0, im.height + 2, int((tile_w - 2) * min(1.0, bar)), im.height + 8], fill=(245, 158, 11))
if cut:
- d.rectangle([TILE_W - 5, 0, TILE_W - 1, im.height + 9], fill=(230, 30, 30))
- d.rectangle([TILE_W - 40, im.height - 22, TILE_W - 6, im.height - 2], fill=(230, 30, 30))
- d.text((TILE_W - 37, im.height - 21), "CUT", fill=(255, 255, 255), font=_font(13))
+ d.rectangle([tile_w - 5, 0, tile_w - 1, im.height + 9], fill=(230, 30, 30))
+ d.rectangle([tile_w - 40, im.height - 22, tile_w - 6, im.height - 2], fill=(230, 30, 30))
+ d.text((tile_w - 37, im.height - 21), "CUT", fill=(255, 255, 255), font=_font(13))
cells.append(cell)
ch = max(c.height for c in cells)
- rows = int(math.ceil(len(cells) / cols))
- sheet = Image.new("RGB", (TILE_W * min(cols, len(cells)) + 2 * (min(cols, len(cells)) - 1), rows * (ch + 2)), (255, 255, 255))
+ n = min(cols, len(cells))
+ sheet = Image.new("RGB", (tile_w * n + 2 * (n - 1), int(math.ceil(len(cells) / cols)) * (ch + 2)), (255, 255, 255))
for k, c in enumerate(cells):
- sheet.paste(c, ((k % cols) * (TILE_W + 2), (k // cols) * (ch + 2)))
+ sheet.paste(c, ((k % cols) * (tile_w + 2), (k // cols) * (ch + 2)))
+ return sheet
+
+
+def _save(img: Image.Image, out: Path) -> Path:
out.parent.mkdir(parents=True, exist_ok=True)
- sheet.save(out, quality=85)
+ img.save(out, quality=85)
return out
+def _stack(blocks: list[tuple[str, Image.Image]], out: Path) -> Path:
+ """Several grids on one image, each under a title bar: one look instead of one per stretch."""
+ font = _font(17)
+ w = max(im.width for _, im in blocks)
+ h = sum(im.height + 26 for _, im in blocks)
+ sheet = Image.new("RGB", (w, h), (255, 255, 255))
+ d = ImageDraw.Draw(sheet)
+ y = 0
+ for title, im in blocks:
+ d.rectangle([0, y, w, y + 24], fill=(40, 70, 160))
+ d.text((8, y + 3), title, fill=(255, 255, 255), font=font)
+ sheet.paste(im, (0, y + 26))
+ y += im.height + 26
+ return _save(sheet, out)
+
+
def _gap_bars(track: FrameTrack, times: list[float], score: np.ndarray, cut_frames: list[int]) -> tuple[list[float], list[bool]]:
bars, cuts = [], []
for k, t in enumerate(times):
@@ -270,21 +296,29 @@ def _source(video: str, info: VideoInfo) -> dict:
return {"path": str(video), "duration": round(info.duration, 3), "size": [info.width, info.height], "fps": round(info.fps, 3)}
+def overview_every(track: FrameTrack, shots: list[Shot], dur: float) -> float:
+ """Spacing of the overview tiles, from how often this video changes: about two tiles between two sudden changes
+ (the detector's cuts or the change curve's spikes, whichever finds more), within OVERVIEW_MIN-OVERVIEW_MAX s and
+ at most OVERVIEW_TILES tiles. A fast edit gets a dense overview, a slow talk a sparse one."""
+ events = max(len(shots) - 1, spikes(track, 0.0, dur))
+ every = min(OVERVIEW_MAX, max(OVERVIEW_MIN, dur / (events + 1) / 2))
+ return max(every, dur / OVERVIEW_TILES)
+
+
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 = int(min(MAX_TILES * MAX_SHEETS, max(8, round(dur / OVERVIEW_EVERY))))
+ n = max(8, int(round(dur / overview_every(track, shots, dur))))
every = dur / n
times = [round((k + 0.5) * every, 3) for k in range(n)]
score = change_score(track)
- cut_frames = [s.start_frame for s in shots[1:]]
frames = _grab(video, info, times)
- bars, cuts = _gap_bars(track, times, score, cut_frames)
+ bars, cuts = _gap_bars(track, times, score, [s.start_frame for s in shots[1:]])
+ labels = [f"{k:02d} {fmt_time(t)}" for k, t in enumerate(times)]
images = []
for p in range(int(math.ceil(n / MAX_TILES))):
sl = slice(p * MAX_TILES, (p + 1) * MAX_TILES)
- labels = [f"{k:02d} {fmt_time(t)}" for k, t in enumerate(times)][sl]
name = f"overview_{p + 1}.jpg" if n > MAX_TILES else "overview.jpg"
- _sheet(frames[sl], labels, bars[sl], cuts[sl], sdir / name)
+ _save(_grid(frames[sl], labels[sl], bars[sl], cuts[sl]), sdir / name)
images.append(f"survey/{name}")
gaps = {f"g{k:02d}": [times[k], times[k + 1]] for k in range(n - 1)}
return {
@@ -328,92 +362,143 @@ def _zoom_frames(track: FrameTrack, a: int, z: int, score: np.ndarray, cap: int
return keep
-def zoom_task(video: str, info: VideoInfo, track: FrameTrack, shots: list[Shot], sdir: Path, tid: str, t0: float, t1: float,
- rnd: int, why: str) -> dict:
+def zoom_tasks(video: str, info: VideoInfo, track: FrameTrack, shots: list[Shot], sdir: Path, windows: list[tuple[float, float, str]],
+ rnd: int) -> list[dict]:
+ """The stretches to look at closer, ZOOM_PER_SHEET of them stacked on one image (one look, one answer file);
+ each stretch's gaps are named <stretch>.<NN>."""
score = change_score(track)
- a, z = frame_at(track, t0), frame_at(track, t1)
- idx = _zoom_frames(track, a, z, score)
- times = [round(_t(track, i), 3) for i in idx]
- frames = _grab(video, info, times)
- bars, cuts = _gap_bars(track, times, score, [s.start_frame for s in shots[1:]])
- labels = [f"{k:02d} {fmt_time(t)}" for k, t in enumerate(times)]
- name = f"zoom/{tid}.jpg"
- _sheet(frames, labels, bars, cuts, sdir / name, cols=min(COLS, 4 if len(frames) <= 16 else COLS))
- gaps = {f"{tid}.{k:02d}": [times[k], times[k + 1]] for k in range(len(times) - 1)}
- return {
- "id": tid, "round": rnd, "why": why, "images": [f"survey/{name}"], "instructions": INSTRUCTIONS,
- "state": {"span": [round(t0, 3), round(t1, 3)], "tiles": len(times), "times": times,
- "tool_cut_gaps": [g for g, c in zip(gaps, cuts) if c]},
- "questions": {"gaps": {"type": "choice", "per": "gap", "ids": list(gaps), "criteria": GAP_CRITERIA, "kinds": KINDS}},
- "answer_template": {"gaps": {}},
- "_gaps": gaps,
- }
-
-
-DETAIL_CANDIDATES = 12 # candidate frames on one shot's detail sheet
+ cut_frames = [s.start_frame for s in shots[1:]]
+ tasks = []
+ for p in range(int(math.ceil(len(windows) / ZOOM_PER_SHEET))):
+ blocks, gaps, wins = [], {}, []
+ for k, (t0, t1, why) in enumerate(windows[p * ZOOM_PER_SHEET:(p + 1) * ZOOM_PER_SHEET]):
+ wid = f"r{rnd}_{p * ZOOM_PER_SHEET + k + 1:02d}"
+ idx = _zoom_frames(track, frame_at(track, t0), frame_at(track, t1), score)
+ times = [round(_t(track, i), 3) for i in idx]
+ bars, cuts = _gap_bars(track, times, score, cut_frames)
+ grid = _grid(_grab(video, info, times), [f"{j:02d} {fmt_time(t)}" for j, t in enumerate(times)], bars, cuts, cols=COLS)
+ blocks.append((f"{wid} {fmt_time(t0)} – {fmt_time(t1)}", grid))
+ wg = {f"{wid}.{j:02d}": [times[j], times[j + 1]] for j in range(len(times) - 1)}
+ gaps.update(wg)
+ wins.append({"id": wid, "why": why, "span": [round(t0, 3), round(t1, 3)], "times": times,
+ "tool_cut_gaps": [g for g, c in zip(wg, cuts) if c]})
+ tid = f"r{rnd}_s{p + 1:02d}"
+ _stack(blocks, sdir / "zoom" / f"{tid}.jpg")
+ tasks.append({
+ "id": tid, "round": rnd, "images": [f"survey/zoom/{tid}.jpg"], "instructions": ZOOM_INSTRUCTIONS + INSTRUCTIONS,
+ "state": {"windows": wins},
+ "questions": {"gaps": {"type": "choice", "per": "gap", "ids": list(gaps), "criteria": GAP_CRITERIA, "kinds": KINDS}},
+ "answer_template": {"gaps": {}}, "_gaps": gaps,
+ })
+ return tasks
+
+
+DETAIL_CANDIDATES = 12 # candidate frames of one shot (one row)
+DETAIL_PER_SHEET = 4 # shots stacked on one key-frame image
+DETAIL_TILE_W = 160
DETAIL_MIN_S = 1.5 # shorter shots keep the tool's key frames without asking
DETAIL_MIN_KEYS = 4 # ... and so do shots where the tool finds fewer key frames (little happens)
-def detail_task(video: str, info: VideoInfo, track: FrameTrack, sdir: Path, k: int, a: int, z: int,
- busy: list[list[float]]) -> dict | None:
- """One shot's candidate key frames, more than the tool would keep (a lower threshold), for the AI to choose
- and name."""
+def _candidates(track: FrameTrack, a: int, z: int, busy: list[list[float]]) -> list[int] | None:
+ """A shot's candidate key frames for the AI (more than the tool would keep), or None when the shot is short or
+ little happens in it: the tool's key frames stand, no question asked."""
if _t(track, z - 1) - _t(track, a) < DETAIL_MIN_S:
return None
- if len(key_frames(track, a, z, [tuple(b) for b in busy])) < DETAIL_MIN_KEYS:
- return None # little happens: the tool's key frames stand, no question asked
- idx = key_frames(track, a, z, [tuple(b) for b in busy], max_n=DETAIL_CANDIDATES,
- moving=KEY_MOVING * 0.8, moving_busy=KEY_MOVING_BUSY * 0.8)
+ b = [tuple(x) for x in busy]
+ if len(key_frames(track, a, z, b)) < DETAIL_MIN_KEYS:
+ return None
+ idx = key_frames(track, a, z, b, max_n=DETAIL_CANDIDATES, moving=KEY_MOVING * 0.8, moving_busy=KEY_MOVING_BUSY * 0.8)
if len(idx) < DETAIL_CANDIDATES // 2: # few changes: top up evenly so a quick blink between two picks is still seen
idx = sorted(set(idx) | set(np.linspace(a, z - 1, num=DETAIL_CANDIDATES // 2).round().astype(int).tolist()))
- times = [round(_t(track, i), 3) for i in idx]
- frames = _grab(video, info, times)
- score = change_score(track)
- bars, _ = _gap_bars(track, times, score, [])
- tid = f"shot_{k:03d}"
- name = f"detail/{tid}.jpg"
- _sheet(frames, [f"{j:02d} {fmt_time(t)}" for j, t in enumerate(times)], bars, [False] * len(times), sdir / name,
- cols=min(COLS, 6))
- return {"id": tid, "stage": "detail", "images": [f"survey/{name}"], "instructions": DETAIL_INSTRUCTIONS,
- "state": {"shot": k, "span": [times[0], round(_t(track, z - 1), 3)], "tiles": len(times), "times": times},
- "questions": {"frames": {"type": "choice", "per": "tile", "criteria": KEY_ROLES},
- "missing": {"type": "multi_choice", "instructions": "漏了关键帧的相邻两格,写成 \"03-04\""}},
- "answer_template": {"frames": {}, "missing": []},
- "_frames": idx}
+ return idx
+
+
+def detail_tasks(video: str, info: VideoInfo, track: FrameTrack, sdir: Path, spans: list[tuple[int, int]],
+ busy: list[list[float]]) -> list[dict]:
+ """Candidate key frames of the shots worth asking about, DETAIL_PER_SHEET shots stacked on one image, one row each."""
+ picked = [(k, idx) for k, (a, z) in enumerate(spans, start=1) if (idx := _candidates(track, a, z, busy))]
+ tasks = []
+ for p in range(int(math.ceil(len(picked) / DETAIL_PER_SHEET))):
+ blocks, shots_ = [], {}
+ for k, idx in picked[p * DETAIL_PER_SHEET:(p + 1) * DETAIL_PER_SHEET]:
+ times = [round(_t(track, i), 3) for i in idx]
+ sid = f"shot_{k:03d}"
+ grid = _grid(_grab(video, info, times, width=DETAIL_TILE_W), [f"{j:02d} {fmt_time(t)}" for j, t in enumerate(times)],
+ [0.0] * len(times), [False] * len(times), cols=DETAIL_CANDIDATES, tile_w=DETAIL_TILE_W)
+ blocks.append((f"{sid} {fmt_time(times[0])} – {fmt_time(_t(track, spans[k - 1][1] - 1))}", grid))
+ shots_[sid] = {"times": times, "frames": idx}
+ tid = f"kf_{p + 1:02d}"
+ _stack(blocks, sdir / "detail" / f"{tid}.jpg")
+ tasks.append({"id": tid, "stage": "detail", "images": [f"survey/detail/{tid}.jpg"], "instructions": DETAIL_INSTRUCTIONS,
+ "state": {"shots": {sid: v["times"] for sid, v in shots_.items()}},
+ "questions": {"shots": {"type": "per_shot", "frames": {"type": "choice", "per": "tile", "criteria": KEY_ROLES},
+ "missing": {"type": "multi_choice", "instructions": "漏了关键帧的相邻两格,写成 \"03-04\""}}},
+ "answer_template": {"shots": {}}, "_frames": {sid: v["frames"] for sid, v in shots_.items()}})
+ return tasks
+
+
+def _clean_shot(v) -> dict:
+ """One shot's key-frame answer: "accept" (or nothing) = the tool's key frames; else frames {tile: role} and
+ missing ["03-04"]. Roles may be written short: "extreme .7"."""
+ if v is None or v == "accept" or (isinstance(v, dict) and v.get("accept")):
+ return {"accept": True, "frames": {}, "missing": []}
+ if not isinstance(v, dict):
+ return {"accept": True, "frames": {}, "missing": []}
+ frames = {}
+ for k, x in (v.get("frames") or {}).items():
+ if isinstance(x, str):
+ ans, _, p = _short(x, KEY_ROLES)
+ x = {"answer": ans, "p": {ans: p}} if ans else None
+ if isinstance(x, dict) and x.get("answer") in KEY_ROLES and str(k).isdigit():
+ p = {r: float(y) for r, y in (x.get("p") or {}).items() if r in KEY_ROLES and isinstance(y, (int, float))}
+ frames[int(k)] = {"answer": x["answer"], "p": p or {x["answer"]: 1.0}}
+ missing = []
+ for m in v.get("missing") or []:
+ try:
+ i, j = (int(y) for y in str(m).split("-"))
+ missing.append((min(i, j), max(i, j)))
+ except ValueError:
+ continue
+ return {"accept": not frames and not missing, "frames": frames, "missing": missing}
def read_detail(path: Path) -> dict | None:
+ """{shot id: key-frame answer} from a filled detail answer; shots left out keep the tool's key frames."""
if not path.is_file():
return None
try:
got = read_json(path)
except (OSError, ValueError):
return None
- if not isinstance(got, dict) or not (got.get("filled") or got.get("frames") or got.get("accept") or got.get("missing")):
+ if not isinstance(got, dict) or not (got.get("filled") or got.get("shots")):
return None
- if got.get("accept"): # the tool's key frames are fine for this shot
- return {"accept": True, "frames": {}, "missing": []}
- frames = {}
- for k, v in (got.get("frames") or {}).items():
- v = {"answer": v} if isinstance(v, str) else v
- if isinstance(v, dict) and v.get("answer") in KEY_ROLES and str(k).isdigit():
- p = {r: float(x) for r, x in (v.get("p") or {}).items() if r in KEY_ROLES and isinstance(x, (int, float))}
- frames[int(k)] = {"answer": v["answer"], "p": p or {v["answer"]: 1.0}}
- missing = []
- for m in got.get("missing") or []:
+ return {sid: _clean_shot(v) for sid, v in (got.get("shots") or {}).items()}
+
+
+def _short(text: str, options: dict, kinds: dict | None = None) -> tuple[str | None, str | None, float]:
+ """A short answer "transition zoom .85" -> (answer, kind, p). Options may be shortened to a unique prefix."""
+ ans = kind = None
+ p = 1.0
+ for tok in str(text).replace(",", " ").split():
try:
- i, j = (int(x) for x in str(m).split("-"))
- missing.append((min(i, j), max(i, j)))
- except ValueError:
+ p = float(tok)
continue
- return {"frames": frames, "missing": missing}
+ except ValueError:
+ pass
+ if ans is None:
+ hits = [o for o in options if o == tok] or [o for o in options if o.startswith(tok)]
+ ans = hits[0] if len(hits) == 1 else None
+ elif kinds and tok in kinds:
+ kind = tok
+ return ans, kind, max(0.0, min(1.0, p))
def _clean_gap(v) -> dict | None:
"""One gap answer -> {"answer", "p", "kind"?}; None when unusable."""
if isinstance(v, str):
- v = {"answer": v}
+ ans, kind, p = _short(v, GAP_CRITERIA, KINDS)
+ v = {"answer": ans, "p": {ans: p}, **({"kind": kind} if kind else {})} if ans else None
if not isinstance(v, dict):
return None
ans = v.get("answer")
@@ -421,8 +506,8 @@ def _clean_gap(v) -> dict | None:
return None
p = v.get("p") if isinstance(v.get("p"), dict) else {}
p = {k: float(x) for k, x in p.items() if k in GAP_CRITERIA and isinstance(x, (int, float))}
- tot = sum(p.values())
- p = {k: round(x / tot, 3) for k, x in p.items()} if tot > 0 else {ans: 1.0}
+ tot = sum(p.values()) # probabilities over 1 in total are scaled down; a lone "cut .85" keeps its .85
+ p = {k: round(x / max(tot, 1.0), 3) for k, x in p.items()} if tot > 0 else {ans: 1.0}
out = {"answer": ans, "p": p}
if v.get("kind") in KINDS:
out["kind"] = v["kind"]
@@ -504,7 +589,7 @@ def _public(task: dict) -> dict:
def _task_paths(sdir: Path, tid: str) -> tuple[Path, Path]:
- base = sdir if tid == "overview" else sdir / ("detail" if tid.startswith("shot_") else "zoom")
+ base = sdir if tid == "overview" else sdir / ("detail" if tid.startswith("kf_") else "zoom")
return base / f"{tid}.task.json", base / f"{tid}.answer.json"
@@ -521,7 +606,7 @@ def _load_task(sdir: Path, tid: str) -> dict | None:
return None
t = read_json(tp)
t["_gaps"] = t.pop("gap_times", None) or {}
- t["_frames"] = t.pop("frame_index", None) or []
+ t["_frames"] = t.pop("frame_index", None) or {}
return t
@@ -598,10 +683,9 @@ def run(video: str | Path, out: Path, track: FrameTrack, shots: list[Shot], info
nxt += _windows(t, ans["gaps"], rnd, track)
if rnd == len(meta["rounds"]) and nxt:
new = []
- for k, (t0, t1, why) in enumerate(nxt):
- tid = f"r{rnd + 1}_{k + 1:02d}"
- _write_task(sdir, zoom_task(video, info, track, shots, sdir, tid, t0, t1, rnd + 1, why))
- new.append(tid)
+ for t in zoom_tasks(video, info, track, shots, sdir, nxt, rnd + 1):
+ _write_task(sdir, t)
+ new.append(t["id"])
meta["rounds"].append(new)
write_json(meta_p, meta)
return run(video, out, track, shots, info, asker, workers, detail)
@@ -615,11 +699,9 @@ def run(video: str | Path, out: Path, track: FrameTrack, shots: list[Shot], info
for p in [*(sdir / "detail").glob("*")]:
p.unlink()
ids = []
- for k, (a, z) in enumerate(spans, start=1):
- t = detail_task(video, info, track, sdir, k, a, z, timeline["busy"])
- if t:
- _write_task(sdir, t)
- ids.append(t["id"])
+ for t in detail_tasks(video, info, track, sdir, spans, timeline["busy"]):
+ _write_task(sdir, t)
+ ids.append(t["id"])
meta.update(detail=ids, detail_for=[c["frame"] for c in timeline["cuts"]])
write_json(meta_p, meta)
tasks = [t for tid in meta.get("detail", []) if (t := _load_task(sdir, tid))]
@@ -627,23 +709,28 @@ def run(video: str | Path, out: Path, track: FrameTrack, shots: list[Shot], info
if (w := waiting(tasks, read_detail, "keyframes", 1)):
write_json(sdir / "timeline.json", timeline) # the cuts are settled already
return w
- timeline["keyframes"] = keyframe_list(track, spans, timeline["busy"], sdir if detail else None)
+ timeline["keyframes"] = keyframe_list(track, spans, timeline["busy"], sdir if detail else None, meta.get("detail", []))
write_json(sdir / "timeline.json", timeline)
return {"status": "done", "rounds": len(meta["rounds"]), "timeline": str(sdir / "timeline.json"),
"shots": timeline["shots"], "cuts": len(timeline["cuts"]),
"keyframes": sum(len(v) for v in timeline["keyframes"].values())}
-def keyframe_list(track: FrameTrack, spans: list[tuple[int, int]], busy: list[list[float]], sdir: Path | None) -> dict:
- """{shot number: [{t, frame, role, p?, by}]}: the AI's picks and names where a detail answer exists (plus the
- frame farthest from the in-between in every gap it said misses one), the tool's key frames elsewhere."""
+def keyframe_list(track: FrameTrack, spans: list[tuple[int, int]], busy: list[list[float]], sdir: Path | None,
+ detail_ids: list[str] | None = None) -> dict:
+ """{shot number: [{t, frame, role, p?, by}]}: the AI's picks and names where a detail answer changed them (plus
+ the frame farthest from the in-between in every gap it said misses one), the tool's key frames elsewhere."""
+ asked: dict[str, tuple[list[int], dict]] = {} # shot id -> (candidate frames, answer)
+ for tid in detail_ids or []:
+ t = _load_task(sdir, tid) if sdir else None
+ got = read_detail(_task_paths(sdir, tid)[1]) if t else None
+ for sid, idx in ((t or {}).get("_frames") or {}).items():
+ asked[sid] = (idx, (got or {}).get(sid) or {"accept": True})
out: dict[str, list[dict]] = {}
for k, (a, z) in enumerate(spans, start=1):
rows: list[dict] = []
- t = _load_task(sdir, f"shot_{k:03d}") if sdir else None
- ans = read_detail(_task_paths(sdir, f"shot_{k:03d}")[1]) if t else None
- if t and ans and not ans.get("accept"):
- idx = t["_frames"]
+ idx, ans = asked.get(f"shot_{k:03d}", ([], {"accept": True}))
+ if idx and not ans.get("accept"):
for j, v in ans["frames"].items():
if 0 <= j < len(idx):
rows.append({"frame": idx[j], "role": v["answer"], "p": round(max(v["p"].values()), 3), "by": "ai"})
@@ -665,12 +752,18 @@ def keyframe_list(track: FrameTrack, spans: list[tuple[int, int]], busy: list[li
def _finest(found: dict) -> dict:
- """Keep, for every stretch, the answers of the round that looked closest: a gap whose span holds gaps answered
- in a later round is replaced by them."""
+ """Keep, for every stretch, the answers of the round that looked closest: a gap that later rounds' gaps cover (90%
+ of it; their tiles need not line up with its ends) is replaced by them."""
out = {}
for g, v in found.items():
t0, t1 = v["t"]
- if any(w["round"] > v["round"] and t0 - 1e-3 <= w["t"][0] and w["t"][1] <= t1 + 1e-3 for w in found.values()):
+ later = sorted((max(t0, w["t"][0]), min(t1, w["t"][1])) for w in found.values() if w["round"] > v["round"])
+ covered, end = 0.0, t0
+ for a, z in later:
+ if z > end:
+ covered += z - max(a, end)
+ end = z
+ if t1 > t0 and covered >= 0.9 * (t1 - t0):
continue
out[g] = v
return out
@@ -705,9 +798,11 @@ def build_timeline(track: FrameTrack, shots: list[Shot], found: dict, meta: dict
run_.append(items[k][1])
t0, t1 = run_[0]["t"][0], run_[-1]["t"][1]
a, z = frame_at(track, t0) + 1, frame_at(track, t1) + 1
- seg = score[a:max(a + 1, z)]
- # the boundary: the biggest single change inside the transition, else its middle
- b = a + int(np.argmax(seg)) if len(seg) and seg.max() > 0.15 else (a + z) // 2
+ # the boundary: the biggest single change inside the transition (away from its first and last frames, which
+ # may be the cuts before and after it), else its middle
+ m = 2 if z - a > 6 else 0
+ seg = score[a + m:max(a + m + 1, z - m)]
+ b = a + m + int(np.argmax(seg)) if len(seg) and seg.max() > 0.15 else (a + z) // 2
kinds = [r.get("kind") for r in run_ if r.get("kind")]
cuts.append({"t": round(_t(track, b), 3), "frame": int(b), "kind": max(set(kinds), key=kinds.count) if kinds else "effect",
"span": [round(t0, 3), round(t1, 3)], "p": round(float(np.mean([r["p"].get("transition", 0.5) for r in run_])), 3),
@@ -717,14 +812,16 @@ def build_timeline(track: FrameTrack, shots: list[Shot], found: dict, meta: dict
same = [v for v in fin.values() if v["answer"] == "same" and not v.get("implicit") and v["p"].get("same", 0) >= DROP_TOOL_CUT_P]
dropped = []
near = 0.25 # a detector cut this close to a transition the survey found is that transition
+ edge = 2.5 / track.fps # ... unless it sits on the transition's first or last frames: a separate cut next to it
for s in shots[1:]:
t = s.start
- if any(c["span"][0] - near <= t <= c["span"][1] + near for c in cuts):
- for c in cuts: # the survey found the same change: take the detector's exact frame when it lies inside
- if c["span"][0] - 1e-3 <= t <= c["span"][1] + 1e-3:
- c.update(frame=s.start_frame, t=round(t, 3), by="survey+tool")
- if c["kind"] in ("cut", "effect") and s.transition_in not in ("cut", "start"):
- c["kind"] = s.transition_in
+ inside = [c for c in cuts if c["span"][1] - c["span"][0] > 2 * edge and c["span"][0] + edge < t < c["span"][1] - edge]
+ at_edge = [c for c in cuts if c not in inside and c["span"][0] - edge <= t <= c["span"][1] + edge and c["span"][1] > c["span"][0]]
+ if inside or (not at_edge and any(c["span"][0] - near <= t <= c["span"][1] + near for c in cuts)):
+ for c in inside: # the survey found the same change: take the detector's exact frame
+ c.update(frame=s.start_frame, t=round(t, 3), by="survey+tool")
+ if c["kind"] in ("cut", "effect") and s.transition_in not in ("cut", "start"):
+ c["kind"] = s.transition_in
continue
if any(v["t"][0] <= t <= v["t"][1] for v in same):
dropped.append(round(t, 3))
diff --git a/rea_video/videomd.py b/rea_video/videomd.py
index 79cd2d1..22a59fc 100644
--- a/rea_video/videomd.py
+++ b/rea_video/videomd.py
@@ -306,8 +306,10 @@ def _next_steps(b: dict) -> list[str]:
"Remake: `rea-video remake <this dir>` does what can be done automatically and keeps the original elsewhere; `remake/status.md` "
"says per shot what is left. Add incoming clips to `remake/mine.json` and run it again"))
if "code_render" in labels:
- L.append(T("代码渲染镜头由 `rea-video code-remake <本目录>` 重画(上一条会自动跑):改 `code/spec.json` 再跑,不要从零写",
- "Code-rendered shots are redrawn by `rea-video code-remake <this dir>` (the step above runs it): edit `code/spec.json` and rerun, do not write one from scratch"))
+ L.append(T("代码渲染镜头建议交给 HTML 视频框架(如 HyperFrames)按 `video/rhythm.md` 的节奏和关键帧重做;"
+ "`rea-video code-remake <本目录>` 只出粒子 / 数据可视化这类画面的快速草稿",
+ "Code-rendered shots are best rebuilt in an HTML video framework (such as HyperFrames) from the rhythm and key frames in "
+ "`video/rhythm.md`; `rea-video code-remake <this dir>` only makes a quick draft for particles / data-visualisation pictures"))
if (b.get("production_plan") or {}).get("drive"):
L.append(T("舞蹈 / 动作镜头不走首尾帧生成:`rea-video drive <本目录>` 出去掉字幕、按停顿切好的驱动视频,生成好的段用 `--join` 拼回;路线和提示词在 `video/remake.md` 的「动作驱动」",
"Dance / action shots are not generated from first / last frames: `rea-video drive <this dir>` writes caption-free drive clips cut at calm moments, "
diff --git a/skills/rea-video/SKILL.md b/skills/rea-video/SKILL.md
index ab6ad47..66e4fd9 100644
--- a/skills/rea-video/SKILL.md
+++ b/skills/rea-video/SKILL.md
@@ -91,7 +91,7 @@ rea-video summary out/ref/breakdown.json # 用并入后的结果写回复
按 `references/output-template.md` 回复:先一句话结论,再内容与角色(这条视频讲什么、主要角色和场景),叙事线(每一步在抓注意、补信息还是给结论,见 `video/content.md`;建议用户保留这条线、换成自己的案例和素材来重写,不只是换个主角),然后复刻方案(按生成单元 / 拍摄场次组织)、分镜表、剪辑包装、声音、真实素材清单、不确定点,最后给 `report.html` 路径(用户版报告:先讲三层、再给照着做的复刻步骤,用户自己就能复刻);用户要 PDF 时运行 `rea-video pdf out/ref` 生成 `report.pdf`(需要本机有 Chrome / Chromium / Edge)。不要把 breakdown.json 贴进对话。
-用户想复刻、二创、做同款或照着做一条自己的,或想知道这条视频怎么做出来、怎么实现时,在回复末尾告知可以用哪些工具来做(`references/remake-tools.md` 里列的都写,各一句);用户选了哪种,按那种的文档帮他接上(`references/chatcut.md`、`capsule-cinema.md`、`diy.md`)。
+用户想复刻、二创、做同款或照着做一条自己的,或想知道这条视频怎么做出来、怎么实现时,在回复末尾告知可以用哪些工具来做(`references/remake-tools.md` 里列的都写,各一句);用户选了哪种,按那种的文档帮他接上(`references/chatcut.md`、`capsule-cinema.md`、`hyperframes.md`、`diy.md`)。
**报告和回复都用用户的语言。**语言的判断顺序:用户明确指定的语言(「用英文出报告」「report in Chinese」)> 用户提问所用的语言 > `rea-video memory` 里的 `lang` 偏好 > 中文。
- 工具支持 `--lang zh` 和 `--lang en`:`decompose` 时就传对,报告文件(`report.html` / `report.md`)、`summary` 输出、VLM 的画面描述和提示词都会是该语言;忘了传可以在 `apply-review out/ref --lang en` 时补上(会重新生成结论和报告文字;VLM 已写好的描述和提示词保持原语言)。看图复核时,`review_answers.json` 里的 evidence / description / prompt 也用这个语言写。
@@ -122,7 +122,7 @@ rea-video summary out/ref/breakdown.json # 用并入后的结果写回复
用户要自己动手做时,先给报告第二部分「照着做」的步骤,不要先讲模型规则和输入表。
-先跑 `rea-video remake out/ref`:能自动做的镜头先做掉(代码渲染重画、静图重建),其余原片占位,拼回原时间线,`remake/status.md` 逐镜写了还要做什么;拿到新镜头写进 `remake/mine.json` 再跑一次。细节见 `references/remake.md`;可用的工具和方式(capsule-cinema、ChatCut、自己动手)和各自的特点列在 `references/remake-tools.md`。在本工具里直接跑:AI 镜头走 capsule-cinema(会计费,先 `rea-video remake-run --dry-run` 并征得用户同意);实拍给拍摄方案;舞蹈 / 动作镜头用 `rea-video drive out/ref` 出驱动视频(见 `references/remake.md`);代码渲染先跑 `rea-video code-remake out/ref` 出第一版(可改的工程 + 成片 + 打分),在它上面改,不要从零写;用户自己的素材用 `rea-video assemble` 拼回原时间线。代码渲染和用户自己的素材也可以在 ChatCut 里做。
+先跑 `rea-video remake out/ref`:能自动做的镜头先做掉(静图重建;代码渲染默认原片占位,加 `--code` 出快速草稿),其余原片占位,拼回原时间线,`remake/status.md` 逐镜写了还要做什么;拿到新镜头写进 `remake/mine.json` 再跑一次。细节见 `references/remake.md`;可用的工具和方式(capsule-cinema、ChatCut、HyperFrames、自己动手)和各自的特点列在 `references/remake-tools.md`。在本工具里直接跑:AI 镜头走 capsule-cinema(会计费,先 `rea-video remake-run --dry-run` 并征得用户同意);实拍给拍摄方案;舞蹈 / 动作镜头用 `rea-video drive out/ref` 出驱动视频(见 `references/remake.md`);代码渲染建议交给 HTML 视频框架(如 HyperFrames)按 `video/rhythm.md` 的节奏和关键帧重做,`rea-video code-remake out/ref` 只出粒子 / 数据可视化这类画面的快速草稿;用户自己的素材用 `rea-video assemble` 拼回原时间线。代码渲染和用户自己的素材也可以在 ChatCut 里做。
## 参考文件
@@ -138,6 +138,7 @@ rea-video summary out/ref/breakdown.json # 用并入后的结果写回复
| `references/remake-tools.md` | 复刻可以用哪些工具和方式,告诉用户有哪些可选 |
| `references/chatcut.md` | 用户要用 ChatCut 时:能做什么、费用、怎么装好接上 |
| `references/capsule-cinema.md` | 用户要用 capsule-cinema 时:费用、安装、出任务和生成 |
+| `references/hyperframes.md` | 代码渲染 / MG / 插画动画类镜头交给 HyperFrames 重做:给它什么、怎么装 |
| `references/diy.md` | 用户自己拍或手动生成时:费用、怎么把素材拼回原时间线 |
| `references/memory.md` | 记住纠正和偏好 |
diff --git a/skills/rea-video/references/hyperframes.md b/skills/rea-video/references/hyperframes.md
new file mode 100644
index 0000000..e779c32
--- /dev/null
+++ b/skills/rea-video/references/hyperframes.md
@@ -0,0 +1,30 @@
+# HyperFrames
+
+[HyperFrames](https://github.com/heygen-com/hyperframes) 是开源的 HTML 视频框架:AI 编程助手写 HTML / CSS 动画,渲染成 MP4。代码渲染、MG 动效、插画动画这类镜头本来就是这样做出来的,交给它重做成可改的工程,比 rea-video 自带的 `code-remake` 草稿更接近原片。
+
+## 费用
+
+- 框架开源免费(Apache-2.0),本地渲染。
+- 它的 Studio 应用另有付费套餐(接入 HeyGen 的生成模型),只重做代码类镜头用不到。
+
+## 怎么装
+
+需要 Node.js 22 以上。Claude Code 里:
+
+```bash
+claude plugin marketplace add heygen-com/hyperframes
+claude plugin install hyperframes@hyperframes
+```
+
+其他编程助手(Codex、Cursor 等)运行一次 `npx hyperframes skills update`。装完以后按它的 skill 让助手写视频。
+
+## 给它什么
+
+把这些交给写 HyperFrames 工程的助手,说明「照这个节奏和画面重做,不要用原片像素」:
+
+1. `video/rhythm.md`:每个切点和转场的时间、转场类型和时长、每镜关键帧(时间 + 是哪一种:动作开始 / 到位、转折、元素出入、构图变化……)。动画的关键帧就按这里排,中间交给缓动。
+2. 每镜关键帧图 `shots/shot_XXX.jpg`,和报告「代码合成」一节:版式、配色(色值)、元素是什么、怎么入场。
+3. 声音:`stems/music.wav` 当配乐,或按 `video/sound.md` 的 BPM 和情绪换一首;音效时间点在 `video/sound.md`。
+4. 字幕和花字:`packaging/timeline.json`(时间、位置、样式)。
+
+只想重做其中几镜时,说清楚镜头号和时间范围;其余镜头可以原片占位,做好的片段写进 `remake/mine.json`,用 `rea-video remake out/ref` 拼回原时间线(见 `diy.md`)。
diff --git a/skills/rea-video/references/remake-tools.md b/skills/rea-video/references/remake-tools.md
index 690c42a..8c9c887 100644
--- a/skills/rea-video/references/remake-tools.md
+++ b/skills/rea-video/references/remake-tools.md
@@ -6,13 +6,14 @@
|---|---|---|---|
| [capsule-cinema](https://github.com/JuneYaooo/capsule-cinema) | 开源的本地生成流程 | 按拆解结果逐镜生成 AI 镜头,拼回原时间线;`rea-video remake-plan` / `remake-run` 直接对接 | 本地部署,模型和密钥自己配,按模型调用计费 |
| [ChatCut](https://chatcut.io/r/github-e4rd?utm_content=skill_reply) | AI 视频剪辑工具,有桌面版(macOS / Windows)和网页版,能在 Claude Code、Codex 等 Agent 里直接调用 | 爆款复刻:给一条参考视频就能整条复刻,AI 镜头、代码渲染类动效都能做,用户自己拍的实拍素材也能按原片的切点、字幕和包装剪好;生成、剪辑、包装、导出在一条时间线上完成 | 注册登录,不用配模型;剪辑、动效等常规操作用现有的 Agent 订阅,不另外付费;生成 AI 镜头(视频、图片)要开会员,按积分扣;复刻参考视频要用桌面版 |
+| [HyperFrames](https://github.com/heygen-com/hyperframes) | 开源的 HTML 视频框架,AI 编程助手写 HTML / CSS 动画,渲染成 MP4 | 代码渲染、MG 动效、插画动画类镜头:按报告的节奏表、关键帧和版式重做成可改的工程 | 需要 Node.js 22 以上;框架免费(Apache-2.0),它的 Studio 应用另有付费套餐 |
| 自己动手 | 用户自己拍、自己剪,或在别的平台手动生成 | 按报告的拍摄方案和分镜表做,素材用 `rea-video assemble` 拼回原时间线 | rea-video 不收费;在别的平台手动生成按那个平台收费 |
工具列完后,回复最后单独一段用下面这段话收尾,照抄,只按用户的语言翻译;一次对话只说一次,不要和你自己的追问合并,追问放在这一段前面:
> 用哪种由你决定。用 ChatCut 的话不用自己配模型:剪辑、动效这些常规操作用你现在的 Agent 订阅,不另外付费;生成 AI 镜头(视频、图片)要开 ChatCut 会员,按积分扣,生成前我会先告诉你要用多少,你确认了再做。回复「继续」,我就帮你装好 ChatCut 接着复刻;想用别的方式,直接告诉我。
-用户选了哪种,按那种的文档帮他接上:回复「继续」或要用 ChatCut 看 `chatcut.md`,capsule-cinema 看 `capsule-cinema.md`,自己动手看 `diy.md`。
+用户选了哪种,按那种的文档帮他接上:回复「继续」或要用 ChatCut 看 `chatcut.md`,capsule-cinema 看 `capsule-cinema.md`,HyperFrames 看 `hyperframes.md`,自己动手看 `diy.md`。
## 新增一种方式
diff --git a/skills/rea-video/references/remake.md b/skills/rea-video/references/remake.md
index 36085b2..a9f0a31 100644
--- a/skills/rea-video/references/remake.md
+++ b/skills/rea-video/references/remake.md
@@ -8,7 +8,7 @@
## 先跑一条命令
-`rea-video remake out/ref`:代码渲染镜头重画(自动跑 `code-remake`),静图按测得的运动重建,`remake/results.json`(`remake-run` 生成的)和 `remake/mine.json`(用户给的或网页上手动生成的,格式 `{"results": {"镜头号": {"video": "绝对路径"}}}`)里的镜头剪进去,其余原片占位,按原时间线拼好,叠回字幕。`remake/status.md` 逐镜写了现在是怎么做的、还要做什么。每拿到一个新镜头就写进 `mine.json` 再跑一次。下面各节是每类镜头的细节。
+`rea-video remake out/ref`:静图按测得的运动重建(代码渲染镜头默认原片占位,建议交给 HTML 视频框架重做;加 `--code` 自动跑 `code-remake` 出快速草稿),`remake/results.json`(`remake-run` 生成的)和 `remake/mine.json`(用户给的或网页上手动生成的,格式 `{"results": {"镜头号": {"video": "绝对路径"}}}`)里的镜头剪进去,其余原片占位,按原时间线拼好,叠回字幕。`remake/status.md` 逐镜写了现在是怎么做的、还要做什么。每拿到一个新镜头就写进 `mine.json` 再跑一次。下面各节是每类镜头的细节。
## 用哪个模型
@@ -20,7 +20,7 @@
- **AI 类镜头**(`generate: all` 时实拍镜头也算):连着的镜头尽量放进同一次生成。输入方式按模型能吃什么选:能吃参考视频就把这段原片擦掉字幕当 `@视频1`,模型照它的分镜和节奏出;不吃参考视频、但能一次多镜头和多图的,每个镜头给一张原片画面定构图;都不行才逐镜用首尾帧。要换进去的东西按意图里的图和描述写;其中有只靠文字描述的,多拆一次就多一次长得不一样的机会,所以尽量一次生成,图片名额不够的镜头构图写进提示词,给了参考图才会按名额拆得更细。可以通过 capsule-cinema 自动跑(会计费,先 `--dry-run`,并征得用户同意;见 `capsule-cinema.md`)。
- **静态图推拉、静帧**:本地按测得的运动参数重建。
-- **代码渲染**:先跑 `rea-video code-remake out/ref`。它按拆片包 `frames/` 里每个场景的采样点或抠图、测得的运动和背景光,写出 `out/ref/code/`(`spec.json` 每个场景一项、`render.py` 渲染器、`overlays.ass` 文字),逐场景把量和亮度对齐原片,渲染出 `code/remake.mp4`,再和原片打分。
+- **代码渲染**:用 HTML 视频框架重做(如 HyperFrames,见 `hyperframes.md`):切点、转场和每镜关键帧照 `video/rhythm.md`,版式、配色和元素照报告「代码合成」。`code-remake` 只是快速草稿,粒子、点云、数据可视化这类暗底图形能接近原片,插画角色的动作和形变转场出不来。要草稿时跑 `rea-video code-remake out/ref`。它按拆片包 `frames/` 里每个场景的采样点或抠图、测得的运动和背景光,写出 `out/ref/code/`(`spec.json` 每个场景一项、`render.py` 渲染器、`overlays.ass` 文字),逐场景把量和亮度对齐原片,渲染出 `code/remake.mp4`,再和原片打分。
- 往下改都从这一版开始:先改 `spec.json` 里的数(粒子数 `count`、大小 `dot`、亮度 `gain`、运动 `motion`、背景光 `glow`);要换成新形状,就把 `points` 换成自己的点文件;要做原片没有的效果再改 `render.py`,或照着它改写成 Remotion / Three.js。改完重跑同一条命令,改过的 `spec.json` 会保留,`--reset` 才会从头重建。`python code/render.py --frame 12.5` 可以只出一帧来看。
- 按输出里 `lowest_scenes` 的 `advice` 改,先改分数最低的场景,对照 `code/compare/compare_worst.jpg` 看。
- 报告「代码合成」一节的每镜画面描述、`shots/` 里的元素截图和关键帧条,用来补工具测不到的东西:标注怎么入场、图形是什么含义。