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

28.2 KB
Raw Blame
"""Turn a classified shot into a replication plan: which capability rule applies, which
models are candidates, and how capsule-cinema (or local ffmpeg) would execute it."""
from __future__ import annotations

import re
from pathlib import Path

import yaml

from .i18n import LangDict, T, join, model_name, semi
from .util import LOG

CAP = Path(__file__).resolve().parent / "capabilities"

# base label -> (routing rule, executor, capsule generation type)
LABEL_ROUTE = {
    "ai_video": ("R07-product-hero", "capsule_cinema", "first_last_frame"),
    "live_action": ("R07-product-hero", "capsule_cinema", "image_to_video"),
    "avatar": ("R03-talking-head", "capsule_cinema", "image_to_video"),
    "cg_3d": ("R08-product-multiview", "capsule_cinema", "first_last_frame"),
    "code_render": ("R01-code-graphics", "code_render_spec", None),
    "screen_capture": ("R02-screen-demo", "code_render_spec", None),
    "still_motion": ("R17-still-motion", "local_ffmpeg", None),
    "static_hold": ("R18-static-hold", "local_ffmpeg", None),
    "anim_2d": ("R19-2d-animation", "capsule_cinema", "first_last_frame"),
    "stop_motion": ("R20-stop-motion", "capsule_cinema", "image_to_video"),
    "film_footage": ("R21-film-footage", "source_footage", None),
}
NOTE = LangDict({
    "ai_video": "原片为 AI 生成:用视频模型重做;和哪些镜头一起生成、喂什么(参考原片、关键帧或首尾帧)按所选模型排,见复刻方案的生成单元",
    "live_action": "原片为实拍:按拍摄方案(景别/机位/打光)重新拍摄(若想改用 AI 生成,运行 rea-video plan --mode ai)",
    "avatar": "数字人口播:先克隆/合成配音,再用数字人模型由人像 + 音频驱动",
    "cg_3d": "3D 渲染:可以用视频模型近似(见复刻方案的生成单元);需要精确多角度时走 3D 建模 + Blender 渲染",
    "code_render": "代码渲染:让编程能力强的模型(如 Claude Opus 5.5 及以上、Gemini 4 系列)按节奏表、关键帧和版式写代码重建,可以参考 HyperFrames、Remotion 这类 HTML 视频框架;100% 可控,不需要视频模型",
    "screen_capture": "录屏/截图:用真实界面录屏或网页截图重建",
    "still_motion": "静态图推拉:用一张图 + 测得的缩放/平移参数在本地 ffmpeg 精确复刻",
    "static_hold": "静帧:一张图定格即可",
    "anim_2d": "2D 动画:先出角色设定图定画风,再用视频模型生成(见复刻方案的生成单元);要精确口型和动作时做 AE / Live2D / Spine 工程",
    "stop_motion": "定格动画:首选真的拍(手机固定 + 定格 App,每秒约 12 张);AI 生成只能近似顿挫感",
    "film_footage": "影视片段:画面剪自已有的电影/电视剧/短剧,复刻要找到原片对应片段再剪(版权属于片方,商用要授权);不用原片时,按同样景别、机位和打光自己拍,或用 AI 做近似画面",
}, en={
    "ai_video": "Source is AI-generated: remake it with a video model; which shots share a call and what it is fed (the source clip, keyframes or first / last frames) depend on the chosen model, see the generation units in the remake plan",
    "live_action": "Source is live action: reshoot per the shooting plan (shot size / camera setup / lighting); run rea-video plan --mode ai to remake with AI instead",
    "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: have a strong coding model (such as Claude Opus 5.5 or later, or the Gemini 4 series) rebuild it in code from the rhythm, key frames and layout, optionally on an HTML video framework such as HyperFrames or Remotion; 100% controllable, no video 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",
    "anim_2d": "2D animation: make a character sheet to lock the style, then generate with a video model (see the generation units); for precise lip sync and motion, build an AE / Live2D / Spine project",
    "stop_motion": "Stop motion: shooting for real is the first choice (phone locked off + a stop-motion app, about 12 frames per second); AI generation only approximates the stepped feel",
    "film_footage": "Film / TV footage: the picture is cut from an existing film, series or short drama; a remake has to find the same clip in the source and cut it (rights belong to the studio, commercial use needs a licence); without the source, shoot it yourself with the same shot size, camera setup and lighting, or approximate it with AI",
})
# AI edits on filmed footage: what was done, which routing rule rebuilds it, how in one line
AI_EDITS = {
    "face_swap": ("换脸", "R12-owned-footage-edit", "拍好后用视频编辑模型换人,保留动作"),
    "lip_sync": ("对口型/改台词", "R13-redub", "拍好后配新台词,再用口型重配模型改嘴型"),
    "restyle": ("整段风格化重绘", "R12-owned-footage-edit", "拍好后用视频编辑模型按参考风格重绘,保留动作和构图"),
    "outfit_swap": ("AI 换装", "R05-garment", "先出试穿图确认,再用视频模型或编辑模型换装"),
    "bg_replace": ("抠像换背景", "R12-owned-footage-edit", "绿幕拍摄后抠像合成;没有绿幕时用视频编辑模型换背景"),
    "object_edit": ("加/删/换物体", "R12-owned-footage-edit", "拍好后用视频编辑模型改画面里的物体"),
    "beautify": ("美颜/瘦脸", None, "剪映、美颜相机等的美颜功能即可,不需要生成模型"),
}
AI_EDITS_EN = {  # (what was done, how) in English, same keys as AI_EDITS
    "face_swap": ("face swap", "after the shoot, swap the person with a video-editing model, keeping the motion"),
    "lip_sync": ("lip sync / new lines", "after the shoot, record the new lines, then redo the mouth with a lip-sync model"),
    "restyle": ("full stylized repaint", "after the shoot, repaint with a video-editing model in the reference style, keeping motion and composition"),
    "outfit_swap": ("AI outfit swap", "make a try-on still to approve first, then swap the outfit with a video or editing model"),
    "bg_replace": ("keyed background replacement", "shoot on green screen and key / composite; without a green screen, replace the background with a video-editing model"),
    "object_edit": ("object added / removed / replaced", "after the shoot, change the object in frame with a video-editing model"),
    "beautify": ("beauty filter / face slimming", "the beauty tools in CapCut, beauty camera apps etc. are enough, no generative model needed"),
}
def engine_range(engine: str | None, models: dict | None = None) -> tuple[int, int]:
    """Seconds one call of this model can make (min, max), from the capability map; (4, 15) for a name it lacks."""
    key = re.sub(r"[^a-z0-9]", "", str(engine or "").lower())
    for m in (models if models is not None else Planner().models).values():
        if re.sub(r"[^a-z0-9]", "", m["id"].lower()) == key:
            d = (m.get("limits") or {}).get("duration_s") or {}
            return int(d.get("min") or 1), int(d.get("max") or 15)
    return 4, 15


PROMPT_KEYS = ("image_prompt", "video_prompt", "video_prompt_en", "motion_prompt", "motion_prompt_en")


def shot_prompts(shot: dict) -> dict:
    """Reverse-engineered prompts for one shot: the agent's review wins over the VLM (it is the later, checked pass)."""
    out = {}
    for src in ((shot.get("vlm") or {}).get("replication") or {}, (shot.get("review") or {}).get("replication") or {}):
        out.update({k: v for k, v in src.items() if k in PROMPT_KEYS and v})
    return out


HAILUO_MOVES = {
    "推": "[Push in]", "push-in": "[Push in]",
    "拉": "[Pull out]", "pull-out": "[Pull out]",
    "摇": "[Pan right]", "pan": "[Pan right]",
    "移": "[Truck right]", "track": "[Tracking shot]",
    "摇/移": "[Pan right,Truck right]", "拉/摇/移": "[Pull out,Pan right]",
    "跟": "[Tracking shot]", "tracking": "[Tracking shot]",
    "环绕": "[Pan right,Truck left]", "orbit": "[Pan right,Truck left]",
    "手持": "[Shake]", "handheld": "[Shake]",
}


def hailuo_bracket(shot: dict) -> str:
    """Hailuo 2.3's fixed bracket camera command for a shot, from its measured or seen camera movement."""
    from .aspects.vocab import canon

    cm = ((shot.get("aspects") or {}).get("camera") or {}).get("measured") or {}
    v = shot.get("review") or shot.get("vlm") or {}
    move = cm.get("move") or v.get("camera_move")
    c = canon(move) if move else None
    if c and c in HAILUO_MOVES:
        return HAILUO_MOVES[c]
    if move and str(move).lower() in HAILUO_MOVES:
        return HAILUO_MOVES[str(move).lower()]
    feat_d = shot.get("features") or {}
    traj = feat_d.get("camera_traj")
    if traj == "push_in":
        return "[Push in]"
    if traj == "pull_out":
        return "[Pull out]"
    if traj == "pan_left":
        return "[Pan left]"
    if traj == "pan_right":
        return "[Pan right]"
    if traj == "tilt_up":
        return "[Tilt up]"
    if traj == "tilt_down":
        return "[Tilt down]"
    feat = feat_d.get("camera")
    if feat == "handheld_like":
        return "[Shake]"
    if feat == "smooth_move":
        return "[Tracking shot]"
    if feat == "planar_zoom_pan":
        z = feat_d.get("zoom_per_s", 0.0)
        return "[Push in]" if z > 0.01 else "[Pull out]" if z < -0.01 else "[Pan right]"
    return "[Static shot]"


def camera_move_words(shot: dict) -> tuple[str, str]:
    """Only the camera move (report language, English), for first-frame mode where static framing is already in the image."""
    from .aspects.vocab import ZH2EN, canon, show

    cm = ((shot.get("aspects") or {}).get("camera") or {}).get("measured") or {}
    v = shot.get("review") or shot.get("vlm") or {}
    move = cm.get("move") or (v.get("camera_move") if v.get("camera_move") not in (None, "", "固定", "static") else None)
    if not move:
        feat_d = shot.get("features") or {}
        traj = feat_d.get("camera_traj")
        traj_map = {
            "push_in": (T("镜头推近", "camera push-in"), "camera push-in"),
            "pull_out": (T("镜头拉远", "camera pull-out"), "camera pull-out"),
            "pan_left": (T("镜头左摇/左移", "camera pan/truck left"), "camera pan/truck left"),
            "pan_right": (T("镜头右摇/右移", "camera pan/truck right"), "camera pan/truck right"),
            "tilt_up": (T("镜头上摇/上移", "camera tilt/pedestal up"), "camera tilt/pedestal up"),
            "tilt_down": (T("镜头下摇/下移", "camera tilt/pedestal down"), "camera tilt/pedestal down"),
            "handheld": (T("手持镜头", "handheld camera"), "handheld camera"),
        }
        if traj in traj_map:
            return traj_map[traj]
        feat = feat_d.get("camera")
        if feat == "handheld_like":
            return T("手持镜头", "handheld camera"), "handheld camera"
        if feat == "smooth_move":
            return T("镜头平滑移动", "smooth camera movement"), "smooth camera movement"
        return T("固定镜头", "static camera"), "static camera"
    c = canon(move)
    en_m = ZH2EN.get(c) or (move if move.isascii() else "moves")
    return T("镜头{m}", "camera {m}", m=show(move)), f"camera {en_m}"


def _where(cx: float | None, cy: float | None) -> tuple[str, str] | None:
    """Where the measured subject sits in the frame, (zh, en)."""
    if cx is None or cy is None:
        return None
    h = ("左侧", "left") if cx < 0.38 else ("右侧", "right") if cx > 0.62 else ("中间", "centre")
    v = ("上部", "upper") if cy < 0.38 else ("下部", "lower") if cy > 0.62 else ("", "")
    if h[1] == "centre" and not v[1]:
        return "主体在画面正中", "subject centred in frame"
    return f"主体在画面{v[0]}{h[0]}".replace("上部中间", "上部正中").replace("下部中间", "下部正中"), \
        f"subject in the {(v[1] + ' ') if v[1] else ''}{h[1]} of the frame".replace("upper centre", "upper middle").replace("lower centre", "lower middle")


def with_acting(prompt: str, act: dict | None, image: bool = False, en: bool = False) -> str:
    """Add the visible acting (face, body, change over time, strength) to a shot prompt, unless the prompt already
    carries it. Readers' prompts tend to name the emotion or leave the face out, which gives a flat or mask-like remake.
    en=True: the English prompt, which only takes English acting words."""
    from .performance import image_line, prompt_line, prompt_line_en

    line = prompt_line_en(act) if en else image_line(act) if image else prompt_line(act)
    if not prompt or not line:
        return prompt
    cue = ((act or {}).get("en") or "") if en else ((act or {}).get("face") or "")
    if cue and cue in prompt:
        return prompt
    end = "" if prompt.rstrip().endswith(("。", ".", ";", ";")) else ". " if en else T("。", ". ")
    return prompt.rstrip() + end + line


def framing_words(shot: dict) -> tuple[str, str]:
    """Shot size, camera angle, subject position and camera move as a prompt prefix, (report language, English).
    The readers' free-text prompts tend to keep the style words and drop these, which flattens the camera in a remake."""
    from .aspects.base import seen
    from .i18n import lang

    asp = shot.get("aspects") or {}
    fr = (asp.get("framing") or {}).get("result") or {}
    fm = (asp.get("framing") or {}).get("measured") or {}
    cm = (asp.get("camera") or {}).get("measured") or {}
    v = shot.get("review") or shot.get("vlm") or {}
    size = fr.get("shot_size") or v.get("shot_size")
    angle = fr.get("camera_angle")
    comp = seen(shot, "framing", "composition")
    comp = comp.get("agent") or comp.get("vlm")
    where = _where(fm.get("center_x"), fm.get("center_y")) if fm.get("subject") in ("face", "focus") else None
    move = cm.get("move") or (v.get("camera_move") if v.get("camera_move") not in (None, "", "固定", "static") else None)
    from .aspects.vocab import ZH2EN, canon, show

    loc = [x for x in (show(size), show(angle), comp or (where and (where[1] if lang() == "en" else where[0])),
                       move and T("镜头{m}", "camera {m}", m=show(move))) if x]

    def en_of(x):  # the English prompt always gets English words, whatever the report language
        c = canon(x) if x else None
        return ZH2EN.get(c) or (x if x and x.isascii() else None)

    en = [en_of(size), en_of(angle),
          comp if comp and comp.isascii() else (where[1] if where and not comp else None),
          move and ("camera " + (en_of(move) or "moves"))]
    return T(",", ", ").join(loc), ", ".join(x for x in en if x)


def _with_framing(prompt: str, words: str) -> str:
    """Prefix the framing words unless the prompt already states each of them."""
    if not prompt or not words:
        return prompt
    sep = "," if "," in words else ", "
    missing = [w for w in words.split(sep) if w and w not in prompt]
    if not missing:
        return prompt
    end = "。" if not words.isascii() else ". "
    return sep.join(missing) + end + prompt


def _move_words(f: dict) -> str:
    """Measured camera / whole-picture motion of a rendered shot in words (what the code camera should do)."""
    cam = f.get("camera")
    if cam in (None, "unknown", "static"):
        return T("固定", "static")
    if cam == "static_with_subject_motion":
        return T("固定机位,画面内元素在动", "static frame, elements move inside it")
    bits = []
    zoom = f.get("zoom_per_s", 0.0)
    if abs(zoom) > 0.01:
        bits.append(T("推近 {z:.0%}/s", "push in {z:.0%}/s", z=zoom) if zoom > 0 else T("拉远 {z:.0%}/s", "pull out {z:.0%}/s", z=-zoom))
    if f.get("pan_px_per_s", 0.0) > 8:
        d = f.get("pan_dir_deg", 0.0) % 360
        where = T("右", "right") if d < 45 or d >= 315 else T("下", "down") if d < 135 else T("左", "left") if d < 225 else T("上", "up")
        bits.append(T("画面向{w}移", "picture drifts {w}", w=where))
    if abs(f.get("rot_deg_per_s", 0.0)) > 1:
        bits.append(T("旋转", "rotates"))
    return T(",", ", ").join(bits) or T("固定机位,画面内元素在动", "static frame, elements move inside it")


def code_scene(shot: dict) -> dict:
    """What a code-rendered shot draws, for rebuilding it: the picture (image readers' description), whether it is
    particle / point-cloud graphics on black, the measured camera move and the confident on-screen text."""
    facts = (shot.get("deterministic") or {}).get("facts") or {}
    desc = (shot.get("review") or {}).get("description") or (shot.get("vlm") or {}).get("description") or ""
    text = shot.get("text") or {}
    sure = {it.get("text") for it in text.get("items", []) if it.get("conf", 0) >= 0.85}
    words: list[str] = []
    for tr in text.get("tracks", []):
        if tr.get("kind") == "subtitle":
            continue
        for w in tr.get("texts", []):
            if w in sure and w not in words:
                words.append(w)
    motion = shot.get("motion") or {}
    pal = motion.get("palette") or {}
    return {"picture": str(desc), "particles": facts.get("fine_dark", 0.0) > 0.5, "style": code_style(shot),
            "move": _move_words(shot.get("features") or {}), "on_screen_text": words[:6],
            "background": pal.get("background"), "palette": [c["hex"] for c in pal.get("colours", [])[:5]], "drawn": motion.get("drawn") or [],
            "events": motion.get("events", []), "sequences": motion.get("sequences", []), "layer": motion.get("layer"),
            "static": motion.get("static", []), "elements_sheet": motion.get("elements_sheet"),
            "strip": (shot.get("assets") or {}).get("strip"), "transition_in": shot.get("transition_in"),
            "flash_s": shot.get("flash_s"), **({"transition": shot["transition"]} if shot.get("transition") else {})}


# how a code-rendered picture is built, from the measured look; keys of CODE_STYLES
def code_style(shot: dict) -> str:
    facts = (shot.get("deterministic") or {}).get("facts") or {}
    text = shot.get("text") or {}
    if facts.get("fine_dark", 0.0) > 0.5:
        return "particles"
    if facts.get("fine_light", 0.0) > 0.5:
        return "lineart"
    kind = facts.get("vector_kind")
    if kind in ("procedural", "neon"):
        return kind
    sure = {it.get("text") for it in text.get("items", []) if it.get("conf", 0) >= 0.85}
    numbers = {w for tr in text.get("tracks", []) for w in tr.get("texts", [])
               if w in sure and re.search(r"[1-9]", w)}  # "000" / "0" are usually OCR noise on shapes
    if len(numbers) >= 3:
        return "data"
    if facts.get("ui_text", 0.0) > 0.5 or facts.get("ui_gray", 0.0) > 0.5 or facts.get("text_like", 0.0) > 0.6:
        return "ui"
    if kind in ("gradient", "colour_fields"):
        return "gradient"
    if text.get("text_coverage", 0.0) > 0.04:
        return "type"
    return "shapes"


def CODE_STYLES() -> dict[str, tuple[str, str]]:
    """style -> (short name, how to build it in a Remotion / HTML project)."""
    return {
        "particles": (T("粒子/点云", "particles / point cloud"),
                      T("Three.js 粒子系统(点按目标形状采样,形状间插值变形,加辉光后期),用 @remotion/three 逐帧渲染",
                        "Three.js particle system (points sampled on the target shape, morph between shapes, bloom), rendered frame by frame with @remotion/three")),
        "lineart": (T("线稿/点阵", "line art / dots"),
                    T("SVG 路径用 stroke-dashoffset 逐帧描线,或 Canvas 按噪声场画流线 / 按目标形状排点;线宽、颜色、密度按画面量",
                      "SVG paths drawn on with stroke-dashoffset, or Canvas flow lines from a noise field / dots placed on a target shape; "
                      "match stroke width, colour and density from the frame")),
        "procedural": (T("程序生成色场", "procedural colour field"),
                       T("GLSL 片元着色器(分形/噪声/plasma),Three.js ShaderMaterial 或 WebGL canvas,时间作 uniform 逐帧驱动",
                         "GLSL fragment shader (fractal / noise / plasma) via Three.js ShaderMaterial or a WebGL canvas, time passed as a uniform each frame")),
        "neon": (T("暗底辉光", "glow on dark"),
                 T("深色底 + 渐变填充文字/线条,CSS drop-shadow 或 SVG feGaussianBlur 叠两层做辉光,亮度随帧轻微呼吸",
                   "Dark ground + gradient-filled text / lines, glow from two stacked CSS drop-shadows or an SVG feGaussianBlur, brightness breathing per frame")),
        "data": (T("数据图表", "data chart"),
                 T("SVG/D3 比例尺画坐标和图形,数字用 interpolate() 逐帧计数,柱/线按 spring() 生长",
                   "SVG / D3 scales for axes and marks, numbers counted up with interpolate(), bars / lines grown with spring()")),
        "ui": (T("界面/文档", "UI / document"),
               T("HTML/CSS 按截图还原卡片和版式(圆角、阴影、字号),元素用 spring() 进场;真界面可直接录屏",
                 "HTML / CSS cards and layout matched to the frame (radius, shadow, type sizes), elements enter with spring(); a real UI can be screen-recorded")),
        "gradient": (T("渐变/色块", "gradients / colour fields"),
                     T("CSS 线性/径向渐变,或几个大圆加 filter: blur() 慢速漂移;毛玻璃卡片用 backdrop-filter",
                       "CSS linear / radial gradients, or a few large circles with filter: blur() drifting slowly; glass cards with backdrop-filter")),
        "type": (T("文字动效", "kinetic type"),
                 T("逐词/逐字 spring() 进场(位移+缩放+透明度),强调词加色块;字体、字号、行距按画面量",
                   "Word-by-word spring() entrances (offset + scale + opacity), highlight boxes on key words; match font, size and leading from the frame")),
        "shapes": (T("矢量图形", "vector shapes"),
                   T("SVG 图形 + interpolate()/spring() 关键帧,按画面量出位置和节奏",
                     "SVG shapes + interpolate() / spring() keyframes, positions and timing measured from the frame")),
    }


def user_capabilities() -> Path:
    """Where a user's own capability entries live (models looked up after the shipped map was written)."""
    from .memory import home

    return home() / "capabilities"


def _load(name: str):
    with (CAP / name).open(encoding="utf-8") as f:
        return yaml.safe_load(f)


class Planner:
    def __init__(self) -> None:
        self.routing = _load("routing.yaml")
        self.rules = {r["id"]: r for r in self.routing["rules"]}
        self.models = {}
        notes = _load("prompting.yaml") or {}
        self.prompting: dict[str, dict] = notes.get("models") or {}   # how to write prompts for each model
        for f in sorted((CAP / "models").glob("*.yaml")):
            for m in (yaml.safe_load(f.read_text(encoding="utf-8")) or {}).get("models", []):
                self.models[m["id"]] = m
        # the user's own entries (~/.rea-video/capabilities/models/*.yaml, written after looking a model up) win over
        # the shipped map: same layout, plus an optional "prompting" block per model
        for f in sorted((user_capabilities() / "models").glob("*.yaml")):
            try:
                doc = yaml.safe_load(f.read_text(encoding="utf-8")) or {}
            except yaml.YAMLError as exc:
                LOG.warning("skipping %s: %s", f, exc)
                continue
            for m in doc.get("models", []) if isinstance(doc, dict) else []:
                if isinstance(m, dict) and m.get("id") and m.get("primitives"):
                    self.models[m["id"]] = dict(m, local=str(f))
                    if isinstance(m.get("prompting"), dict):
                        self.prompting[m["id"]] = m["prompting"]
        self.keyframe_notes: list[str] = notes.get("keyframes") or []  # frame-picking practice shared by all models

    def edit_steps(self, edits: list | None) -> list[dict]:
        """Image readers' list of AI edits on a filmed shot -> post-production steps with candidate models."""
        out = []
        for e in edits or []:
            if not isinstance(e, dict) or e.get("kind") not in AI_EDITS or any(x["kind"] == e["kind"] for x in out):
                continue
            zh, rule_id, how = AI_EDITS[e["kind"]]
            zh_en, how_en = AI_EDITS_EN[e["kind"]]
            names = [model_name(self.models[m]["name"]) for m in (self.rules.get(rule_id) or {}).get("prefer", [])
                     if m in self.models and self.models[m]["status"] != "shutdown"][:3]
            out.append({"kind": e["kind"], "kind_zh": T(zh, zh_en), "evidence": str(e.get("evidence", ""))[:120], "rule": rule_id,
                        "how": T(how, how_en) + (T("({n})", " ({n})", n=" / ".join(names)) if names else "")})
        return out

    def plan_shot(self, label: str, shot: dict, video: dict, engine: str = "minimax-h3") -> dict:
        rule_id, executor, gen_type = LABEL_ROUTE.get(label, ("R14-ambient-broll", "capsule_cinema", "text_to_video"))
        from .dance import move_of

        moved = move_of({**shot, "base": {"label": label}})
        if moved:  # the moves are the point: driven from the source clip; capsule-cinema keeps the original until then
            rule_id, executor, gen_type = "R04-precise-motion", "motion_drive", None
        rule = self.rules.get(rule_id, {})
        candidates = [{"id": m, "name": model_name(self.models[m]["name"]), "status": self.models[m]["status"]}
                      for m in rule.get("prefer", []) if m in self.models and self.models[m]["status"] != "shutdown"]
        plan = {"label": label, "rule": rule_id, "route": rule.get("route", []), "candidates": candidates,
                "verify": rule.get("verify", []), "executor": executor,
                "note": T("动作是看点:用原片这段当动作驱动(`rea-video drive` 出驱动视频,见复刻方案「动作驱动」),不用首尾帧生成",
                          "the moves are the point: drive them from this stretch of the source (`rea-video drive` writes the drive clips, see “Motion drive” "
                          "in the remake plan) instead of first / last frame generation") if moved else NOTE.get(label, "")}
        dur = float(shot["duration"])
        mat = shot.get("material") or {}
        user_assets = []
        for it in mat.get("items", []):
            if it.get("real_material"):
                where = T("整个画面", "whole frame") if it.get("region") == "full" else (
                    T("画面局部 x{:.0%} y{:.0%} 宽{:.0%} 高{:.0%}", "part of the frame x{:.0%} y{:.0%} w{:.0%} h{:.0%}").format(*it["bbox"])
                    if it.get("bbox") else T("画面局部", "part of the frame"))
                user_assets.append({"kind": it["kind"], "kind_zh": it.get("kind_zh", it["kind"]), "where": where,
                                    "description": it.get("description", ""), "reference": shot.get("assets", {}).get("first_frame")})
        if user_assets:
            plan["user_assets"] = user_assets
            plan["note"] += semi() + T("需要用户提供真实素材:", "real material the user must supply: ") \
                + join(T("{k}({w})", "{k} ({w})", k=a["kind_zh"], w=a["where"]) for a in user_assets)
        refs = mat.get("references") or []
        if refs:
            plan["references"] = refs
            plan["note"] += semi() + T("生成时作参考:", "references for generation: ") + join(dict.fromkeys(r["kind_zh"] for r in refs))
        if executor == "local_ffmpeg":
            m = shot.get("features", {})
            plan["local"] = {"zoom_per_s": m.get("zoom_per_s", 0.0), "pan_px_per_s": m.get("pan_px_per_s", 0.0),
                             "pan_dir_deg": m.get("pan_dir_deg", 0.0), "analysis_width": 480, "duration": round(dur, 3)}
        elif executor == "code_render_spec":
            plan["spec"] = {"text_layers": [l for l in shot.get("layers", []) if l["kind"] in ("subtitle", "title", "label")],
                            "beats": shot.get("beats", []), "duration": round(dur, 3), "scene": code_scene(shot)}
        return plan