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

Flag reference frames that conflict with swaps

june01258b9e85a2
diff --git a/rea_video/generation.py b/rea_video/generation.py
index b5d0841..4cfd0b4 100644
--- a/rea_video/generation.py
+++ b/rea_video/generation.py
@@ -42,6 +42,7 @@ GEN_LABELS = ("ai_video", "cg_3d", "anim_2d")
ALL_GEN_LABELS = GEN_LABELS + ("live_action", "stop_motion", "film_footage", "avatar")
INSERT_LABELS = ("code_render", "screen_capture", "still_motion", "static_hold")
INTENT_FILE = Path("remake") / "intent.yaml"
+REDRAWN_DIR = Path("remake") / "redrawn"
PROMPTS_FILE = Path("remake") / "prompts.json"
STRATEGY_ZH = {"remix": ("参考原片改写", "remix of the source"), "keyframes": ("关键帧参考多镜头", "multi-shot from source keyframes"),
@@ -430,12 +431,27 @@ def shots_written(text: str) -> int:
return max([int(x) for p in SHOT_RES for x in re.findall(p, text)] or [0])
+def redrawn_frame(out: Path, name: str) -> Path | None:
+ """A source frame the user redrew with the swapped-in subject: remake/redrawn/<name>.png|jpg|webp."""
+ return next((f for ext in ("png", "jpg", "jpeg", "webp") if (f := Path(out) / REDRAWN_DIR / f"{name}.{ext}").is_file()), None)
+
+
+def source_frame_names(u: dict) -> list[str]:
+ """The frames this unit takes from the source, by the name a redrawn version goes under."""
+ names = [f"shot{int(r['keyframe']):03d}" for r in u.get("refs") or [] if r.get("keyframe")]
+ if u.get("strategy") == "frames":
+ names.append(f"{u['id']}_first")
+ if any(x["kind"] == "last_frame" and x["need"] != "no" for x in u.get("inputs") or []):
+ names.append(f"{u['id']}_last")
+ return names
+
+
def unit_images(u: dict) -> list[dict]:
"""The images one unit sends, in prompt order."""
return [r for r in u.get("refs") or [] if r["tag"].startswith("@图片")]
-def checks(plan: dict, intent: dict, prompts: dict[str, str], notes: dict | None, gen_seconds: float) -> list[dict]:
+def checks(plan: dict, intent: dict, prompts: dict[str, str], notes: dict | None, gen_seconds: float, root: Path | None = None) -> list[dict]:
"""Problems to fix before paying for generation. level "error" blocks `remake-plan`; "warn" is shown."""
spec, units = plan.get("spec") or {}, plan.get("units") or []
out: list[dict] = []
@@ -464,6 +480,11 @@ def checks(plan: dict, intent: dict, prompts: dict[str, str], notes: dict | None
if u["generate_s"] < SHORT_UNIT_S:
add("warn", T("{u} 只有 {d:.1f} 秒:单独生成不稳,按模型最短时长生成后剪短,或和相邻镜头合到一起",
"{u} is only {d:.1f}s: unstable on its own; generate the model's minimum and trim, or join it with a neighbour", u=u["id"], d=u["generate_s"]), u["id"])
+ stale_frames = [x for x in source_frame_names(u) if not (root and redrawn_frame(root, x))] if intent.get("swaps") else []
+ if stale_frames:
+ add("warn", T("{u} 的参考帧还是原片里被替换的主体,模型会在镜头中途变来变去:先照换入的主体重画,存成 remake/redrawn/{f}.png",
+ "{u}'s reference frames still show the subject being swapped, so the model may morph it mid-shot: redraw them with the new subject as remake/redrawn/{f}.png",
+ u=u["id"], f="|".join(stale_frames)), u["id"])
final = prompts.get(u["id"])
if not final:
add("warn", T("{u} 还是通用草稿:按 {m} 的写法写好最终提示词,放进 remake/prompts.json", "{u} still has the generic draft: write the final prompt in {m}'s format into remake/prompts.json",
diff --git a/rea_video/integrations/capsule_cinema.py b/rea_video/integrations/capsule_cinema.py
index 9bb0cc5..b63527e 100644
--- a/rea_video/integrations/capsule_cinema.py
+++ b/rea_video/integrations/capsule_cinema.py
@@ -224,7 +224,7 @@ def build_remake_jobs(b: dict, bdir: Path, capsule_root: Path) -> Path:
plan = {**plan, "units": plan.get("units") or []}
# the intent and the final prompts may have changed since the plan was written: check what will actually be sent
prompts = load_prompts(bdir)
- cs = checks(plan, load_intent(bdir), prompts, plan.get("prompting"), sum(u["duration"] for u in plan["units"])) if plan["units"] else []
+ cs = checks(plan, load_intent(bdir), prompts, plan.get("prompting"), sum(u["duration"] for u in plan["units"]), root=bdir) if plan["units"] else []
errors = [c["msg"] for c in cs if c["level"] == "error"]
if errors:
raise ValueError(T("方案检查没过,先改:", "the plan checks failed, fix these first: ") + semi().join(errors))
@@ -304,7 +304,7 @@ def _unit_jobs(b: dict, bdir: Path, run_dir: Path, plan: dict, prompts: dict[str
frame per shot (keyframes), the shot's first / last frame (frames) or nothing but text; the user's images first; the
final prompt from remake/prompts.json, else the draft. Everything taken from the source has its subtitles erased."""
from ..drive import scene_text
- from ..generation import unit_images
+ from ..generation import redrawn_frame, unit_images
spec = plan.get("spec") or {}
lo, hi = int(spec.get("min") or 1), int(spec.get("max") or 15)
@@ -333,7 +333,9 @@ def _unit_jobs(b: dict, bdir: Path, run_dir: Path, plan: dict, prompts: dict[str
else:
params.update(generation_type="image_to_video", image_path=first)
jid = u["id"] if len(parts) == 1 else f"{u['id']}-{part}"
- times = [r["t"] for r in u["refs"] if r.get("keyframe")] + ([u["start"] + 0.05, u["end"] - 0.08] if u["strategy"] == "frames" else [])
+ times = [r["t"] for r in u["refs"] if r.get("keyframe") and not redrawn_frame(bdir, f"shot{int(r['keyframe']):03d}")]
+ if u["strategy"] == "frames":
+ times += [t for name, t in ((f"{u['id']}_first", u["start"] + 0.05), (f"{u['id']}_last", u["end"] - 0.08)) if not redrawn_frame(bdir, name)]
words = list(dict.fromkeys(w for t in times for w in scene_text(b, t)))
warning = T("参考帧里还有画面内文字({w}),模型可能照着生成:换成干净图,或确认有授权", "the reference frames still show text in the picture ({w}), which the model may copy: use a clean image or confirm you have the rights",
w=join(words[:6])) if words else None
@@ -349,12 +351,13 @@ def ref_clips(b: dict, bdir: Path, unit: dict) -> dict[tuple[int, str], str]:
reference clips ({(part, "@视频1"): path}), per-shot keyframes ({(1, "@图片3"): path}) and the first / last frame of
a frames unit ({(1, "first"): path, (1, "last"): path}). Files are named by span, so a re-plan never reuses a stale one."""
from ..drive import clean_clip, clean_frame
+ from ..generation import redrawn_frame
d = bdir / "remake" / "refs"
out = {}
for r in unit.get("refs") or []:
if r.get("keyframe"):
- f = d / f"{unit['id']}_shot{int(r['keyframe']):03d}_{r['t']:.2f}.jpg"
+ f = redrawn_frame(bdir, f"shot{int(r['keyframe']):03d}") or d / f"{unit['id']}_shot{int(r['keyframe']):03d}_{r['t']:.2f}.jpg"
if not f.is_file():
clean_frame(b, r["t"], f)
out[(1, r["tag"])] = str(f.resolve())
@@ -369,7 +372,7 @@ def ref_clips(b: dict, bdir: Path, unit: dict) -> dict[tuple[int, str], str]:
for key, t in (("first", s0 + 0.05), ("last", s1 - 0.08)):
if key == "last" and not any(x["kind"] == "last_frame" and x["need"] != "no" for x in unit.get("inputs") or []):
continue
- f = d / f"{unit['id']}_{key}_{t:.2f}.jpg"
+ f = redrawn_frame(bdir, f"{unit['id']}_{key}") or d / f"{unit['id']}_{key}_{t:.2f}.jpg"
if not f.is_file():
clean_frame(b, t, f)
out[(1, key)] = str(f.resolve())
diff --git a/rea_video/production.py b/rea_video/production.py
index 7f58825..281f9e1 100644
--- a/rea_video/production.py
+++ b/rea_video/production.py
@@ -392,7 +392,7 @@ def production_plan(b: dict, out: Path, engine: str = "minimax-h3") -> dict:
gen_s = sum(u["duration"] for u in units)
prompts = gen_mod.load_prompts(out)
plan["prompts"] = {k: v for k, v in prompts.items() if any(u["id"] == k for u in units)}
- plan["checks"] = gen_mod.checks(plan, intent, prompts, plan.get("prompting"), gen_s)
+ plan["checks"] = gen_mod.checks(plan, intent, prompts, plan.get("prompting"), gen_s, root=out)
plan["drive"] = dance.units(b)
plan["shoot"] = _setups([r for r in shots if r["base"]["label"] not in gen_labels], sig, thr, b)
code, cur = [], []