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

Shape prompt drafts per model

junebc97f214ebed
diff --git a/rea_video/capabilities/models/video.yaml b/rea_video/capabilities/models/video.yaml
index b9dcd9e..66ec49d 100644
--- a/rea_video/capabilities/models/video.yaml
+++ b/rea_video/capabilities/models/video.yaml
@@ -227,7 +227,8 @@ models:
access: [app, api]
primitives: [video.t2v, video.i2v_first_frame, video.i2v_first_last, video.multi_reference, video.multi_shot, video.extend, video.native_audio]
limits:
- duration_s: {min: 4, max: 8}
+ duration_s: {min: 4, max: 8, steps: [4, 6, 8]}
+ duration_with_refs_s: [8]
resolutions: [720p, 1080p, 4K]
refs: {image: 4}
audio: {native: true}
diff --git a/rea_video/capabilities/prompting.yaml b/rea_video/capabilities/prompting.yaml
index a215afe..928e8e0 100644
--- a/rea_video/capabilities/prompting.yaml
+++ b/rea_video/capabilities/prompting.yaml
@@ -61,6 +61,8 @@ models:
- https://runway.com/resources/seedance-2-5-prompt-guide
lint:
max_cjk: 500
+ forbid:
+ - {re: '编辑视频|增加|加上|删除|去掉|修改|替换|改成|换成|延长|延续|续写', when: refs, level: warn, why: 带参考素材时这些词会让请求被当成编辑或续写任务:换个说法,或把 omni_reference_task_type 设成 reference}
seedance-2.5-flash:
basis: vendor
@@ -112,6 +114,7 @@ models:
kling-4.0:
basis: vendor
+ draft: {shot: {zh: "镜头{i}({d}秒):{text}", en: "Shot {i} ({d}s): {text}"}, image_tag: "@Image{n}", video_tag: "@Video{n}"}
structure: >-
四块:[Asset Roles] 每个素材管什么 → [Overall Settings] 整体设定 → [Sequence of Events] 按时间写事件,再写运镜 → [Audio] 声音。先用一句话写清主体、场景、动作、情绪,再只补运镜、时间、声音和要保持不变的东西
language: 没有指定提示词语言;台词和画面文字支持中、英、日、韩、西、葡、德、法、印地语,中文方言和英语口音
@@ -157,6 +160,7 @@ models:
kling-3.0:
basis: third-party
+ lint: {max_chars: 2500}
structure: 没有固定公式;按 主体、动作、场景、运镜、光线、情绪 来写,示例顺序是 场景 → 主体 → 运镜 → 动作 → 台词
language: 中文、英文都可以;台词支持中、英、日、韩、西和方言口音
length: 整体 2500 字符以内;自定义分镜每个镜头 512 字符以内,超出被截断
@@ -184,6 +188,7 @@ models:
kling-o3:
basis: vendor
+ lint: {max_chars: 2500}
structure: >-
参考生成:[主体的细节描述] + [主体之间的互动 / 动作] + [环境或背景] + [光线、风格等视觉方向]
language: 中文、英文都可以
@@ -209,6 +214,8 @@ models:
veo-3.1:
basis: vendor
+ draft: {lang: en, shot: "[{a}-{z}] {text}", image_tag: "image {n}", negatives_line: false}
+ lint: {language: en}
structure: >-
[Cinematography 镜头] + [Subject 主体] + [Action 动作] + [Context 环境] + [Style & Ambiance 风格氛围];短片一条提示词只写一个集中的瞬间
language: 提示词用英文
@@ -253,6 +260,8 @@ models:
gemini-omni-flash:
basis: vendor
+ draft: {lang: en, shot: "[{s0}-{s1}s] {text}", image_tag: "reference image {n}", video_tag: "reference video {n}"}
+ lint: {language: en}
structure: 没有公式,自然语言写清场景、运镜、光线、氛围
language: 英文(其他语言官方未评估)
length: 官方没给上限
@@ -345,6 +354,15 @@ models:
minimax-h3:
basis: vendor
+ draft:
+ lang: en
+ head: "integrated_multimodal_description: "
+ first_shot: "[Shot 1] {text}"
+ shot: "[Shot {i}] At {at}, the camera cuts to: {text}"
+ image_tag: "<Picture {n}>"
+ video_tag: "<Video {n}>"
+ negatives_line: false
+ tail: ["overall_soundscape: Only the natural sounds of the actions on screen.", "non_diegetic_music: N/A"]
structure: >-
分字段写:integrated_multimodal_description:(画面和动作)→ overall_soundscape:(环境声和音效,1–4 句)→ non_diegetic_music:(配乐的乐器和速度,1–3 句,没有写 N/A)。两个声音字段不要留空,留空容易出多余的人声
language: 提示词用英文;台词和画面文字保留原语言
@@ -379,6 +397,15 @@ models:
minimax-h3-max:
basis: vendor
+ draft:
+ lang: en
+ head: "integrated_multimodal_description: "
+ first_shot: "[Shot 1] {text}"
+ shot: "[Shot {i}] At {at}, the camera cuts to: {text}"
+ image_tag: "<Picture {n}>"
+ video_tag: "<Video {n}>"
+ negatives_line: false
+ tail: ["overall_soundscape: Only the natural sounds of the actions on screen.", "non_diegetic_music: N/A"]
structure: >-
和 MiniMax H3 同一套写法(rea-video models minimax-h3)
length: >-
@@ -407,6 +434,8 @@ models:
pika-h3-flex:
basis: vendor
+ draft: {lang: en, first_shot: "[Shot 1] {text}", shot: "[Shot {i}] at {a}: {text}", image_tag: "@Image{n}", video_tag: "@Video{n}"}
+ lint: {language: en, max_chars: 8000}
structure: >-
按播放顺序写:画面和场景 → 谁在哪 → 每个动作以及它怎么结束
language: >-
@@ -445,6 +474,7 @@ models:
hailuo-2.3:
basis: vendor
+ lint: {max_chars: 2000}
structure: 官方没有公式;常用顺序是 景别 / 运镜 → 主体 → 动作 → 场景 / 光线,一段 6 秒只写一个动作节拍
language: 没有说明
length: 2000 字符以内
@@ -466,6 +496,13 @@ models:
wan-3.0:
basis: vendor
+ draft:
+ shot: {zh: "第{i}个镜头[{s0}-{s1}秒]{text}"}
+ image_tag: {zh: "图{n}", en: "Image {n}"}
+ video_tag: {zh: "视频{n}", en: "Video {n}"}
+ negatives_line: false
+ tail: {zh: ["负向清单:字幕、文字、水印"], en: ["Negative list: subtitles, captions, watermarks"]}
+ lint: {max_chars: 20000}
structure: >-
[总体描述] + [参考素材引用:图 N / 视频 N / 音频 N] + [分镜 N(起-止秒):主体 + 场景 + 运动 + 美学控制] + [台词:xx 说:"xxxx"] + [音效 / BGM] + [风格 / 情绪] + [负向清单],写不到的板块直接跳过
language: 中文、英文
@@ -493,6 +530,7 @@ models:
wan-2.7-edit:
basis: vendor
+ lint: {max_chars: 5000}
structure: 编辑指令:说清改什么、改成什么,其余保持不变;一次改一项
language: 中文、英文
length: 5000 字符以内;negative_prompt 500 字符以内
@@ -529,6 +567,8 @@ models:
ltx-2.5:
basis: vendor
+ draft: {lang: en}
+ lint: {language: en}
structure: >-
一整段英文,按时间顺序、现在时:主要动作 → 细节动作 → 外观 → 环境 → 运镜 → 光线 → 变化。不用 "Audio:" "Visual:" 这类标签;景别、运镜、视角写进句子里,不要写成 "medium shot, static camera —" 这样的前缀;不写推测出来的情绪,写看得见的动作
language: 英文;台词保留原语言,原样放在引号里
@@ -606,6 +646,7 @@ models:
runway-gen-4.5:
basis: vendor
+ lint: {max_chars: 1000}
structure: >-
文生视频:"[Camera] shot of [subject] [action] in [environment]. [补充描述]";图生视频:"The camera [运镜] as the subject [动作]. [补充描述]"。不认 JSON 格式
language: 什么语言都收,英文最稳
@@ -637,6 +678,8 @@ models:
luma-ray3.2:
basis: vendor
+ draft: {lang: en}
+ lint: {language: en, max_chars: 6000}
structure: 运镜放最前,再写场景、发生什么、光线和风格;加一个速度词(slowly、smoothly)。动词用进行中的动作(running,不用 begins to run),现在时
language: 英文
length: 100 个词左右(上限 6000 字符)
diff --git a/rea_video/capabilities/schema.json b/rea_video/capabilities/schema.json
index 6954fcd..3c8de9e 100644
--- a/rea_video/capabilities/schema.json
+++ b/rea_video/capabilities/schema.json
@@ -26,6 +26,7 @@
"properties": {"image": {"type": "integer"}, "video": {"type": "integer"}, "audio": {"type": "integer"}, "total": {"type": "integer"}}
},
"ref_video_s": {"$ref": "#/$defs/range", "description": "Total length of the reference videos one request accepts"},
+ "duration_with_refs_s": {"type": "array", "items": {"type": "number"}, "description": "The only lengths a call takes when reference images or videos are sent"},
"keyframes": {"type": "integer"},
"shots_per_generation": {"type": "integer"},
"prompt_tokens": {"type": "integer"},
@@ -67,7 +68,8 @@
"$defs": {
"range": {
"type": "object", "additionalProperties": false,
- "properties": {"min": {"type": "number"}, "max": {"type": "number"}}
+ "properties": {"min": {"type": "number"}, "max": {"type": "number"},
+ "steps": {"type": "array", "items": {"type": "number"}, "description": "The only lengths a call takes, when the model does not take any length in its range"}}
}
}
}
diff --git a/rea_video/generation.py b/rea_video/generation.py
index 68eb053..caa4f2b 100644
--- a/rea_video/generation.py
+++ b/rea_video/generation.py
@@ -29,13 +29,14 @@ import yaml
from .readings import shot_description
from . import performance
from .classify import LABEL_ZH
-from .i18n import T, join, lang, model_name, semi, shot_ids
+from .i18n import T, join, lang, model_name, semi, shot_ids, using
from .plan import framing_words, shot_prompts, with_acting
REF_CLIP_S = 15.0 # one reference video: Seedance / Kling take clips up to about 15 s each
SHORT_UNIT_S = 3.0 # a call this short on its own is unstable and wasteful
CALLS_PER_MIN = 12 # more calls than this per generated minute: the plan is cutting too finely
UNKNOWN_IMAGES = 4 # a model that takes reference images without a stated limit is planned for this many
+REMIX_MIN_REF_S = 5.0 # reference video shorter than this per call is a motion / look reference, too short to carry a stretch of shots
GEN_LABELS = ("ai_video", "cg_3d", "anim_2d")
# generate = all: filmed and clipped shots are generated too (the user swaps people / products and remakes it by model);
@@ -110,6 +111,7 @@ def spec_of(model: dict | None) -> dict:
multi_ref = "video.multi_reference" in prim
plan = m.get("planning") or {}
return {"max": float(d.get("max") or 10), "min": float(d.get("min") or 0),
+ "steps": [float(x) for x in d.get("steps") or []], "steps_with_refs": [float(x) for x in lim.get("duration_with_refs_s") or []],
"multi_shot": "video.multi_shot" in prim, "shots": int(lim.get("shots_per_generation") or 0) or None,
"ref_video": "video.reference_video" in prim, "ref_videos": int(refs.get("video") or 1),
"ref_total": float(rv) if rv else REF_CLIP_S * max(1, int(refs.get("video") or 1)),
@@ -119,13 +121,23 @@ def spec_of(model: dict | None) -> dict:
"exclusive": bool(lim.get("exclusive_inputs")), "native_audio": bool((m.get("audio") or {}).get("native"))}
+def call_seconds(spec: dict, secs: float, refs: bool = False) -> int:
+ """The length one call asks for: the model's allowed lengths when it only takes some (Veo: 4 / 6 / 8 s, 8 s with
+ reference images), else whole seconds within its range; the clip is trimmed to `secs` afterwards."""
+ steps = (spec.get("steps_with_refs") if refs else None) or spec.get("steps") or []
+ if steps:
+ return int(next((x for x in sorted(steps) if x >= secs - 0.05), max(steps)))
+ lo, hi = int(spec.get("min") or 1), int(spec.get("max") or 15)
+ return int(min(hi, max(lo, -(-round(secs, 2) // 1))))
+
+
def planned_images(spec: dict) -> int:
"""Images a plan uses per call: the model's limit, or the narrower default its capability entry sets."""
return min(spec["images"], spec.get("plan_images") or spec["images"])
def choose_strategy(spec: dict, n_own: int) -> str:
- if spec["ref_video"] and spec.get("prefer") in (None, "remix"):
+ if spec["ref_video"] and spec.get("prefer") in (None, "remix") and spec["ref_total"] >= REMIX_MIN_REF_S:
return "remix"
if spec["multi_shot"] and spec["multi_ref"] and planned_images(spec) >= n_own + 2:
return "keyframes"
@@ -224,39 +236,77 @@ def _brief(seg: list[dict], keyframe_tag: dict[int, str]) -> list[dict]:
"duration": round(r["duration"], 3), "label": r["base"]["label"],
"source": shot_description(r),
"action": with_acting(_shot_text(r), act, en=lang() == "en"), "framing": framing_words(r)[0],
+ "action_en": with_acting(shot_prompts(r).get("video_prompt_en") or "", act, en=True), "framing_en": framing_words(r)[1],
"composition": keyframe_tag.get(r["index"]), **({"acting": performance.summary(act)} if act else {})})
acc += r["duration"]
return out
-def _draft(strategy: str, refs: list[dict], brief: list[dict], swaps_txt: list[str], style: str) -> str:
- """A generic prompt from the brief: what to keep, what changes, shot by shot. The final one is written per model."""
- vids = "".join(dict.fromkeys(r["tag"] for r in refs if r["tag"].startswith("@视频")))
- head = []
- if strategy == "remix":
- head.append(T("{v} 是原片:照它的分镜生成,镜头数、每个镜头的时长、景别、机位、运镜、动作和剪辑节奏都跟它一致,只把画面内容换成下面写的",
- "{v} is the source: follow its shots (count, length, size, camera, movement, action and cutting rhythm) and change only what is written below", v=vids))
- elif strategy == "keyframes":
- head.append(T("按下面的镜头顺序一次生成,镜头之间硬切;每个镜头的构图、景别和机位参考对应的原片画面图",
- "Generate the shots below in order in one go, hard cuts between them; each shot takes composition, size and camera from its source frame image"))
- head += swaps_txt
- if style:
- head.append(style)
- head.append(T("画面里不要出现字幕、文字和水印", "No subtitles, captions or watermarks in the picture"))
- lines = []
- for i, x in enumerate(brief, 1):
- text = x["action"] or T("(缺镜头描述:先看图复核补写)", "(no description: write one in the image review)")
- if strategy == "keyframes" and not x.get("composition") and x.get("framing"):
- text = x["framing"] + T("。", ". ") + text
- if x.get("composition"):
- text += T("(构图参考 {k})", " (composition: {k})", k=x["composition"])
- if len(brief) == 1:
- lines.append(text)
- elif strategy == "remix":
- lines.append(T("镜头{i}:{t}", "Shot {i}: {t}", i=i, t=text))
- else:
- lines.append(T("镜头{i}(从 {a:.1f} 秒起):{t}", "Shot {i} (from {a:.1f}s): {t}", i=i, a=x["at"], t=text))
- return T("。", ". ").join(h.rstrip("。.") for h in head) + T("。\n", ".\n") + "\n".join(lines)
+REF_TAG = re.compile(r"@(图片|视频)(\d+)")
+
+
+def _swap_line(sw: dict) -> str:
+ # the words describe what the shot shows, not an edit: Seedance-style models read 换成 / 替换 / 改成 as an edit task
+ f = sw.get("from") or T("主体", "subject")
+ t = sw.get("to") or sw.get("tag") or T("用户给的主体", "the user's subject")
+ return (T("原片里{f}的位置,这次是{t}", "where the source has {f}, this video has {t}", f=f, t=t)
+ + (T("(参考 {k})", " (see {k})", k=sw["tag"]) if sw.get("tag") else ""))
+
+
+def _draft(strategy: str, refs: list[dict], brief: list[dict], swaps: list[dict], style, fmt: dict | None = None) -> str:
+ """A prompt from the brief: what to keep, what changes, shot by shot. `fmt` (the model's `draft` block in
+ prompting.yaml) sets the prompt language, the shot lines, how images / videos are named and the fixed fields, so the
+ draft is already in the model's own shape; the agent still checks it against the model's notes."""
+ raw = fmt or {}
+ dl = raw.get("lang") or lang()
+ with using(dl):
+ # any field may be split by language ({zh: …, en: …}); a field missing for this language falls back to the generic shape
+ fmt = {k: (v.get(lang()) if isinstance(v, dict) else v) for k, v in raw.items()}
+ en = lang() == "en"
+ vids = T("、", ", ").join(dict.fromkeys(r["tag"] for r in refs if r["tag"].startswith("@视频")))
+ head = []
+ if strategy == "remix":
+ head.append(T("{v} 是原片:照它的分镜生成,镜头数、每个镜头的时长、景别、机位、运镜、动作和剪辑节奏都跟它一致,画面内容照下面写",
+ "{v} is the source: follow its shots (count, length, size, camera, movement, action and cutting rhythm); the picture is as written below", v=vids))
+ elif strategy == "keyframes":
+ head.append(T("按下面的镜头顺序一次生成,镜头之间硬切;每个镜头的构图、景别和机位参考对应的原片画面图",
+ "Generate the shots below in order in one go, hard cuts between them; each shot takes composition, size and camera from its source frame image"))
+ head += [_swap_line(sw) for sw in swaps]
+ st = style.get(lang(), "") if isinstance(style, dict) else style
+ if st:
+ head.append(st)
+ if fmt.get("negatives_line", True):
+ head.append(T("画面里不要出现字幕、文字和水印", "No subtitles, captions or watermarks in the picture"))
+ lines = []
+ for i, x in enumerate(brief, 1):
+ text = (x.get("action_en") if en and x.get("action_en") else x["action"]) \
+ or T("(缺镜头描述:先看图复核补写)", "(no description: write one in the image review)")
+ framing = x.get("framing_en") if en else x.get("framing")
+ if strategy == "keyframes" and not x.get("composition") and framing:
+ text = framing + T("。", ". ") + text
+ if x.get("composition"):
+ text += T("(构图参考 {k})", " (composition: {k})", k=x["composition"])
+ a, z = x["at"], x["at"] + x["duration"]
+ keys = {"i": i, "text": text, "a": _mmss(a), "z": _mmss(z), "at": _mmss(a, ms=True),
+ "s0": int(round(a)), "s1": max(int(round(z)), int(round(a)) + 1), "d": max(1, int(round(x["duration"])))}
+ if fmt.get("shot"):
+ lines.append((fmt.get("first_shot") if i == 1 and fmt.get("first_shot") else fmt["shot"]).format(**keys))
+ elif len(brief) == 1:
+ lines.append(text)
+ elif strategy == "remix":
+ lines.append(T("镜头{i}:{t}", "Shot {i}: {t}", i=i, t=text))
+ else:
+ lines.append(T("镜头{i}(从 {a:.1f} 秒起):{t}", "Shot {i} (from {a:.1f}s): {t}", i=i, a=a, t=text))
+ sep = T("。", ". ")
+ out = fmt.get("head", "") + sep.join(h.rstrip("。.") for h in head) + sep.rstrip() + "\n" + "\n".join(lines)
+ if fmt.get("tail"):
+ out += "\n" + "\n".join(fmt["tail"])
+ tags = {"图片": fmt.get("image_tag"), "视频": fmt.get("video_tag")}
+ return REF_TAG.sub(lambda m: tags[m.group(1)].format(n=m.group(2)) if tags[m.group(1)] else m.group(0), out)
+
+
+def _mmss(t: float, ms: bool = False) -> str:
+ return f"{int(t // 60):02d}:{t % 60:06.3f}" if ms else f"{int(t // 60):02d}:{int(round(t)) % 60:02d}"
def _inputs(strategy: str, refs: list[dict], seg: list[dict], spec: dict) -> list[dict]:
@@ -287,8 +337,8 @@ def _inputs(strategy: str, refs: list[dict], seg: list[dict], spec: dict) -> lis
return out
-def build_unit(seg: list[dict], k: int, strategy: str, spec: dict, own: list[dict], swaps_txt: list[str], style: str,
- model: dict | None) -> dict:
+def build_unit(seg: list[dict], k: int, strategy: str, spec: dict, own: list[dict], swaps: list[dict], style,
+ model: dict | None, fmt: dict | None = None) -> dict:
t0, t1 = seg[0]["start"], seg[-1]["end"]
dur = round(sum(r["duration"] for r in seg), 3)
ranges = _ranges(seg)
@@ -299,8 +349,7 @@ def build_unit(seg: list[dict], k: int, strategy: str, spec: dict, own: list[dic
parts = int(-(-dur // spec["max"])) if len(seg) == 1 and dur > spec["max"] + 1e-6 else 1
refs = [dict(r) for r in own] if strategy != "frames" or not spec["exclusive"] else []
kept_tags = {r["tag"] for r in refs}
- unit_swaps = [re.sub(r"(参考 @图片\d+)| \(see @图片\d+\)", "", t) if not any(k in t for k in kept_tags) else t
- for t in swaps_txt]
+ unit_swaps = [sw if sw.get("tag") in kept_tags else {**sw, "tag": None} for sw in swaps]
keyframe_tag: dict[int, str] = {}
if strategy == "remix":
each = min(REF_CLIP_S, spec["ref_total"])
@@ -324,11 +373,12 @@ def build_unit(seg: list[dict], k: int, strategy: str, spec: dict, own: list[dic
refs.append({"tag": tag, "keyframe": r["index"], "t": round(r["start"] + min(0.3, r["duration"] / 2), 3),
"what": T("原片镜头 #{i} 的画面(擦掉字幕):只参考构图、景别和机位", "source shot #{i} (subtitles erased): composition, size and camera only", i=r["index"])})
brief = _brief(seg, keyframe_tag)
+ call_s = call_seconds(spec, dur / parts, refs=bool(refs))
unit = {"id": f"G{k}", "kind": "generate", "strategy": strategy, "label": label, "label_zh": LABEL_ZH[label],
"shots": [r["index"] for r in seg], "start": round(t0, 3), "end": round(t1, 3), "duration": dur, "ranges": ranges,
"mode": "multi_shot" if len(seg) > 1 else ("split" if parts > 1 else "single"), "calls": parts,
- "generate_s": round(dur / parts, 3), "model": (model or {}).get("id"), "model_name": model_name((model or {}).get("name")),
- "refs": refs, "brief": brief, "draft": _draft(strategy, refs, brief, unit_swaps, style),
+ "generate_s": round(dur / parts, 3), "call_s": call_s, "model": (model or {}).get("id"), "model_name": model_name((model or {}).get("name")),
+ "refs": refs, "brief": brief, "draft": _draft(strategy, refs, brief, unit_swaps, style, fmt), "draft_format": bool(fmt),
"inputs": _inputs(strategy, refs, seg, spec)}
unframed = [x["shot"] for x in brief if strategy == "keyframes" and not x.get("composition")]
missing = [x["shot"] for x in brief if not x["action"]]
@@ -361,13 +411,14 @@ def part_starts(b: dict) -> set[int]:
return out
-def plan_generation(b: dict, model: dict | None, intent: dict, new_scene: set[int], style: str, skip: set[int]) -> dict:
+def plan_generation(b: dict, model: dict | None, intent: dict, new_scene: set[int], style, skip: set[int],
+ notes: dict | None = None) -> dict:
"""Generation units and the facts they were planned on. `skip`: shots made another way (motion drive, a clip
reused from another unit)."""
spec = spec_of(model)
labels = ALL_GEN_LABELS if intent.get("generate") == "all" else GEN_LABELS
own = []
- swaps_txt = []
+ swaps = []
for s in intent.get("swaps") or []:
tag = None
if s.get("image"):
@@ -375,8 +426,7 @@ def plan_generation(b: dict, model: dict | None, intent: dict, new_scene: set[in
own.append({"tag": tag, "user": True, "path": s["image"],
"what": (s["to"] or T("用户给的参考图", "the user's reference image")) + (T("(替换原片的{f})", " (replaces the source's {f})", f=s["from"]) if s["from"] else "")})
if s["from"] or s["to"]:
- swaps_txt.append(T("原片的{f}换成{t}", "the source's {f} becomes {t}", f=s["from"] or T("主体", "subject"), t=s["to"] or tag)
- + (T("(参考 {k})", " (see {k})", k=tag) if tag else ""))
+ swaps.append({"from": s["from"], "to": s["to"], "tag": tag})
strategy = choose_strategy(spec, len(own))
if strategy == "remix":
max_s, max_shots = min(spec["max"], spec["ref_total"]), spec["shots"]
@@ -393,7 +443,7 @@ def plan_generation(b: dict, model: dict | None, intent: dict, new_scene: set[in
new_part = part_starts(b)
for run in runs(b["shots"], labels, skip, joinable_inserts=strategy in ("remix", "keyframes", "text")):
for seg in pack(run, max_s, max_shots, new_scene, new_part):
- units.append(build_unit(seg, len(units) + 1, strategy, spec, own, swaps_txt, style, model))
+ units.append(build_unit(seg, len(units) + 1, strategy, spec, own, swaps, style, model, (notes or {}).get("draft")))
return {"strategy": strategy, "spec": spec, "labels": list(labels), "units": units, "own_refs": own,
"rules": {"max_s": max_s, "max_shots": max_shots, "generate": intent.get("generate", "ai")}}
@@ -404,10 +454,16 @@ VIDEO_TAG_RES = (r"@视频(\d+)", r"<Video (\d+)>", r"\bVideo (\d+)\b")
def lint_prompt(text: str, n_images: int, n_videos: int, notes: dict | None) -> list[str]:
- """What breaks the model's own format: image / video numbers past what is sent, length, required and forbidden
- parts (from the model's `lint` notes in the capability map)."""
+ """The errors of `lint`."""
+ return [m for lv, m in lint(text, n_images, n_videos, notes) if lv == "error"]
+
+
+def lint(text: str, n_images: int, n_videos: int, notes: dict | None) -> list[tuple[str, str]]:
+ """What breaks the model's own format, as (level, message): image / video numbers past what is sent, length,
+ required and forbidden parts (from the model's `lint` notes in the capability map). A forbid rule may carry
+ `when: refs` (only when reference images or videos are sent) and `level: warn` (a risk, not a format error)."""
rules = (notes or {}).get("lint") or {}
- errs = []
+ errs: list = []
imgs = [int(x) for p in TAG_RES for x in re.findall(p, text)]
vids = [int(x) for p in VIDEO_TAG_RES for x in re.findall(p, text)]
if imgs and max(imgs) > n_images:
@@ -422,15 +478,20 @@ def lint_prompt(text: str, n_images: int, n_videos: int, notes: dict | None) ->
for need in rules.get("require") or []:
if need not in text:
errs.append(T("缺少「{x}」", "missing “{x}”", x=need))
+ warns = []
for f in rules.get("forbid") or []:
- if isinstance(f, dict) and f.get("re") and re.search(f["re"], text):
- errs.append(str(f.get("why") or f["re"]))
+ if not isinstance(f, dict) or not f.get("re") or (f.get("when") == "refs" and not (n_images or n_videos)):
+ continue
+ hit = re.search(f["re"], text)
+ if hit:
+ msg = str(f.get("why") or f["re"]) + T("(「{w}」)", " (“{w}”)", w=hit.group(0))
+ (warns if f.get("level") == "warn" else errs).append(msg)
if rules.get("language") == "en":
body = re.sub(r"<d>.*?</d>|\"[^\"]*\"", "", text, flags=re.S) # dialogue and on-screen text keep their own language
cjk = len(re.findall(r"[㐀-鿿]", body))
if cjk > 0.05 * max(1, len(body)):
errs.append(T("这个模型的提示词要用英文(台词和画面文字除外)", "this model's prompts should be in English (dialogue and on-screen text aside)"))
- return errs
+ return [("error", e) for e in errs] + [("warn", w) for w in warns]
SHOT_RES = (r"\[Shot (\d+)\]", r"镜头\s*(\d+)", r"\bShot (\d+)\b")
@@ -512,11 +573,15 @@ def checks(plan: dict, intent: dict, prompts: dict[str, str], notes: dict | None
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",
- u=u["id"], m=u.get("model_name") or u.get("model") or "?"), u["id"])
- else:
- for e in lint_prompt(final, n_img, n_vid, notes):
- add("error", f"{u['id']}: {e}", u["id"])
+ m = u.get("model_name") or u.get("model") or "?"
+ add("warn", T("{u} 还是工具草稿(已按 {m} 的格式排好):对照它的写法核对、改好后放进 remake/prompts.json",
+ "{u} still has the tool's draft (already in {m}'s layout): check it against the model's notes and put the final into remake/prompts.json", u=u["id"], m=m)
+ if u.get("draft_format") else
+ T("{u} 还是通用草稿:按 {m} 的写法写好最终提示词,放进 remake/prompts.json", "{u} still has the generic draft: write the final prompt in {m}'s format into remake/prompts.json", u=u["id"], m=m), u["id"])
+ for lv, e in lint(final or u.get("draft") or "", n_img, n_vid, notes):
+ if final or lv == "warn": # a draft is the tool's own wording: only its risks are worth a line
+ add(lv, f"{u['id']}: {e}", u["id"])
+ if final:
n = shots_written(final)
if n and len(u["shots"]) > 1 and n != len(u["shots"]): # written for another split of the shots
add("error", T("{u} 的最终提示词写了 {n} 个镜头,单元里有 {m} 个:按现在的单元重写", "{u}'s final prompt numbers {n} shots but the unit has {m}: rewrite it for the current unit",
@@ -557,8 +622,10 @@ def report_md(plan: dict, prompts: dict[str, str]) -> list[str]:
st = plan.get("strategy")
how = {"remix": T("这段原片擦掉字幕后当参考视频,模型照它的分镜、运镜和节奏出完这段的镜头",
"the source stretch, subtitles erased, is the reference video; the model follows its shots, camera and pacing"),
- "keyframes": T("这个模型不吃参考视频,每个镜头给一张擦掉字幕的原片画面定构图,换进去的东西各给参考图",
- "the model takes no reference video: one source frame per shot (subtitles erased) fixes composition, swapped-in things get their own images"),
+ "keyframes": (T("这个模型也能吃参考视频,这里按它的默认排法:", "the model also takes reference video, but its default plan is used here: ")
+ if spec.get("ref_video") else T("这个模型不吃参考视频,", "the model takes no reference video: "))
+ + T("每个镜头给一张擦掉字幕的原片画面定构图,换进去的东西各给参考图",
+ "one source frame per shot (subtitles erased) fixes composition, swapped-in things get their own images"),
"frames": T("一次只出一个镜头,从原片首帧(和尾帧)起步", "one shot per call, from the source's first (and last) frame"),
"text": T("只有文字提示词", "prompt only")}[st]
notes_md = [T("- 分组:连着的镜头尽量放进同一次生成,单次 ≤{s:.0f} 秒", "- Grouping: consecutive shots share a call where they fit, ≤{s:.0f}s per call", s=rules.get("max_s") or 0)
@@ -570,11 +637,11 @@ def report_md(plan: dict, prompts: dict[str, str]) -> list[str]:
if plan.get("overlay_note"):
notes_md.append(T("- 包装层:{a}", "- Packaging: {a}", a=plan["overlay_note"]))
L = [T("| 段 | 镜头 | 时间 | 时长 | 要准备 |", "| Part | Shots | Time | Length | Prepare |"), "|---|---|---|---|---|"]
- shortest = float(spec.get("min") or 0)
for u in units:
when = join(f"{a:.1f}–{z:.1f}s" for a, z in u["ranges"])
- length = (T("生成 {m:.0f}s,剪到 {d:.1f}s", "generate {m:.0f}s, trim to {d:.1f}s", m=shortest, d=u["duration"])
- if u["generate_s"] < shortest else f"{u['duration']:.1f}s")
+ call = u.get("call_s") or u["generate_s"]
+ length = (T("生成 {m:.0f}s,剪到 {d:.1f}s", "generate {m:.0f}s, trim to {d:.1f}s", m=call, d=u["generate_s"])
+ if call - u["generate_s"] >= 0.5 else f"{u['duration']:.1f}s")
L.append(f"| {u['id']} | {shot_ids(u['shots'])} | {when} | {length}"
f"{T('({c} 次)', ' ({c} calls)', c=u['calls']) if u['calls'] > 1 else ''} | {_fed(u) or '—'} |")
L += ["", '<details class="ref"><summary>' + T("这样分段的原因", "Why it is split this way") + "</summary>", ""] + notes_md + ["", "</details>"]
@@ -591,6 +658,8 @@ def report_md(plan: dict, prompts: dict[str, str]) -> list[str]:
s=a["shot"], k=T("(看点)", " (key)") if a["key"] else "", l=a["line"], h=a["how"]))
final = prompts.get(u["id"])
L += ["", T("提示词:", "Prompt:") if final
+ else T("提示词草稿(已按 {m} 的格式排好,生成前核对后写进 remake/prompts.json):", "Draft prompt (in {m}'s layout; check it and put the final into remake/prompts.json before generating):",
+ m=u.get("model_name") or u.get("model")) if u.get("draft_format")
else T("提示词草稿(通用写法,生成前按 {m} 的写法改写进 remake/prompts.json):", "Draft prompt (generic; rewrite it in {m}'s format into remake/prompts.json before generating):",
m=u.get("model_name") or u.get("model")),
"", "```text", final or u["draft"], "```", "", "</details>"]
diff --git a/rea_video/i18n.py b/rea_video/i18n.py
index d828cfe..4a0daf4 100644
--- a/rea_video/i18n.py
+++ b/rea_video/i18n.py
@@ -11,6 +11,7 @@ The language is set once per run (`set_lang`), from `--lang` / prefs, and stored
"""
from __future__ import annotations
+import contextlib
import contextvars
import re
from collections.abc import Mapping
@@ -44,6 +45,16 @@ def lang() -> str:
return _lang.get()
+def using(lang: str | None) -> Iterator[None]:
+ """Render a block in another language (a prompt for a model that wants English inside a Chinese report)."""
+ tok = _lang.set(_norm_lang(lang) or _lang.get())
+ try:
+ yield
+ finally:
+ _lang.reset(tok)
+
+
def T(zh: str, en: str | None = None, **kw) -> str:
"""Text for the current language; `en` missing falls back to zh. kwargs are applied with str.format."""
s = en if (en is not None and _lang.get() == "en") else zh
diff --git a/rea_video/integrations/capsule_cinema.py b/rea_video/integrations/capsule_cinema.py
index 1421b8a..2281cc0 100644
--- a/rea_video/integrations/capsule_cinema.py
+++ b/rea_video/integrations/capsule_cinema.py
@@ -321,7 +321,7 @@ def _unit_jobs(b: dict, bdir: Path, run_dir: Path, plan: dict, prompts: dict[str
gtype = GEN_TYPE[u["strategy"]]
params = {"prompt": prompt, "output_dir": str(run_dir / (u["id"] if len(parts) == 1 else f"{u['id']}-{part}")),
"generation_type": gtype, "engine": eng, "aspect_ratio": b["source"].get("aspect_ratio") or "9:16",
- "duration": int(min(hi, max(lo, round(secs + 0.49))))}
+ "duration": int(u.get("call_s") or min(hi, max(lo, round(secs + 0.49))))}
if vids:
params["video_paths"] = vids
if images:
diff --git a/rea_video/production.py b/rea_video/production.py
index 9128b18..3d9906c 100644
--- a/rea_video/production.py
+++ b/rea_video/production.py
@@ -233,6 +233,21 @@ def reused_footage(gen: list[dict]) -> dict[int, int]:
return out
+def _light_word(r: dict, key: str) -> str | None:
+ """One lighting reading in the current language: the stored words are in the language the video was broken down
+ in, so an English prompt inside a Chinese report reads them again from the measurements."""
+ from .aspects import lighting
+
+ li = (r.get("aspects") or {}).get("lighting") or {}
+ v = (li.get("result") or {}).get(key)
+ if not v or lang() != "en" or not re.search(r"[㐀-鿿]", v):
+ return v
+ if key == "setup_name":
+ row = next((s for s in lighting.SETUPS if s["key"] == (li.get("result") or {}).get("setup")), None)
+ return (row or {}).get("name_en")
+ return lighting.words(li.get("measured") or {}).get(key)
+
+
def _style_line(shots: list[dict], aspect_ratio: str) -> str:
"""One style sentence for every unit (most common lighting reading across the generated shots, by duration),
so separately generated units still look like one video."""
@@ -243,11 +258,17 @@ def _style_line(shots: list[dict], aspect_ratio: str) -> str:
for key in ("setup_name", "quality", "color_temp", "depth"):
votes: dict[str, float] = {}
for r in shots:
- v = (((r.get("aspects") or {}).get("lighting") or {}).get("result") or {}).get(key)
+ v = _light_word(r, key)
if v:
votes[v] = votes.get(v, 0.0) + r["duration"]
if votes:
- picks.append(max(votes.items(), key=lambda kv: kv[1])[0])
+ # the bracketed explanations are for people reading the report, not for the model
+ v = re.sub(r"\s*[((][^))]*[))]", "", max(votes.items(), key=lambda kv: kv[1])[0]).strip()
+ if key == "color_temp" and re.fullmatch(r"[a-z]+", v):
+ v += " tones" # "cool" alone is vague in an English prompt
+ words = set(re.findall(r"[a-z]+", v.lower()))
+ if v and not any(v in p or (words and words <= set(re.findall(r"[a-z]+", p.lower()))) for p in picks):
+ picks.append(v)
if picks:
bits.append(T(",", ", ").join(picks))
return semi().join(bits)
@@ -349,12 +370,18 @@ def production_plan(b: dict, out: Path, engine: str = "minimax-h3") -> dict:
new_scene = {r["index"] for r in shots if not same_prev.get(r["index"], False)}
eng, model = pick_model(planner, intent.get("model") or engine)
gen = [r for r in shots if r["base"]["label"] in gen_labels]
- style = _style_line(gen, b["source"].get("aspect_ratio", "")) if gen else ""
+ from .i18n import using
+
+ style = {} # the prompt drafts are in the model's prompt language, which may differ from the report's
+ for lg in ("zh", "en"):
+ with using(lg):
+ style[lg] = _style_line(gen, b["source"].get("aspect_ratio", "")) if gen else ""
reused = reused_footage(gen)
from . import dance
motion = dance.motion_indices(b) # the moves are the point: driven from the source motion, not generated from frames
- g = gen_mod.plan_generation(b, model, intent, new_scene, style, set(reused) | motion)
+ g = gen_mod.plan_generation(b, model, intent, new_scene, style, set(reused) | motion,
+ notes=planner.prompting.get((model or {}).get("id")))
units = g["units"]
for again, src in sorted(reused.items()):
u = next((u for u in units if src in u["shots"]), None)
diff --git a/rea_video/report.py b/rea_video/report.py
index afe44d8..a06aa70 100644
--- a/rea_video/report.py
+++ b/rea_video/report.py
@@ -499,11 +499,17 @@ def _plan_md(b: dict) -> list[str]:
pre = ["", f'<details class="ref"><summary>{_pre_summary}</summary>', ""] + pre + ["", "</details>", ""]
m = plan.get("model_name") or T("视频模型", "the video model")
drafts = [u["id"] for u in plan.get("units") or [] if u["id"] not in (plan.get("prompts") or {})]
- tip = (T("> ⚠️ {u} 的提示词还是通用草稿。生成前按 {m} 的官方写法改好(或让 agent 用这个模型的提示词 skill 写),放进 `remake/prompts.json`,"
- "图片编号按单元里「参考图」的顺序;写好后 `rea-video plan` 会检查格式。",
- "> ⚠️ {u}: the prompts are still generic drafts. Rewrite them in {m}'s official format (or have the agent write them with that model's "
- "prompting skill) into `remake/prompts.json`, numbering images in the unit's reference order; `rea-video plan` then checks the format.",
- u="、".join(drafts), m=m) if drafts else "")
+ shaped = drafts and all(u.get("draft_format") for u in plan["units"] if u["id"] in drafts)
+ tip = ((T("> ⚠️ {u} 的提示词是工具草稿,已按 {m} 的格式排好。生成前对照它的写法和同类优质提示词核对、改好,放进 `remake/prompts.json`;"
+ "写好后 `rea-video plan` 会检查格式。",
+ "> ⚠️ {u}: the prompts are the tool's drafts, already in {m}'s layout. Check them against the model's conventions and good "
+ "prompts for similar shots, then put the finals into `remake/prompts.json`; `rea-video plan` then checks the format.",
+ u="、".join(drafts), m=m) if shaped else
+ T("> ⚠️ {u} 的提示词还是通用草稿。生成前按 {m} 的官方写法改好(或让 agent 用这个模型的提示词 skill 写),放进 `remake/prompts.json`,"
+ "图片编号按单元里「参考图」的顺序;写好后 `rea-video plan` 会检查格式。",
+ "> ⚠️ {u}: the prompts are still generic drafts. Rewrite them in {m}'s official format (or have the agent write them with that model's "
+ "prompting skill) into `remake/prompts.json`, numbering images in the unit's reference order; `rea-video plan` then checks the format.",
+ u="、".join(drafts), m=m)) if drafts else "")
n_calls = plan.get("calls") or len(plan["units"])
sub(T("AI 生成", "AI generation"), [T("**分 {c} 次生成,共 {s:.0f} 秒**", "**{c} generation{p}, {s:.0f} s in total**", c=n_calls, p="" if n_calls == 1 else "s",
s=sum(float(u.get("duration") or 0) for u in plan["units"])), ""] + ([tip, ""] if tip else []) + parts["units"] + pre)
diff --git a/scripts/validate_capabilities.py b/scripts/validate_capabilities.py
index 238cc4e..a95797d 100644
--- a/scripts/validate_capabilities.py
+++ b/scripts/validate_capabilities.py
@@ -153,10 +153,23 @@ def main() -> int:
continue
if k == "lint": # machine-checked format rules for final prompts (rea_video/generation.py lint_prompt)
ok = isinstance(x, dict) and set(x) <= {"language", "max_chars", "max_cjk", "require", "forbid"} and all(
- isinstance(f, dict) and f.get("re") and f.get("why") for f in x.get("forbid") or [])
+ isinstance(f, dict) and f.get("re") and f.get("why") and set(f) <= {"re", "why", "when", "level"}
+ and f.get("when") in (None, "refs") and f.get("level") in (None, "error", "warn") for f in x.get("forbid") or [])
if not ok:
errors.append(f"prompting.yaml:{mid}: lint 格式不对")
continue
+ if k == "draft": # the layout of the tool's prompt draft for this model (rea_video/generation.py _draft)
+ keys = {"lang", "head", "shot", "first_shot", "image_tag", "video_tag", "negatives_line", "tail"}
+ ok = isinstance(x, dict) and set(x) <= keys and x.get("lang") in (None, "zh", "en")
+ for f in ("shot", "first_shot"):
+ for v in ((x or {}).get(f).values() if isinstance((x or {}).get(f), dict) else [(x or {}).get(f)]):
+ try:
+ v and v.format(i=1, text="", a="", z="", at="", s0=0, s1=1, d=1)
+ except (KeyError, IndexError, ValueError):
+ ok = False
+ if not ok:
+ errors.append(f"prompting.yaml:{mid}: draft 格式不对")
+ continue
if k in text_keys and not isinstance(x, str) or k in list_keys and not (isinstance(x, list) and all(isinstance(i, str) for i in x)):
errors.append(f"prompting.yaml:{mid}: 字段 {k} 类型不对")
elif k not in text_keys | list_keys:
diff --git a/skills/rea-video/SKILL.md b/skills/rea-video/SKILL.md
index 23d65f4..2c1f92b 100644
--- a/skills/rea-video/SKILL.md
+++ b/skills/rea-video/SKILL.md
@@ -121,7 +121,7 @@ rea-video summary out/ref/breakdown.json # 用并入后的结果写回复
```
2. 方案按这个模型的最新实际情况来:`rea-video models <id>` 看能力地图里的资料和核实日期,再上网核对它最新的官方文档和更新(有没有新版本,单次时长、参考视频 / 参考图的数量和时长、一次多镜头、首尾帧、原生音频、提示词写法有没有变)。能力地图里没有、或和最新资料不一致的,按能力地图的格式写进 `~/.rea-video/capabilities/models/<id>.yaml`(同 id 会覆盖自带的),写上来源和核实日期。
3. `rea-video plan out/ref`:按意图和模型出报告第二部分,并做方案检查。工具按模型能吃什么选输入方式(参考原片视频 / 每镜一张原片关键帧 / 首尾帧 / 纯文字),在单次时长和参考数量以内用最少的调用装下所有镜头,原片参考擦掉字幕后放在 `remake/refs/`。
-4. 写之前上网搜这个模型的提示词写法和同类镜头的优质提示词:先看口碑好的创作者的实测教程和作品提示词,再看官方文档和示例,参考结构和写法,不照抄内容;和能力地图不一致的按第 2 步记下来。再按这个模型的提示词写法(`rea-video models <id>`,或这个模型的提示词 skill)把每个单元的草稿写成最终提示词,放进 `out/ref/remake/prompts.json`(`{"G1": "..."}`,图片编号按单元里参考图的顺序),再跑一次 `rea-video plan`,直到方案检查没有 ❌。
+4. 写之前上网搜这个模型的提示词写法和同类镜头的优质提示词:先看口碑好的创作者的实测(X、YouTube、B站、小红书等),再看官方文档和示例;平台的教程页(CapCut、fal 这类)只当二手资料。参考结构和写法,不照抄内容;和能力地图不一致的按第 2 步记下来。报告里的草稿大多已按这个模型的格式排好,再按它的写法(`rea-video models <id>`,或这个模型的提示词 skill)核对改好,写成最终提示词,放进 `out/ref/remake/prompts.json`(`{"G1": "..."}`,图片编号按单元里参考图的顺序),再跑一次 `rea-video plan`,直到方案检查没有 ❌。
5. 把方案给用户看(调用次数、每次喂什么、检查结果),用户同意后再生成。
用户要自己动手做时,先给报告第二部分「照着做」的步骤,不要先讲模型规则和输入表。
diff --git a/skills/rea-video/references/remake.md b/skills/rea-video/references/remake.md
index d4c1928..93fcc0c 100644
--- a/skills/rea-video/references/remake.md
+++ b/skills/rea-video/references/remake.md
@@ -13,7 +13,7 @@
## 用哪个模型
- 模型、整条重做还是只做 AI 镜头、换什么,都写在 `remake/intent.yaml`(见 SKILL.md「复刻」),`rea-video plan out/ref` 按它出方案。用户没说用哪个模型时,先按默认模型(MiniMax H3,或 `prefs engine` 记住的模型)出方案并在回复里说明,不要先停下来追问;用户想换模型再跑 `rea-video plan out/ref --model <id>`。
-- 报告里每个单元的提示词是草稿。按 `rea-video models <id>` 打印的写法写成最终版放进 `remake/prompts.json`:时间和镜头怎么分、参考素材怎么指代、台词和不想要的内容怎么写;首帧 / 首尾帧模式下只留运动和运镜。`rea-video plan` 会按这个模型的格式规则检查。
+- 报告里每个单元的提示词是草稿,有格式模板的模型已按它的镜头写法、语言和素材编号排好。按 `rea-video models <id>` 打印的写法核对,写成最终版放进 `remake/prompts.json`:时间和镜头怎么分、参考素材怎么指代、台词和不想要的内容怎么写;首帧 / 首尾帧模式下只留运动和运镜。`rea-video plan` 会按这个模型的格式规则检查。
- 选帧、擦字、首尾帧怎么配:`rea-video models keyframes`。
## 各类镜头怎么复刻