Reverse-engineer any video, shot by shot: filmed, AI-generated or coded, and how to remake it. Breakdowns in the open VIDEO.md format. 逆向一切视频,逐个镜头看是拍的、AI 生成的还是代码做的,再告诉你怎么复刻;拆解结果按 VIDEO.md 格式输出。
Python agent-skillsai-videoaigc-detectionclaude-codecodexffmpegprompt-engineeringremotionreverse-engineeringshort-videoshot-detectionsubtitlesvideo-analysisvideo-breakdownvideo-editingvideo-generationvideomdvlm
Motion drive for dance and action shots
june5c734049767c
diff --git a/docs/cli.md b/docs/cli.mdindex e91c7ca..78d8f78 100644--- a/docs/cli.md+++ b/docs/cli.md@@ -106,6 +106,8 @@ rea-video capsule-draft out/ref/breakdown.json --capsule-root $CC --capsule-name| `tiles VIDEO --start --end --every` | 按时间抽帧拼图,近距离复核 || `frames OUT_DIR [--every 0.25] [--points 4000] [--all]` | 代码渲染镜头按场景切分(画上去的东西整体换了位置或形状就算新场景),写出 `frames/`:每场景首 / 中 / 尾原尺寸帧、`scene_XX_layer.png`(画上去那一层的抠图,背景和文字已去掉)、`points/scene_XX.json`(这一层的采样点)、`scenes.json`(底色、背景光、前景颜色、块数、范围、重心随时间的轨迹);深底浅底都适用;decompose 遇到代码渲染镜头会自动跑 || `compare REF REMAKE [--scenes frames/scenes.json] [-o DIR]` | 逐帧比较复刻和原片画上去的那一层:落在哪、形状重合度、多少;两边各按自己的底色取前景,换了底色也能直接比;并给出要改什么(整体早晚几秒、偏左偏右、铺开范围、多少、前景颜色和底色差多少),整段、每个场景、最差的几帧各一份;`-o` 写出 `compare.json` 和最差时刻的左右对比图 `compare_worst.jpg` |+| `drive OUT_DIR [--shots 3-7] [--depth] [--no-clean] [--prefer 10] [--max 15]` | 舞蹈 / 动作镜头的驱动视频:擦掉后期字幕和贴纸,在动作停顿、靠近拍点处切段,写出 `drive/seg_XX.mp4`(无声)、`seg_XX_first.jpg`(角色图按它对齐景别和朝向)、`seg_XX_music.wav`、`segments.jpg` 和带各路线提示词的 `README.md`;默认用复刻方案里的「动作驱动」单元(看图复核时 `performance.move` 标出的镜头);`--depth` 同时出深度视频(需要 transformers + torch) |+| `drive OUT_DIR --join [RESULTS]` | 把生成好的段(默认 `drive/results.json`:`{"seg_01": 路径}`)按段长对齐、拼起来、按镜头切开,写进 `remake/mine.json`,再跑 `remake` 出对比片 || `eval labels.yaml` | 在带标注的样本上评测准确率和切点 F1 || `capsule breakdown.json` | 导出 capsule-cinema 的视频分析 JSON || `models [ID] [--plan OUT_DIR]` | 列出能力地图里的生成模型;带 id 时打印这个模型的提示词写法和关键帧要求(`models keyframes` 是关键帧通用做法);`--plan` 把已有拆解的复刻方案改按该模型重出 |diff --git a/docs/replicate.md b/docs/replicate.mdindex 8ff85e4..66daefd 100644--- a/docs/replicate.md+++ b/docs/replicate.md@@ -1,6 +1,6 @@# 照着报告复刻-报告「自己复刻」一节开头先说这条视频属于哪一类(人物口播、桌拍 / 开箱、vlog、实拍剧情、AI 剧情短片、AI 商品广告、AI 音乐 MV、数字人口播、AI 短片段、3D / 动画、影视解说 / 混剪、动效科普、录屏教程、图片推拉成片、卡点混剪),再按这类视频的制作顺序列出步骤。类型只决定有哪几步、先后怎么排,每一步的内容都来自这条原片:+报告「自己复刻」一节开头先说这条视频属于哪一类(人物口播、桌拍 / 开箱、vlog、实拍剧情、AI 剧情短片、AI 商品广告、AI 音乐 MV、数字人口播、AI 短片段、3D / 动画、影视解说 / 混剪、动效科普、录屏教程、图片推拉成片、卡点混剪、舞蹈 / 动作表演),再按这类视频的制作顺序列出步骤。类型只决定有哪几步、先后怎么排,每一步的内容都来自这条原片:- 拍摄:测出来的景别、机位、布光(主光方向、光比、软硬、色温)、调色,和按测量推的布光做法- 生成:几个生成单元、调用几次哪个模型、每个单元要喂的首帧图和参考图@@ -25,6 +25,19 @@- 自动:装了 [capsule-cinema](https://github.com/JuneYaooo/capsule-cinema) 的话,说「用 capsule-cinema 复刻 AI 镜头」,agent 会调用视频模型生成,再自动拼回、出对比片。调模型要花钱,所以它会先免费试跑一遍,等你确认后再正式生成。3. 目前自动生成还是一个镜头调用一次模型。报告里已经写好了一次生成多个镜头的提示词,这种方式更省钱,但现在只能走手动这条路。+## 舞蹈和动作镜头:用原片驱动++舞蹈、打斗、健身这类镜头,看点是大幅度的全身动作。带货、口播,或全程唱歌、说话只是小幅度动的,不算这一类,照原来的生成单元走,对口型或数字人就能做。只给首尾帧生成,中间的动作全靠模型猜,编舞和卡点会丢,所以报告会把它们单独列成「动作驱动」,不放进生成单元。++1. 让 agent 跑 `rea-video drive <报告目录>`:擦掉字幕和贴纸,在动作停顿、靠近拍点的地方切成 10 秒左右的短段,每段一个驱动视频。+2. 准备一张角色设定图(同一套衣服的正面、侧面、背面全身和脸部特写),每段都用它。+3. 多数情况直接拿驱动视频当参考就行,不用转深度或做白模:单人、全身、一镜到底用 Kling 动作控制;多人、有运镜或中间有剪辑用 Seedance 2.5 全能参考;想本地跑用 Wan Animate。报告按这几点给出这条先用哪种,提示词都写好了:+ - 原片背景杂乱(街道、人群、杂物),或你的新场景和原片差很多:转成深度视频(`--depth` 或 Video Depth Anything)再喂,只留动作、空间和运镜。+ - 连空间、机位都要换,或这套动作要反复用:动捕转成白模,在 Blender 里重设机位渲染,再用白模参考生成。+ - 神态是看点:留在直接参考原片。深度、骨骼和白模只带身体,表情会丢。+ - 新角色是 Q 版、动物、卡通,体型差很多:用骨骼视频(DWPose + Wan VACE)。+4. 生成好的段发给 agent,它用 `rea-video drive --join` 拼回原时间线,再出一条和原片并排的对比片,对着原曲看卡点。+## 代码 / 界面动效:写代码报告会给出每段的文字、版式和动效节奏。让 agent「按报告写一个 Remotion 工程」,之后改文案只改数据。工具目前不会自动生成这个工程,要 agent 来写。diff --git a/rea_video/capabilities/MATRIX.md b/rea_video/capabilities/MATRIX.mdindex 33f3ee4..f2c419f 100644--- a/rea_video/capabilities/MATRIX.md+++ b/rea_video/capabilities/MATRIX.md@@ -14,6 +14,9 @@| `analyze.camera_motion` | 相机运动反解 | ◐ `megasam` || `analyze.audio_separation` | 音频分轨 | ● `demucs` || `analyze.beat_tempo` | 节拍与段落分析 | ◐ `librosa-madmom` |+| `analyze.depth_video` | 视频深度估计 | ◐ `video-depth-anything` |+| `analyze.pose_track` | 人体骨骼跟踪 | ◐ `dwpose` |+| `analyze.body_mocap` | 单目视频动捕 | ◐ `rokoko-vision` || `analyze.image_layer_decompose` | 单帧图层分解 | ◐ `seedream-5.0`、◐ `seedream-5.5` || `image.t2i` | 文生图 | ◐ `flux-3`、◐ `flux-3-klein`、● `gpt-image-2.5`、◐ `gpt-image-2.6`、◐ `grok-imagine-image-2.0`、○ `ideogram-4.5`、◐ `kling-o3-image`、◐ `mai-image-2.6`、○ `midjourney-v8.2`、◐ `minimax-h3-image`、◐ `nano-banana-2-lite`、◐ `nano-banana-2.1`、◐ `qwen-image-2.1`、◐ `qwen-image-3.0`、◐ `qwen-image-3.0-pro`、◐ `seedream-5.0`、◐ `seedream-5.5` || `image.edit_multi_ref` | 多参考图像编辑/合成 | ◐ `flux-3`、◐ `flux-3-klein`、● `gpt-image-2.5`、◐ `gpt-image-2.6`、◐ `grok-imagine-image-2.0`、○ `ideogram-4.5`、◐ `kling-o3-image`、◐ `mai-image-2.6`、○ `midjourney-v8.2`、◐ `minimax-h3-image`、◐ `nano-banana-2.1`、◐ `qwen-image-2.1`、◐ `qwen-image-3.0`、◐ `qwen-image-3.0-pro`、◐ `seedream-5.0`、◐ `seedream-5.5` |@@ -21,7 +24,7 @@| `image.storyboard_series` | 分镜组图 | ◐ `kling-o3-image`、◐ `seedream-5.0` || `image.tryon` | 虚拟试穿 | ◐ `fashn-tryon-max`、◐ `fashn-v1.6`、◐ `kling-kolors-tryon`、◐ `kling-virtual-tryon-3`、◐ `qwen-image-2.1` || `video.t2v` | 文生视频 | ◐ `flux-3-video`、○ `flux-3-video-max`、◐ `gemini-omni-flash`、◐ `grok-imagine-video-1.5`、○ `grok-imagine-video-1.5-lite`、◐ `hailuo-2.3`、○ `happyhorse-1.0`、◐ `heygen-video-1`、◐ `hunyuanvideo-1.5`、◐ `kling-3.0`、◐ `kling-4.0`、◐ `kling-4.0-flash`、◐ `kling-o3`、◐ `ltx-2.5`、○ `luma-ray3.2`、◐ `minimax-h3`、◐ `minimax-h3-max`、○ `p-video-2-pro`、◐ `pika-h3-flex`、◐ `pixverse-v6`、◐ `runway-gen-4.5`、◐ `seedance-2.0`、● `seedance-2.5`、○ `seedance-2.5-flash`、○ `skyreels-v4`、○ `utopai-x`、◐ `veo-3.1`、◐ `vidu-q3`、● `wan-2.2`、◐ `wan-3.0` |-| `video.i2v_first_frame` | 图生视频(首帧) | ◐ `flux-3-video`、○ `flux-3-video-max`、◐ `gemini-omni-flash`、◐ `grok-imagine-video-1.5`、○ `grok-imagine-video-1.5-lite`、◐ `hailuo-2.3`、○ `happyhorse-1.0`、◐ `heygen-video-1`、◐ `hunyuanvideo-1.5`、◐ `kling-3.0`、◐ `kling-4.0`、◐ `kling-4.0-flash`、◐ `kling-o3`、◐ `ltx-2.5`、○ `luma-ray3.2`、◐ `minimax-h3`、◐ `minimax-h3-max`、○ `p-video-2-pro`、◐ `pika-h3-flex`、◐ `pixverse-v6`、◐ `runway-gen-4.5`、◐ `seedance-2.0`、● `seedance-2.5`、○ `seedance-2.5-flash`、○ `skyreels-v4`、◐ `veo-3.1`、◐ `vidu-q3`、◐ `vidu-q4-preview`、● `wan-2.2`、◐ `wan-3.0` |+| `video.i2v_first_frame` | 图生视频(首帧) | ◐ `flux-3-video`、○ `flux-3-video-max`、◐ `gemini-omni-flash`、◐ `grok-imagine-video-1.5`、○ `grok-imagine-video-1.5-lite`、◐ `hailuo-2.3`、○ `happyhorse-1.0`、◐ `heygen-video-1`、◐ `hunyuanvideo-1.5`、◐ `kling-3.0`、◐ `kling-4.0`、◐ `kling-4.0-flash`、◐ `kling-o3`、◐ `ltx-2.5`、○ `luma-ray3.2`、◐ `minimax-h3`、◐ `minimax-h3-max`、○ `p-video-2-pro`、◐ `pika-h3-flex`、◐ `pixverse-v6`、◐ `runway-gen-4.5`、◐ `seedance-2.0`、● `seedance-2.5`、○ `seedance-2.5-flash`、○ `skyreels-v4`、◐ `veo-3.1`、◐ `vidu-q3`、◐ `vidu-q4-preview`、● `wan-2.2`、◐ `wan-3.0`、◐ `wan-vace` || `video.i2v_first_last` | 首尾帧生成 | ◐ `flux-3-video`、○ `flux-3-video-max`、◐ `gemini-omni-flash`、◐ `grok-imagine-video-1.5`、◐ `heygen-video-1`、◐ `kling-3.0`、◐ `kling-4.0`、◐ `kling-o3`、◐ `minimax-h3`、◐ `minimax-h3-max`、○ `p-video-2-pro`、◐ `pika-h3-flex`、◐ `pixverse-v6`、◐ `seedance-2.0`、● `seedance-2.5`、○ `seedance-2.5-flash`、◐ `veo-3.1`、◐ `wan-3.0` || `video.keyframes` | 多关键帧控制 | ◐ `flux-3-video`、○ `flux-3-video-max`、◐ `grok-imagine-video-1.5`、◐ `kling-4.0`、◐ `runway-gen-4.5` || `video.multi_reference` | 多参考生视频(主体一致) | ◐ `gemini-omni-flash`、◐ `grok-imagine-video-1.5`、○ `happyhorse-1.0`、◐ `heygen-video-1`、◐ `kling-3.0`、◐ `kling-4.0`、◐ `kling-4.0-flash`、◐ `kling-o3`、◐ `minimax-h3`、◐ `minimax-h3-max`、◐ `pika-h3-flex`、◐ `pixverse-v6`、◐ `seedance-2.0`、● `seedance-2.5`、○ `seedance-2.5-flash`、◐ `veo-3.1`、◐ `vidu-q3`、◐ `vidu-q4-preview`、◐ `wan-3.0` |@@ -29,9 +32,10 @@| `video.reference_audio` | 参考音频生成 | ◐ `grok-imagine-video-1.5`、◐ `heygen-video-1`、◐ `kling-4.0-flash`、◐ `ltx-2.5`、◐ `minimax-h3-max`、◐ `pika-h3-flex`、◐ `seedance-2.0`、● `seedance-2.5`、○ `seedance-2.5-flash`、◐ `vidu-q4-preview`、◐ `wan-3.0` || `video.multi_shot` | 单次多镜头 | ◐ `flux-3-video`、◐ `gemini-omni-flash`、◐ `kling-3.0`、◐ `kling-4.0`、◐ `kling-4.0-flash`、◐ `kling-o3`、◐ `ltx-2.5`、◐ `minimax-h3`、◐ `pika-h3-flex`、◐ `pixverse-v6`、◐ `seedance-2.0`、● `seedance-2.5`、◐ `veo-3.1`、◐ `vidu-q4-preview`、◐ `wan-3.0` || `video.extend` | 续写延长 | ◐ `flux-3-video`、◐ `gemini-omni-flash`、● `seedance-2.5`、◐ `veo-3.1` |-| `video.edit_v2v` | 视频编辑(保留运动) | ◐ `flux-3-video`、◐ `gemini-omni-flash`、○ `happyhorse-1.0`、○ `higgsfield-genjutsu`、◐ `kling-4.0`、◐ `kling-o3`、◐ `ltx-2.5`、○ `luma-ray3.2`、◐ `pika-h3-flex`、○ `runway-aleph-2`、◐ `runway-gen-4.5`、◐ `seedance-2.0`、● `seedance-2.5`、○ `skyreels-v4`、◐ `viggle-animate`、◐ `wan-2.2-animate`、○ `wan-2.7-edit` |+| `video.edit_v2v` | 视频编辑(保留运动) | ◐ `flux-3-video`、◐ `gemini-omni-flash`、○ `happyhorse-1.0`、○ `higgsfield-genjutsu`、◐ `kling-4.0`、◐ `kling-o3`、◐ `ltx-2.5`、○ `luma-ray3.2`、◐ `pika-h3-flex`、○ `runway-aleph-2`、◐ `runway-gen-4.5`、◐ `seedance-2.0`、● `seedance-2.5`、○ `skyreels-v4`、◐ `viggle-animate`、◐ `wan-2.2-animate`、○ `wan-2.7-edit`、◐ `wan-vace` || `video.camera_control` | 运镜与镜头参数控制 | ◐ `gemini-omni-flash`、◐ `kling-3.0`、◐ `kling-4.0`、◐ `pixverse-v6`、○ `runway-aleph-2`、◐ `runway-gen-4.5`、● `seedance-2.5` || `video.native_audio` | 音画同出 | ◐ `flux-3-video`、○ `flux-3-video-max`、◐ `gemini-omni-flash`、◐ `grok-imagine-video-1.5`、○ `grok-imagine-video-1.5-lite`、◐ `heygen-video-1`、◐ `kling-3.0`、◐ `kling-4.0`、◐ `kling-4.0-flash`、◐ `ltx-2.5`、○ `luma-ray3.2`、◐ `minimax-h3`、◐ `minimax-h3-max`、○ `p-video-2-pro`、◐ `pika-h3-flex`、◐ `pixverse-v6`、◐ `runway-gen-4.5`、◐ `seedance-2.0`、● `seedance-2.5`、○ `seedance-2.5-flash`、○ `skyreels-v4`、○ `utopai-x`、◐ `veo-3.1`、◐ `vidu-q3`、◐ `vidu-q4-preview`、◐ `wan-3.0` |+| `video.control_video` | 控制视频驱动生成 | ◐ `wan-vace` || `motion.transfer` | 动作迁移 | ○ `dreamactor-m2.0`、○ `higgsfield-genjutsu`、◐ `kling-motion-control`、◐ `runway-gen-4.5`、◐ `viggle-animate`、◐ `viggle-v4`、◐ `wan-2.2-animate`、◐ `wan-animate-2` || `avatar.audio_driven` | 音频驱动数字人 | ○ `creatify-aurora`、○ `hedra-omnia`、◐ `heygen-avatar-v`、◐ `kling-avatar-v2`、◐ `longcat-video-avatar-1.5`、◐ `ltx-2.3-lipsync`、◐ `ltx-2.5`、◐ `mirage-avatar-x`、◐ `omnihuman-2.0`、◐ `sync-3`、◐ `synthesia-express-3`、○ `veed-fabric-1.0` || `lipsync.redub` | 口型重配 | ◐ `heygen-avatar-v`、◐ `sync-3`、◐ `sync-react-1` |@@ -55,6 +59,7 @@|---|---|---|---|---|---|---|---|| Demucs(htdemucs) | Meta(开源) | analysis | ga | | | 是 | knowledge 2026-10-29 || Doubao Seed 2.0 Pro(豆包) | ByteDance | analysis | ga | | | 是 | third-party 2026-10-29 |+| DWPose | IDEA Research(开源) | analysis | ga | | | 是 | knowledge 2026-11-14 || FunASR / SenseVoice | Alibaba(开源) | analysis | ga | | | 有条件 | knowledge 2026-10-29 || Gemini 3.1 Pro | Google | analysis | ga | 10800 | | 是 | third-party 2026-10-29 || Gemini 3.5 Flash | Google | analysis | ga | 10800 | | 是 | third-party 2026-10-29 |@@ -66,8 +71,10 @@| PySceneDetect | 开源 | analysis | ga | | | 是 | knowledge 2026-10-29 || Qwen3.5 397B-A17B(开源) | Alibaba | analysis | ga | | | 有条件 | third-party 2026-10-29 || RobustVideoMatting(RVM) | 开源 | analysis | ga | | | 有条件 | knowledge 2026-10-29 |+| Rokoko Vision 3.0 | Rokoko | analysis | ga | | | 有条件 | vendor 2026-11-14 || SAM 系列(SAM 2 / SAM 3) | Meta(开源) | analysis | ga | | | 有条件 | knowledge 2026-10-29 || TransNetV2 | 开源 | analysis | ga | | | 是 | knowledge 2026-10-29 |+| Video Depth Anything | ByteDance(开源) | analysis | ga | | | 有条件 | third-party 2026-11-14 || 火山引擎人像视频抠像 | ByteDance | analysis | ga | | | 是 | third-party 2026-10-29 || WhisperX | 开源 | analysis | ga | | | 是 | knowledge 2026-10-29 || CosyVoice 3(开源)/ 百炼 CosyVoice v3.5 | Alibaba | audio | ga | | | 有条件 | third-party 2026-10-29 |@@ -169,3 +176,4 @@| Wan 2.2(开源,含 TI2V-5B) | Alibaba | video | ga | | 否 | 是 | third-party 2026-10-29 || Wan 2.7 视频编辑 | Alibaba | video | ga | | | 是 | third-party 2026-10-29 || Wan 3.0(万相) | Alibaba | video | ga | 30 | 是 | 是 | vendor 2026-11-12 |+| Wan VACE(Wan 2.1 VACE / Wan2.2-VACE-Fun) | Alibaba | video | ga | | 否 | 是 | third-party 2026-11-14 |diff --git a/rea_video/capabilities/models/analysis.yaml b/rea_video/capabilities/models/analysis.yamlindex 14f0085..9c24850 100644--- a/rea_video/capabilities/models/analysis.yaml+++ b/rea_video/capabilities/models/analysis.yaml@@ -239,6 +239,62 @@ models:verified: {date: 2026-10-29, basis: third-party}confidence: medium+ - id: video-depth-anything+ name: Video Depth Anything+ vendor: ByteDance(开源)+ category: analysis+ release: 2025-01+ status: ga+ access: [open-weights]+ primitives: [analyze.depth_video]+ strengths:+ - 长视频深度估计,帧间稳定,不像逐帧深度那样闪+ - 有 Small / Base / Large 三档,Small 消费级显卡就能跑+ weaknesses:+ - 快速转身、手部交叠和遮挡处仍可能缺肢体,出驱动前要整段看一遍+ license: {commercial: conditional, note: Small 为 Apache 2.0;Base / Large 为 CC BY-NC 4.0,不能商用}+ sources:+ - https://github.com/DepthAnything/Video-Depth-Anything+ - https://aiidelist.com/blog/remake-viral-video-codex-depth-maps-minimax-h3+ verified: {date: 2026-11-14, basis: third-party}+ confidence: medium+ notes: 深度驱动复刻的做法见 aiidelist 的流程:原片转灰度深度视频,再和角色设定图一起交给视频模型++ - id: dwpose+ name: DWPose+ vendor: IDEA Research(开源)+ category: analysis+ release: 2023-07+ status: ga+ access: [open-weights]+ primitives: [analyze.pose_track]+ strengths:+ - 全身含手指和脸部关键点;ComfyUI 的 controlnet_aux 有现成节点,出骨骼视频接 Wan VACE+ weaknesses:+ - 只有 2D 关键点,转身和前后遮挡时左右容易翻+ license: {commercial: true, note: Apache 2.0}+ sources:+ - https://github.com/IDEA-Research/DWPose+ verified: {date: 2026-11-14, basis: knowledge}+ confidence: medium++ - id: rokoko-vision+ name: Rokoko Vision 3.0+ vendor: Rokoko+ category: analysis+ status: ga+ access: [app]+ primitives: [analyze.body_mocap]+ strengths:+ - 上传一段视频就出清理过的 3D 动作,导出 FBX / BVH(HIK、Mixamo 骨架),能直接进 Blender+ weaknesses:+ - 免费额度很少;BVH 导出要付费档+ license: {commercial: conditional, note: 以平台条款为准}+ sources:+ - https://rokoko.com/products/video+ verified: {date: 2026-11-14, basis: vendor}+ confidence: medium+- id: megasamname: MegaSaMvendor: 学术开源(CVPR 2025)diff --git a/rea_video/capabilities/models/video.yaml b/rea_video/capabilities/models/video.yamlindex b95954b..13d3fcc 100644--- a/rea_video/capabilities/models/video.yaml+++ b/rea_video/capabilities/models/video.yaml@@ -691,6 +691,29 @@ models:verified: {date: 2026-10-29, basis: third-party}confidence: high+ - id: wan-vace+ name: Wan VACE(Wan 2.1 VACE / Wan2.2-VACE-Fun)+ vendor: Alibaba+ category: video+ release: 2025-05+ status: ga+ access: [open-weights]+ primitives: [video.control_video, video.edit_v2v, video.i2v_first_frame]+ limits:+ resolutions: [480p, 720p]+ audio: {native: false}+ strengths:+ - 深度、骨骼、线稿视频都能当控制输入,加一张参考图给角色外观;ComfyUI 有现成的舞蹈动作迁移工作流+ - 开源可本地跑,参数(控制强度、分段)全可调+ weaknesses:+ - 要自己搭 ComfyUI 和显卡;长段要分段生成再拼+ license: {commercial: true, note: Apache 2.0}+ sources:+ - https://github.com/ali-vilab/VACE+ - https://www.runcomfy.com/comfyui-workflows/wan-2-2-vace-in-comfyui-pose-driven-motion-video-workflow+ verified: {date: 2026-11-14, basis: third-party}+ confidence: medium+- id: ltx-2.5name: LTX-2.5(开源)vendor: Lightricksdiff --git a/rea_video/capabilities/primitives.yaml b/rea_video/capabilities/primitives.yamlindex 559c470..f66c907 100644--- a/rea_video/capabilities/primitives.yaml+++ b/rea_video/capabilities/primitives.yaml@@ -87,6 +87,28 @@ primitives:inputs: [audio]output: beat_griduse_when: 音乐卡点视频;给剪辑节奏提供节拍锚点+ - id: analyze.depth_video+ group: analyze+ name: 视频深度估计+ inputs: [video]+ output: video+ use_when: 舞蹈、打斗等动作镜头复刻:把原片转成灰度深度视频当驱动,保留动作、走位、空间和运镜,去掉原来的人长什么样、穿什么+ metrics: [motion_trajectory_error]+ probe: 快速转身、手部交叠、多人遮挡片段的逐帧闪烁和肢体缺失+ - id: analyze.pose_track+ group: analyze+ name: 人体骨骼跟踪+ inputs: [video]+ output: keypoints+ use_when: 目标角色和原舞者体型差很多(Q 版、动物、卡通)时,用骨骼而不是深度当驱动,体型不会被带过去+ metrics: [motion_trajectory_error]+ - id: analyze.body_mocap+ group: analyze+ name: 单目视频动捕+ inputs: [video]+ output: animation+ use_when: 动作要改机位、反复用或在 3D 里改时,把原片动作转成 FBX / BVH,绑到白模上重新渲染+ metrics: [motion_trajectory_error]- id: analyze.image_layer_decomposegroup: analyzename: 单帧图层分解@@ -219,6 +241,13 @@ primitives:metrics: [lip_sync, speech_wer]# ===== 人物驱动 =====+ - id: video.control_video+ group: video+ name: 控制视频驱动生成+ inputs: [video, image, text]+ output: video+ use_when: 用深度、骨骼或线稿视频逐帧锁住动作和结构,参考图给角色外观(舞蹈、打斗的本地开源流程)+ metrics: [motion_trajectory_error, identity_consistency]- id: motion.transfergroup: charactername: 动作迁移diff --git a/rea_video/capabilities/routing.yaml b/rea_video/capabilities/routing.yamlindex c29977f..6c48dc9 100644--- a/rea_video/capabilities/routing.yaml+++ b/rea_video/capabilities/routing.yaml@@ -45,6 +45,7 @@ segmentation:defaults:generation_unit_s: {min: 4, max: 15}multishot_hardcut_s: {prefer: 8, max: 10} # S06:单个生成单元内连续硬切的时长+ motion_segment_s: {prefer: 10, max: 15, min: 3} # 动作驱动视频每段的长度:在停顿处切,短段手脚更稳same_scene_distance: 0.5 # 相邻镜头首尾帧颜色分布距离(Bhattacharyya)低于它算同一场景rules:- id: S01-merge-multishot@@ -94,11 +95,12 @@ rules:- id: R04-precise-motionlayer: basewhen: [precise_motion]- route: [motion.transfer, video.reference_video, video.edit_v2v]- prefer: [kling-motion-control, wan-2.2-animate, wan-animate-2, seedance-2.5, kling-o3, runway-gen-4.5]+ route: [motion.transfer, video.reference_video, analyze.depth_video, analyze.pose_track, video.control_video, analyze.body_mocap, render.3d_scene]+ prefer: [kling-motion-control, seedance-2.5, wan-2.2-animate, wan-animate-2, video-depth-anything, dwpose, wan-vace, rokoko-vision, blender]verify: [motion_trajectory_error, identity_consistency, beat_alignment]- why: 动作的时间行为无法用文字和静帧描述- guard: 参考视频先当证据;只有当时间行为本身就是看点时,才把片段作为模型输入。驱动视频必须有权使用+ why: 动作的时间行为无法用文字和静帧描述;首尾帧只锁两端,中间的编舞全靠模型猜+ alternatives: 原片人物的外观或体型被带出来时,改用深度视频(换人换景、保留运镜)或骨骼视频(目标体型差很多)当驱动;要改机位或反复用这套动作时,单目动捕转白模,在 Blender 里重设机位渲染,再用白模参考生成+ guard: 驱动视频先擦掉字幕、贴纸(会被当成画面的一部分学进去),按停顿切成短段(手脚和转身在短段里更稳);用别人的舞蹈视频驱动要注意肖像权与版权- id: R05-garmentlayer: basediff --git a/rea_video/cli.py b/rea_video/cli.pyindex ed829c0..9bc0a1f 100644--- a/rea_video/cli.py+++ b/rea_video/cli.py@@ -387,6 +387,32 @@ def cmd_code_remake(args) -> int:return 0+def cmd_drive(args) -> int:+ from .drive import drive, join++ out = Path(args.out_dir)+ if not (out / "breakdown.json").is_file():+ raise SystemExit(f"rea-video: {out} 下没有 breakdown.json,先运行 decompose")+ try:+ if args.join is not None:+ res = join(out, Path(args.join) if args.join else None)+ else:+ shots = None+ if args.shots:+ shots = []+ for part in args.shots.split(","):+ a, _, z = part.strip().partition("-")+ shots += list(range(int(a), int(z or a) + 1))+ res = drive(out, shots=shots, depth=args.depth, clean=not args.no_clean, prefer=args.prefer, max_s=args.max)+ res = {k: v for k, v in res.items() if k != "segments"} | {"segments": [+ {k: s[k] for k in ("id", "start", "end", "duration", "cut_in", "cuts_inside")} for s in res["segments"]],+ "readme": str(out / "drive" / "README.md")}+ except (ValueError, FileNotFoundError) as e:+ raise SystemExit(f"rea-video: {e}")+ print(json.dumps(res, ensure_ascii=False, indent=1))+ return 0++def cmd_summary(args) -> int:"""Compact, agent-friendly view of a breakdown (instead of reading the whole JSON)."""from .i18n import T, join@@ -727,6 +753,16 @@ def main(argv: list[str] | None = None) -> int:cr.add_argument("--no-compare", action="store_true", help="渲染后不打分")cr.set_defaults(func=cmd_code_remake)+ dv = sub.add_parser("drive", help="舞蹈 / 动作镜头的驱动视频:擦掉字幕贴纸、在动作停顿处切段(drive/seg_XX.mp4),喂动作迁移或参考视频模型;--join 把生成好的段拼回原时间线")+ dv.add_argument("out_dir", help="decompose 的输出目录")+ dv.add_argument("--shots", help="只做这些镜头,如 3-7,9(默认用复刻方案里的动作驱动单元)")+ dv.add_argument("--depth", action="store_true", help="同时出深度视频(需要 transformers + torch;没有时 README 里给 Video Depth Anything 命令)")+ dv.add_argument("--no-clean", action="store_true", help="不擦字幕和贴纸")+ dv.add_argument("--prefer", type=float, help="每段的理想长度(秒),默认 10")+ dv.add_argument("--max", type=float, help="每段最长(秒),默认 15;Kling 最长 30")+ dv.add_argument("--join", nargs="?", const="", default=None, metavar="RESULTS", help="把生成好的段(默认 drive/results.json)拼回去,写进 remake/mine.json")+ dv.set_defaults(func=cmd_drive)+sm = sub.add_parser("summary", help="紧凑打印拆解结果(低置信镜头会被标出来)")sm.add_argument("breakdown")sm.set_defaults(func=cmd_summary)diff --git a/rea_video/dance.py b/rea_video/dance.pynew file mode 100644index 0000000..ac9df37--- /dev/null+++ b/rea_video/dance.py@@ -0,0 +1,353 @@+"""Motion-led shots (dance, fights, workouts): the moves are the point, and words cannot carry them.++First / last frame generation pins two moments and leaves the choreography in between to the model, so a dance+remade that way keeps the look and loses the dance. What works is driving the new picture from the source motion:++ ref the source clip itself as the motion reference (Kling Motion Control, Seedance 2.5 reference video, Wan Animate)+ depth the source turned into a grey depth video: moves, blocking, space and camera stay, the original person's+ face, clothes and set go (Video Depth Anything, then a reference-video model or Wan VACE)+ pose a skeleton video: only the joints travel, so a very different body (chibi, animal, cartoon) keeps its shape+ clay monocular mocap to FBX / BVH, a clay figure in Blender with a new camera, then a clay-render reference+ shoot for a filmed original: dance it yourself in the same framing, then swap or restyle if wanted++Which shots are motion-led comes from the image readers (performance.move: the agent's review or the VLM);+nothing in the pixels separates a dance from someone walking about. The drive clips themselves (captions+removed, cut at calm moments near beats) are written by `rea-video drive` (drive.py).+"""+from __future__ import annotations++from . import performance+from .i18n import LangDict, T, join, semi, shot_ids++MOTION_LABELS = ("live_action", "ai_video", "cg_3d", "anim_2d")+GENERATED = ("ai_video", "cg_3d", "anim_2d")+MOVE_ZH = LangDict({"dance": "舞蹈", "fight": "打斗", "sport": "健身 / 运动"}, en={"dance": "dance", "fight": "fight", "sport": "workout / sport"})+PRODUCT_KINDS = ("product_photo", "logo")+TALK = 0.5 # share of a shot under speech or singing past which small movements are lip-sync / avatar work+_MOVING = ("smooth_move", "handheld_like")+SEGMENT = {"prefer": 10.0, "max": 15.0, "min": 3.0}+++def segment_limits() -> dict:+ from .plan import _load++ try:+ got = ((_load("routing.yaml").get("segmentation") or {}).get("defaults") or {}).get("motion_segment_s") or {}+ except (OSError, ValueError):+ got = {}+ return {k: float(got.get(k, v)) for k, v in SEGMENT.items()}+++def _product(rec: dict) -> bool:+ m = rec.get("material") or {}+ return any(it.get("kind") in PRODUCT_KINDS for it in (m.get("items") or []) + (m.get("references") or []))+++def guard(rec: dict) -> str:+ """Why a shot is not driven from the source motion even if a reader marked it, "" when nothing stops it.+ Product shots are selling, not choreography; a shot mostly under speech or singing without the whole body in+ frame is a talking / singing performance that a lip-sync or avatar model already reproduces."""+ if _product(rec) or rec.get("product_video"):+ return T("带货 / 商品镜头", "product / selling shot")+ p = performance.of(rec) or {}+ if float(rec.get("talk_share") or 0) >= TALK and p.get("full_body") is not True:+ return T("边说或边唱、不是全身大动作:对口型或数字人就能做", "talking or singing without full-body moves: lip sync or an avatar does it")+ return ""+++def mark(b: dict) -> None:+ """Stamp what the guard needs from the whole video: how much of each shot is under speech or singing, and+ whether the video is a product / desk video."""+ segs = ((b.get("audio") or {}).get("voice") or {}).get("segments") or [] if ((b.get("audio") or {}).get("voice") or {}).get("present") else []+ fmt = (((b.get("aspects") or {}).get("format") or {}).get("result") or {}).get("format")+ from .entities import cast++ shop = fmt in ("desk", "product") or any(c.get("kind") == "product" for c in cast(b).get("characters") or [])+ for r in b.get("shots", []):+ d = r.get("duration") or 0+ over = sum(max(0.0, min(r["end"], z) - max(r["start"], a)) for a, z in segs)+ r["talk_share"] = round(over / d, 3) if d else 0.0+ r["product_video"] = shop+++def move_of(rec: dict) -> dict | None:+ """The shot's performance when its motion is the point (a reader set performance.move and no guard stops it), else None."""+ if (rec.get("base") or {}).get("label") not in MOTION_LABELS:+ return None+ p = performance.of(rec)+ return p if p and p.get("move") and not guard(rec) else None+++def motion_indices(b: dict) -> set[int]:+ return {r["index"] for r in b.get("shots", []) if move_of(r)}+++def share(b: dict) -> float:+ total = sum(r["duration"] for r in b.get("shots", [])) or 1.0+ return sum(r["duration"] for r in b.get("shots", []) if move_of(r)) / total+++def is_motion_video(b: dict) -> bool:+ return share(b) >= 0.5+++def maybe_motion(rec: dict, b: dict) -> bool:+ """A hint for the image reader, not a verdict: a long shot with a lot of local motion over music and little speech.+ Fights, crowds and handheld walks look the same in these numbers, so it only asks the reader to look."""+ if (rec.get("base") or {}).get("label") not in MOTION_LABELS or rec.get("duration", 0) < 3 or _product(rec) or rec.get("product_video"):+ return False+ if float(rec.get("talk_share") or 0) >= TALK:+ return False+ f = rec.get("features") or {}+ audio = b.get("audio") or {}+ voice = audio.get("voice") or {}+ talk = float(voice.get("ratio") or 0) if voice.get("present") else 0.0+ return (float(f.get("local_motion_ratio") or 0) >= 0.3 and f.get("camera") != "planar_zoom_pan"+ and bool((audio.get("music") or {}).get("present")) and talk < 0.3)+++def _runs(b: dict) -> list[list[dict]]:+ """Consecutive motion-led shots: one dance cut into several takes is still one piece of choreography."""+ runs, cur = [], []+ for r in b.get("shots", []):+ if move_of(r) and (not cur or abs(cur[-1]["end"] - r["start"]) < 0.05):+ cur.append(r)+ continue+ if cur:+ runs.append(cur)+ cur = [r] if move_of(r) else []+ if cur:+ runs.append(cur)+ return runs+++def _beats(b: dict, a: float, z: float) -> list[float]:+ return [t for t in ((b.get("audio") or {}).get("music") or {}).get("beats") or [] if a <= t <= z]+++def _bpm(b: dict) -> float | None:+ audio = b.get("audio") or {}+ v = audio.get("tempo_bpm") or (audio.get("music") or {}).get("tempo_bpm")+ return float(v) if v else None+++def _cast_bits(b: dict, shots: set[int]) -> tuple[list[dict], str]:+ """(characters seen in these shots, the scene's look) from the readers' cast."""+ from .entities import cast++ c = cast(b)+ who = [x for x in c.get("characters") or [] if set(x.get("shots") or []) & shots and x.get("kind") in ("person", "animal", "cartoon", "avatar", "")]+ scene = next((s.get("look") or s.get("where") or "" for s in c.get("scenes") or [] if set(s.get("shots") or []) & shots), "")+ return who, scene+++def _routes(u: dict) -> list[dict]:+ """The ways to drive this run, best fit first, each with when it fits, the tools and what to feed."""+ multi, takes, moving, full = u["movers"] >= 2, len(u["shots"]), u["camera_moves"], u["full_body"]+ cartoon = any(c.get("kind") in ("cartoon", "animal") for c in u["who"])+ kling_off = [w for w, bad in ((T("原片多人同时跳,只会取画面里最大的那个人", "several people move at once; it only takes the largest person"), multi),+ (T("原片中间有剪辑,要一镜到底的段落", "the source has cuts; it needs single-take segments"), takes > 1),+ (T("原片手脚或头常出画,要头到脚都在画面里", "head, hands or feet leave the frame; it needs the whole body in view"), full is False),+ (T("原片有运镜,它的参考视频最好是固定机位", "the source camera moves; its reference works best locked off"), moving)) if bad]+ ref = {"key": "ref", "name": T("原片当参考视频(动作迁移)", "Source clip as the motion reference (motion transfer)"),+ "when": T("原片背景干净、新场景和原片差不多,或神态要一起复刻时:动作、节拍、走位和表情一次带过去,最省事",+ "when the source background is clean and the new setting is close to it, or the expression must come across too: moves, timing, "+ "blocking and face in one go, the least work"),+ "tools": [T("Kling 动作控制:单人、全身、一镜到底最稳;3.0 可以绑定脸", "Kling Motion Control: steadiest with one person, full body, single take; 3.0 can bind a face")+ + (T("(这条不太合适:{w})", " (a poor fit here: {w})", w=semi().join(kling_off)) if kling_off else ""),+ T("Seedance 2.5 全能参考:多人、带运镜、中间有剪辑都能喂;参考视频合计 ≤30 秒,首帧和参考不能同传",+ "Seedance 2.5 omni-reference: takes several dancers, camera moves and cuts; reference videos ≤30 s in total, and no first frame alongside references"),+ T("Wan 2.2 Animate / Wan-Animate-2:开源,本地显卡跑,也能在原片里直接换人",+ "Wan 2.2 Animate / Wan-Animate-2: open weights on your own GPU; can also replace the person inside the source")],+ "feed": T("驱动视频 `drive/seg_XX.mp4` + 角色图", "drive clip `drive/seg_XX.mp4` + character image")}+ depth = {"key": "depth", "name": T("深度视频当驱动", "Depth video as the driver"),+ "when": T("原片背景杂乱(街道、人群、杂物),或新场景和原片差很多:只留动作、空间和运镜,原背景和原来的人一点不带;表情会丢",+ "when the source background is busy (street, crowd, clutter) or the new setting is far from it: only moves, space and camera are kept, "+ "nothing of the old background or person; the expression is lost"),+ "tools": [T("Video Depth Anything 出灰度深度视频(Small 版可商用),或 `rea-video drive --depth`",+ "Video Depth Anything makes the grey depth video (the Small model allows commercial use), or `rea-video drive --depth`"),+ T("再把深度视频当参考视频喂 Seedance 2.5,或当控制视频喂 Wan VACE",+ "then feed it to Seedance 2.5 as the reference video, or to Wan VACE as the control video")],+ "feed": T("深度视频 `drive/seg_XX_depth.mp4` + 角色设定图", "depth video `drive/seg_XX_depth.mp4` + character sheet")}+ pose = {"key": "pose", "name": T("骨骼视频当驱动", "Skeleton video as the driver"),+ "when": T("新角色和原舞者体型差很多(Q 版、动物、卡通):深度会把原来的身形带过去,骨骼只带关节",+ "when the new character's build is far from the dancer's (chibi, animal, cartoon): depth carries the old silhouette, a skeleton only the joints"),+ "tools": [T("DWPose 出骨骼视频(ComfyUI controlnet_aux 节点),接 Wan VACE + 角色参考图",+ "DWPose makes the skeleton video (ComfyUI controlnet_aux node), into Wan VACE with the character reference")],+ "feed": T("骨骼视频 + 角色图", "skeleton video + character image")}+ clay = {"key": "clay", "name": T("动捕转白模再生成", "Mocap to a clay figure, then generate"),+ "when": T("新场景连空间、机位都要换,或这套动作要反复用、在 3D 里改:画面里只有一个动的白模;最费事,表情会丢",+ "when even the space and camera change, or the moves will be reused or edited in 3D: nothing but a moving clay figure; the most work, and the expression is lost"),+ "tools": [T("Rokoko Vision 等单目动捕出 FBX / BVH → Blender 绑到白模,重设机位渲染白模视频",+ "monocular mocap such as Rokoko Vision to FBX / BVH → a clay figure in Blender, re-camera and render the clay video"),+ T("白模视频当参考视频喂 Seedance 2.5(白模参考),提示词写「参考白模的站位、动作和运镜」",+ "feed the clay video to Seedance 2.5 as the reference (clay render reference), prompting “follow the clay figure's blocking, moves and camera”")],+ "feed": T("白模渲染视频 + 角色图", "clay render video + character image")}+ order = [ref, pose, depth, clay] if cartoon else [ref, depth, clay, pose]+ first = next(r for r in order if r["key"] == u["pick"]["key"])+ order = [first] + [r for r in order if r is not first]+ if u["live"]:+ order.append({"key": "shoot", "name": T("自己跳 / 找人跳", "Dance it yourself / cast a dancer"),+ "when": T("原片是实拍;照「拍摄」的机位和布光拍,跟着原曲练到卡点再拍",+ "the original is filmed; shoot with the setup under “Shoot”, rehearse to the original track until the hits land"),+ "tools": [T("要换成别的人或画风:拍好后用视频编辑模型换人 / 风格化,保留动作", "to change the person or look: swap or restyle the take with a video-editing model, keeping the moves")],+ "feed": T("自己拍的素材", "your own footage")})+ return order+++def pick(u: dict) -> dict:+ """The route to start from, decided by what this video shows: does the face carry the shot (only the source clip+ brings it across; depth, skeletons and clay keep the body alone) and is the background behind the dancer busy+ (a raw reference drags it, and passers-by, into the new picture). How far the new setting is from the old one+ is the user's call, so the report asks it next to this pick."""+ if u["face_matters"]:+ return {"key": "ref", "why": T("神态是看点:只有直接拿原片当参考,表情才会一起带过去,深度、骨骼和白模都只留身体",+ "the expression matters: only the source clip itself carries the face across; depth, skeletons and clay keep the body alone")+ + (T("。原背景杂乱:提示词写明不参考背景、场景用参考图给;还是带出原背景时,再改深度驱动 + 脸部特写参考图(Kling 3.0 可以绑脸),表情写进提示词",+ ". The background is busy: say in the prompt not to follow the background and give the setting as a reference image; if it still leaks, "+ "switch to a depth drive + a face close-up reference (Kling 3.0 can bind a face) and write the expression into the prompt")+ if u["backdrop"] == "busy" else "")}+ if u["backdrop"] == "busy":+ return {"key": "depth", "why": T("原背景杂乱、神态不是看点:直接参考容易把原背景和路人一起带过来,深度视频只留动作、空间和运镜",+ "busy background and the face is not the point: a raw reference tends to bring the old background and passers-by along; "+ "a depth video keeps only moves, space and camera")}+ return {"key": "ref", "why": T("原背景干净、神态不是看点:直接拿原片当参考视频就够,不用转深度或做白模",+ "clean background and the face is not the point: the source clip as the reference is enough, no depth or clay needed")+ if u["backdrop"] == "clean" else+ T("先直接拿原片当参考视频;背景杂不杂还没看图确认,杂的话改深度视频",+ "start with the source clip as the reference; whether the background is busy is not confirmed yet, and if it is, switch to a depth video")}+++def _prompts(u: dict) -> dict[str, str]:+ """Prompt templates per route, filled with this run's measured and seen facts; <> marks what the user decides."""+ move = MOVE_ZH[u["move"]]+ who = u["who"][0].get("name") if u["who"] else ""+ look = u["who"][0].get("look") if u["who"] else ""+ outfit = T("<你的角色穿什么,写具体>", "<what your character wears, specifically>")+ scene = u["scene"] or T("<场景>", "<setting>")+ frame = u["framing"]+ beat = T(",跟着 {b:.0f} BPM 的节拍", " on the {b:.0f} BPM beat", b=u["bpm"]) if u.get("bpm") else ""+ many = T("。多人:C 位用 @图片1,其余从左到右 @图片2、@图片3…,站位和原片一致",+ ". Several dancers: the centre one is @图片1, the rest left to right @图片2, @图片3…, in the same formation as the source") if u["movers"] >= 2 else ""+ return {+ "seedance": T("@视频1 只参考{m}动作、走位、运镜和节拍,不参考人物外观、服装和场景。@图片1 的角色一比一做出 @视频1 里{w}的全部动作{beat},"+ "动作幅度、朝向和在画面里的位置保持一致{many}。{f}。角色穿{o}。场景:{s}。",+ "Use @视频1 only for the {m} moves, blocking, camera and timing, not for the person's look, clothes or setting. The character in @图片1 "+ "performs every move of {w} in @视频1 one to one{beat}, with the same size of movement, facing and place in frame{many}. {f}. "+ "The character wears {o}. Setting: {s}.",+ m=move, w=who or T("原舞者", "the dancer"), beat=beat, many=many, f=frame, o=outfit, s=scene),+ "kling": T("(Kling 只写画面,不写动作){look},穿{o},{s}", "(Kling takes the picture only, not the moves) {look}, wearing {o}, {s}",+ look=look or T("<角色外观>", "<character look>"), o=outfit, s=scene),+ "depth": T("@视频1 是深度视频,是动作、节奏、空间和运镜的最高优先参考:动作不改,不加新的运镜。角色以 @图片1 为准,穿{o}。场景:{s}。{f}。",+ "@视频1 is a depth video and the top reference for moves, timing, space and camera: do not redesign the moves, do not add camera "+ "movement. The character follows @图片1, wearing {o}. Setting: {s}. {f}.", o=outfit, s=scene, f=frame),+ }+++def units(b: dict) -> list[dict]:+ """One drive unit per run of motion-led shots."""+ from .plan import framing_words++ lim = segment_limits()+ out = []+ for run in _runs(b):+ ids = {r["index"] for r in run}+ perfs = [move_of(r) or {} for r in run]+ kinds: dict[str, float] = {}+ for r, p in zip(run, perfs):+ kinds[p["move"]] = kinds.get(p["move"], 0.0) + r["duration"]+ fulls = [p.get("full_body") for p in perfs if p.get("full_body") is not None]+ who, scene = _cast_bits(b, ids)+ a, z = run[0]["start"], run[-1]["end"]+ dur = round(z - a, 3)+ u = {"id": f"M{len(out) + 1}", "kind": "drive", "shots": [r["index"] for r in run], "start": round(a, 3), "end": round(z, 3),+ "duration": dur, "move": max(kinds.items(), key=lambda kv: kv[1])[0],+ "movers": max([p.get("movers") or 1 for p in perfs] or [1]),+ "full_body": (all(fulls) if fulls else None),+ "backdrop": ("busy" if any(p.get("backdrop") == "busy" for p in perfs) else+ "clean" if any(p.get("backdrop") == "clean" for p in perfs) else None),+ "face_matters": any(p.get("face") and (p.get("key") or p.get("arc") or p.get("intensity") in ("mid", "high")) for p in perfs),+ "camera_moves": any((r.get("features") or {}).get("camera") in _MOVING for r in run),+ "live": any(r["base"]["label"] == "live_action" for r in run),+ "labels": list(dict.fromkeys(r["base"]["label"] for r in run)),+ "bpm": _bpm(b), "beats": len(_beats(b, a, z)),+ "segments_est": max(1, int(-(-dur // lim["max"]))),+ "framing": framing_words(run[0])[0], "who": [{k: c.get(k) for k in ("id", "name", "kind", "look")} for c in who],+ "scene": scene, "body": semi().join(dict.fromkeys(p.get("body") for p in perfs if p.get("body")))}+ u["pick"] = pick(u)+ u["routes"] = _routes(u)+ u["prompts"] = _prompts(u)+ out.append(u)+ return out+++def summary_bit(drive: list[dict]) -> str:+ n = sum(len(u["shots"]) for u in drive)+ s = sum(u["duration"] for u in drive)+ return T("{k} {n} 镜({s:.0f} 秒)→ {u} 段动作驱动", "{k} {n} shot{p} ({s:.0f} s) → {u} motion-drive unit{q}",+ k=join(dict.fromkeys(MOVE_ZH[u["move"]] for u in drive)), n=n, p="" if n == 1 else "s", s=s, u=len(drive), q="" if len(drive) == 1 else "s")+++def report_md(drive: list[dict], lim: dict | None = None) -> list[str]:+ """The "Motion drive" part of the remake plan."""+ if not drive:+ return []+ lim = lim or segment_limits()+ L = ["", T("### 动作驱动", "### Motion drive"), "",+ T("这些镜头的看点是动作本身。只给首尾帧,中间的动作全靠模型猜,编舞和卡点会丢;要用原片这段动作去驱动新画面。",+ "The moves are the point of these shots. First and last frames pin only two moments and leave the choreography to the model, "+ "so the dance and the hits get lost; drive the new picture from the source motion instead."), "",+ T("1. **出驱动视频**:`rea-video drive <报告目录>`:擦掉字幕和贴纸(不擦会被当成画面学进去),在动作停顿、靠近拍点的地方切成 {p:.0f}–{mx:.0f} 秒的短段"+ "(短段手脚和转身更稳),每段一个 `drive/seg_XX.mp4`;要走深度路线时加 `--depth`",+ "1. **Make the drive clips**: `rea-video drive <report folder>` erases subtitles and stickers (left in, they are learned as part of the picture) and cuts "+ "the motion into {p:.0f}–{mx:.0f} s segments at calm moments near a beat (hands, feet and turns hold up better in short segments), one "+ "`drive/seg_XX.mp4` each; add `--depth` when going the depth route", p=lim["prefer"], mx=lim["max"]),+ T("2. **角色图**:同一套衣服出一张角色设定图(正面、正侧面、背面全身 + 脸部特写),每段都用这一张;Kling 用正面全身图,景别和朝向对齐 `drive/seg_XX_first.jpg`",+ "2. **Character image**: one character sheet in one outfit (front, strict side and back full body + a face close-up), the same one for every "+ "segment; for Kling use the front full-body image, matched to the framing and facing of `drive/seg_XX_first.jpg`"),+ T("3. **逐段生成**:多数情况直接拿驱动视频当参考就行;原背景杂乱、新场景差很多才转深度或做白模,神态要复刻就留在直接参考。每个单元下面按这几点给了建议和提示词;服装要在提示词里写明,不写会变回原舞者的衣服",+ "3. **Generate segment by segment**: usually the drive clip as the reference is all it takes; go to depth or clay only when the background is busy or the new "+ "setting is far off, and stay with the direct reference when the expression must come across. Each unit below gives the pick and the prompts; name the "+ "outfit in the prompt, or it drifts back to the dancer's clothes"),+ T("4. **接回去**:生成结果写进 `drive/results.json`(`{\"seg_01\": \"绝对路径\"}`),跑 `rea-video drive <报告目录> --join` 按段拼好、按镜头切开写进 "+ "`remake/mine.json`,再 `rea-video remake <报告目录>` 出和原片并排的对比片,对着原曲看卡点",+ "4. **Put it back**: list the results in `drive/results.json` (`{\"seg_01\": \"absolute path\"}`), run `rea-video drive <report folder> --join` to join "+ "the segments, cut them per shot and write `remake/mine.json`, then `rea-video remake <report folder>` for the side-by-side, and check the hits against the original track"),+ T("5. **检查**:手指和脚(快动作、转身处最容易坏)、脸有没有变、衣服有没有变回去、段与段接缝;哪段坏就把那段再切短重做,一次只改一样",+ "5. **Check**: fingers and feet (they break first on fast moves and turns), whether the face drifts, whether the clothes revert, the seams between "+ "segments; redo a bad segment shorter, changing one thing at a time"), "",+ T("| 单元 | 镜头 | 时间 | 动作 | 人数 | 全身入画 | 机位 | 约几段 |", "| Unit | Shots | Time | Moves | People | Full body | Camera | Segments |"),+ "|---|---|---|---|---|---|---|---|"]+ yes_no = {True: T("是", "yes"), False: T("否", "no"), None: "—"}+ for u in drive:+ L.append(f"| {u['id']} | {shot_ids(u['shots'])} | {u['start']:.1f}–{u['end']:.1f}s | {MOVE_ZH[u['move']]} | {u['movers']} | "+ f"{yes_no[u['full_body']]} | {T('有运镜', 'moving') if u['camera_moves'] else T('固定', 'fixed')}"+ f"{T(',{n} 处剪辑', ', {n} cuts', n=len(u['shots']) - 1) if len(u['shots']) > 1 else ''} | {u['segments_est']} |")+ for u in drive:+ facts = [T("{d:.1f} 秒", "{d:.1f} s", d=u["duration"])]+ if u.get("bpm"):+ facts.append(T("{b:.0f} BPM,段内 {n} 拍", "{b:.0f} BPM, {n} beats", b=u["bpm"], n=u["beats"]))+ if u.get("framing"):+ facts.append(u["framing"])+ L += ["", "<details><summary>" + T("{id} · 镜头 {sh} · {m} · {d:.1f}s", "{id} · shots {sh} · {m} · {d:.1f}s",+ id=u["id"], sh=shot_ids(u["shots"]), m=MOVE_ZH[u["move"]], d=u["duration"]) + "</summary>", "",+ T("- 原片:", "- Source: ") + semi().join(facts)]+ if u.get("body"):+ L.append(T("- 动作:{b}", "- Moves: {b}", b=u["body"]))+ bd = {"clean": T("干净", "clean"), "busy": T("杂乱", "busy"), None: T("待看图", "to check")}[u["backdrop"]]+ L += ["", T("怎么选驱动(先看这三点):", "Choosing the drive (three questions first):"), "",+ T("| 看什么 | 这条原片 | 怎么选 |", "| Question | This video | Choice |"), "|---|---|---|",+ T("| 原片背景杂不杂 | {b} | 干净:直接拿原片当参考视频;杂乱:转深度视频 |", "| Is the background busy | {b} | clean: the source clip as reference; busy: a depth video |", b=bd),+ T("| 神态要不要复刻 | {f} | 要:直接参考原片(深度、骨骼、白模都会丢表情) |", "| Must the expression come across | {f} | yes: the source clip itself (depth, skeleton and clay lose the face) |",+ f=T("要,表情是看点", "yes, it is part of the point") if u["face_matters"] else T("不是看点", "not the point")),+ T("| 新场景和原片差多少 | 你来定 | 差不多:直接参考;差很多:深度视频;连空间、机位都换:白模 |",+ "| How far is the new setting | your call | close: the source clip; far: a depth video; new space and camera too: clay |"),+ T("| 新角色体型 | 你来定 | 和原舞者差很多(Q 版、动物):骨骼视频 |", "| The new character's build | your call | far from the dancer (chibi, animal): a skeleton video |"),+ "", T("**这条先用:{n}**。{w}", "**Start with: {n}**. {w}", n=u["routes"][0]["name"], w=u["pick"]["why"]),+ "", T("| 路线 | 什么时候用 | 工具 | 要喂的 |", "| Route | When | Tools | Feed |"), "|---|---|---|---|"]+ for r in u["routes"]:+ L.append(f"| {r['name']} | {r['when']} | {'<br>'.join(r['tools'])} | {r['feed']} |")+ L += ["", T("Seedance 2.5 参考视频提示词:", "Seedance 2.5 reference-video prompt:"), "", "```text", u["prompts"]["seedance"], "```",+ "", T("Kling 动作控制(人物朝向选「跟随视频」):", "Kling Motion Control (character orientation: match the video):"), "", "```text", u["prompts"]["kling"], "```",+ "", T("深度视频驱动:", "Depth-video drive:"), "", "```text", u["prompts"]["depth"], "```", "", "</details>"]+ return Ldiff --git a/rea_video/drive.py b/rea_video/drive.pynew file mode 100644index 0000000..a335c7e--- /dev/null+++ b/rea_video/drive.py@@ -0,0 +1,405 @@+"""Drive clips for motion-led shots (dance, fights, workouts): the source motion, cleaned and cut, ready to feed a+motion-transfer or reference-video model, and the way back onto the original timeline.++ drive(out) for each motion-drive unit of the production plan (or the shots given):+ - erase the post-production text and stickers frame by frame (a model learns them as part of the picture)+ - cut the motion into short segments at calm moments near a beat, or at the source's own cuts+ (hands, feet and turns hold up better in short segments; the seams fall where the dancer is still)+ - write drive/seg_XX.mp4 (no sound), seg_XX_first.jpg (frame the character image is matched to),+ seg_XX_music.wav (the track under it), optional seg_XX_depth.mp4, segments.jpg, drive.json, README.md+ join(out) the generated segments (drive/results.json: {"seg_01": path}) fitted to their lengths, joined, cut per+ shot and written into remake/mine.json, so `rea-video remake` places them on the original timeline++Calm moments are measured, not guessed: the mean frame-to-frame change (overlay boxes masked out) at 12 fps, smoothed+over a quarter second; a cut is scored by that motion, the distance to the nearest beat and how far it lands from+the preferred segment length.+"""+from __future__ import annotations++import subprocess+from pathlib import Path++import cv2+import numpy as np++from . import dance+from .i18n import T, semi, shot_ids+from .media import iter_frames, scaled_size, video_info+from .util import LOG, read_json, write_image, write_json++CURVE_FPS = 12.0+CURVE_W = 160+PAD = 0.012 # share of the frame added around an overlay box before erasing+SUB_HOLD = 0.8 # seconds a subtitle may outlive its OCR end time+T_PAD = 0.25 # seconds added before / after an overlay: OCR samples a few times a second, so its in / out times are coarse+++def _ff(args: list[str]) -> None:+ subprocess.run(["ffmpeg", "-v", "error", "-y", "-nostdin", *args], check=True)+++def overlays(b: dict) -> list[dict]:+ """Post-production boxes to erase: subtitles, styled text, titles, labels and stickers laid on top+ (text that is part of the picture and stickers a reader marked as in the picture stay)."""+ from .classify import _same_words++ pk = b.get("packaging") or {}+ out = []+ for c in pk.get("text_cues") or []:+ if c.get("part_of_picture") or c.get("kind") == "scene" or not c.get("bbox"):+ continue+ mid = (c["t0"] + c["t1"]) / 2+ r = next((r for r in b.get("shots", []) if r["start"] <= mid < r["end"]), None) or {}+ said = (r.get("vlm") or {}).get("overlay_text")+ said = said if isinstance(said, list) else (r.get("review") or {}).get("overlay_text")+ if isinstance(said, list) and not any(_same_words(c.get("text") or "", str(o)) for o in said):+ continue # a reader listed this shot's post-production words; this one is text in the scene (a phone screen, a sign)+ out.append({"t0": float(c["t0"]), "t1": float(c["t1"]), "bbox": c["bbox"], "what": c.get("kind_zh") or c.get("kind") or "text",+ "sub": c.get("kind") == "subtitle"})+ # OCR often loses a subtitle line a little before it really goes; subtitles run back to back, so hold each one+ # until the next starts (at most SUB_HOLD)+ subs = [x for x in out if x["sub"]]++ def cy(x: dict) -> float:+ return x["bbox"][1] + x["bbox"][3] / 2++ for x in subs:+ later = [y["t0"] for y in subs if y["t0"] > x["t0"] + 0.05 and abs(cy(y) - cy(x)) < 0.06] # the next line in the same band+ x["t1"] = min(x["t1"] + SUB_HOLD, max(x["t1"], min(later))) if later else x["t1"] + SUB_HOLD+ for s in pk.get("stickers") or []:+ if s.get("in_picture") or s.get("is_overlay") is False or not s.get("bbox"):+ continue+ out.append({"t0": float(s["t0"]), "t1": float(s["t1"]), "bbox": s["bbox"], "what": s.get("kind_zh") or "sticker"})+ return out+++def _mask(boxes: list[dict], t: float, w: int, h: int) -> np.ndarray | None:+ on = [x for x in boxes if x["t0"] - T_PAD <= t <= x["t1"] + T_PAD]+ if not on:+ return None+ m = np.zeros((h, w), np.uint8)+ for x in on:+ bx, by, bw, bh = x["bbox"]+ x0, y0 = int(max(0.0, bx - PAD) * w), int(max(0.0, by - PAD) * h)+ x1, y1 = int(min(1.0, bx + bw + PAD) * w), int(min(1.0, by + bh + PAD) * h)+ m[y0:y1, x0:x1] = 255+ return m+++def erase(frame: np.ndarray, mask: np.ndarray | None) -> np.ndarray:+ """Fill the overlay boxes from their surroundings. Done at half size and pasted back: a drive clip needs the+ text gone, not a perfect fill, and full-size inpainting of a subtitle band is slow."""+ if mask is None or not mask.any():+ return frame+ h, w = frame.shape[:2]+ small, sm = cv2.resize(frame, (w // 2, h // 2), interpolation=cv2.INTER_AREA), cv2.resize(mask, (w // 2, h // 2), interpolation=cv2.INTER_NEAREST)+ filled = cv2.resize(cv2.inpaint(small, sm, 3, cv2.INPAINT_TELEA), (w, h), interpolation=cv2.INTER_LINEAR)+ out = frame.copy()+ out[mask > 0] = filled[mask > 0]+ return out+++def motion_curve(path: str | Path, info, a: float, z: float, boxes: list[dict]) -> tuple[np.ndarray, np.ndarray]:+ """(times, motion) at CURVE_FPS: mean absolute change from the previous frame, overlay boxes left out."""+ prev, ts, es = None, [], []+ for i, f in enumerate(iter_frames(path, info, CURVE_W, start=a, duration=z - a, gray=True, fps=CURVE_FPS)):+ t = a + i / CURVE_FPS+ g = f.astype(np.float32)+ m = _mask(boxes, t, g.shape[1], g.shape[0])+ keep = np.ones_like(g, bool) if m is None else m == 0+ if prev is not None:+ ts.append(t)+ es.append(float(np.abs(g - prev)[keep].mean()) if keep.any() else 0.0)+ prev = g+ e = np.array(es, float)+ if len(e) >= 3:+ e = np.convolve(e, np.ones(3) / 3, mode="same")+ return np.array(ts, float), e+++def cut_points(a: float, z: float, ts: np.ndarray, es: np.ndarray, beats: list[float], shot_cuts: list[float],+ lim: dict, bpm: float | None = None) -> list[tuple[float, str]]:+ """Where to cut [a, z] into segments: [(time, why)]. The count comes first (as few as the maximum allows, about+ the preferred length each), then each cut is searched around its even split: the source's own cuts are free+ seams; inside a take the calmest moment near a beat wins."""+ dur = z - a+ n = max(int(np.ceil(dur / lim["max"] - 1e-6)), int(round(dur / lim["prefer"])), 1)+ if n <= 1:+ return []+ step = dur / n+ scale = float(np.percentile(es, 90)) if len(es) else 1.0+ scale = scale or 1.0+ beat_gap = 60.0 / bpm if bpm else 0.5+ bs = np.array(beats, float)+ out: list[tuple[float, str]] = []+ pos = a+ for k in range(1, n):+ target = a + k * step+ left = n - k # segments still to come after this cut+ lo = max(pos + lim["min"], target - 0.3 * step, z - left * lim["max"])+ hi = min(pos + lim["max"], target + 0.3 * step, z - left * lim["min"])+ if hi < lo:+ lo = hi = target+ best: tuple[float, float, str] | None = None+ for c in shot_cuts:+ if lo <= c <= hi:+ sc = 0.1 + 0.3 * abs(c - target) / step+ if best is None or sc < best[0]:+ best = (sc, c, "cut")+ for t, e in zip(ts, es):+ if lo <= t <= hi:+ bd = min(1.0, float(np.min(np.abs(bs - t))) / beat_gap) if len(bs) else 0.5+ sc = float(e) / scale + 0.4 * bd + 0.3 * abs(t - target) / step+ if best is None or sc < best[0]:+ best = (sc, float(t), "beat" if bd < 0.25 else "calm")+ cut = best[1] if best else target+ out.append((round(cut, 3), best[2] if best else "calm"))+ pos = cut+ return out+++_WHY = {"cut": T("原片切点", "source cut"), "beat": T("动作停顿,落在拍点上", "calm moment on a beat"),+ "calm": T("动作停顿", "calm moment"), "start": T("单元开头", "unit start")}+++def _units(b: dict, shots: list[int] | None) -> list[dict]:+ if shots:+ want = set(shots)+ runs, cur = [], []+ for r in b["shots"]:+ if r["index"] in want and (not cur or abs(cur[-1]["end"] - r["start"]) < 0.05):+ cur.append(r)+ continue+ if cur:+ runs.append(cur)+ cur = [r] if r["index"] in want else []+ if cur:+ runs.append(cur)+ return [{"id": f"M{k}", "shots": [r["index"] for r in run], "start": run[0]["start"], "end": run[-1]["end"]} for k, run in enumerate(runs, 1)]+ return (b.get("production_plan") or {}).get("drive") or []+++def _depth_model():+ """Depth Anything V2 Small through transformers, when installed; None otherwise (the README then gives the+ Video Depth Anything command, which is the better tool: it is made for video and does not flicker)."""+ try:+ import torch # noqa: F401+ from transformers import pipeline+ except ImportError:+ return None+ try:+ return pipeline("depth-estimation", model="depth-anything/Depth-Anything-V2-Small-hf")+ except Exception as e: # network, weights, device+ LOG.warning("depth model unavailable: %s", e)+ return None+++def _write_depth(model, frames: list[np.ndarray], path: Path, fps: float) -> None:+ from PIL import Image++ raw = [np.asarray(model(Image.fromarray(cv2.cvtColor(f, cv2.COLOR_BGR2RGB)))["predicted_depth"].squeeze(), np.float32) for f in frames]+ lo, hi = np.percentile(np.stack(raw), [2, 98]) # one range for the whole clip: per-frame ranges flicker+ h, w = frames[0].shape[:2]+ prev = None+ enc = _encoder(path, w, h, fps)+ for d in raw:+ d = np.clip((d - lo) / max(hi - lo, 1e-6), 0, 1)+ prev = d if prev is None else 0.6 * d + 0.4 * prev+ g = cv2.resize((prev * 255).astype(np.uint8), (w, h), interpolation=cv2.INTER_LINEAR)+ enc.stdin.write(cv2.cvtColor(g, cv2.COLOR_GRAY2BGR).tobytes())+ enc.stdin.close()+ enc.wait()+++def _encoder(path: Path, w: int, h: int, fps: float):+ return subprocess.Popen(["ffmpeg", "-v", "error", "-y", "-f", "rawvideo", "-pix_fmt", "bgr24", "-s", f"{w}x{h}", "-r", f"{fps:.4f}",+ "-i", "-", "-an", "-c:v", "libx264", "-pix_fmt", "yuv420p", "-crf", "18", str(path)], stdin=subprocess.PIPE)+++def _sheet(rows: list[list[np.ndarray]], labels: list[str], path: Path) -> None:+ H = 220+ lines = []+ for frames, lab in zip(rows, labels):+ thumbs = [cv2.resize(f, (max(1, int(f.shape[1] * H / f.shape[0])), H)) for f in frames]+ row = np.concatenate(thumbs, axis=1)+ cv2.putText(row, lab, (8, 26), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 0), 4, cv2.LINE_AA)+ cv2.putText(row, lab, (8, 26), cv2.FONT_HERSHEY_SIMPLEX, 0.7, (255, 255, 255), 1, cv2.LINE_AA)+ lines.append(row)+ w = max(r.shape[1] for r in lines)+ write_image(path, np.concatenate([np.pad(r, ((0, 0), (0, w - r.shape[1]), (0, 0))) for r in lines], axis=0))+++def drive(out: Path, shots: list[int] | None = None, depth: bool = False, clean: bool = True,+ prefer: float | None = None, max_s: float | None = None) -> dict:+ b = read_json(out / "breakdown.json")+ units = _units(b, shots)+ if not units:+ raise ValueError(T("没有动作驱动单元:先在看图复核里给舞蹈 / 动作镜头填 performance.move 并 apply-review,或用 --shots 指定镜头",+ "no motion-drive units: mark the dance / action shots with performance.move in the review and apply it, or pass --shots"))+ src = Path(b["source"]["path"])+ info = video_info(src)+ lim = dance.segment_limits()+ if prefer:+ lim["prefer"] = float(prefer)+ if max_s:+ lim["max"] = float(max_s)+ lim["prefer"] = min(lim["prefer"], lim["max"])+ boxes = overlays(b) if clean else []+ beats = ((b.get("audio") or {}).get("music") or {}).get("beats") or []+ bpm = dance._bpm(b)+ ddir = out / "drive"+ ddir.mkdir(parents=True, exist_ok=True)+ for old in ddir.glob("seg_*"): # a rerun may cut differently: no stale segments next to the new ones+ old.unlink()+ music = out / "stems" / "music.wav"+ model = _depth_model() if depth else None+ w, h = scaled_size(info, info.width or 1920)+ fps = info.fps if 0 < info.fps <= 60 else 30.0+ by_shot = {r["index"]: r for r in b["shots"]}+ segs, sheet_rows, sheet_labels = [], [], []+ for u in units:+ a, z = float(u["start"]), float(u["end"])+ shot_cuts = [by_shot[i]["start"] for i in u["shots"][1:] if i in by_shot]+ ts, es = motion_curve(src, info, a, z, boxes)+ cuts = cut_points(a, z, ts, es, beats, shot_cuts, lim, bpm)+ bounds = [(a, "start")] + cuts + [(z, "")]+ for (s0, why), (s1, _) in zip(bounds, bounds[1:]):+ k = len(segs) + 1+ name = f"seg_{k:02d}"+ inside = [c for c in shot_cuts if s0 + 0.05 < c < s1 - 0.05]+ erased: list[str] = []+ frames, keep = [], []+ enc = _encoder(ddir / f"{name}.mp4", w, h, fps)+ for i, f in enumerate(iter_frames(src, info, w, start=s0, duration=s1 - s0)):+ t = s0 + i / fps+ m = _mask(boxes, t, f.shape[1], f.shape[0]) if boxes else None+ if m is not None:+ erased += [w for w in dict.fromkeys(x["what"] for x in boxes if x["t0"] - T_PAD <= t <= x["t1"] + T_PAD) if w not in erased]+ f = erase(f, m)+ enc.stdin.write(f.tobytes())+ if model is not None:+ frames.append(f)+ if i == 0:+ write_image(ddir / f"{name}_first.jpg", f)+ if i % max(1, int(fps)) == 0: # one frame a second for the contact sheet+ keep.append(f)+ enc.stdin.close()+ enc.wait()+ files = {"clip": f"drive/{name}.mp4", "first": f"drive/{name}_first.jpg"}+ if music.is_file() or info.has_audio:+ _ff(["-ss", f"{s0:.3f}", "-i", str(music if music.is_file() else src), "-t", f"{s1 - s0:.3f}", "-vn", "-ac", "2", str(ddir / f"{name}_music.wav")])+ files["music"] = f"drive/{name}_music.wav"+ if model is not None and frames:+ _write_depth(model, frames, ddir / f"{name}_depth.mp4", fps)+ files["depth"] = f"drive/{name}_depth.mp4"+ if keep:+ sheet_rows.append([keep[0], keep[len(keep) // 2], keep[-1]])+ sheet_labels.append(f"{name} {s0:.1f}-{s1:.1f}s")+ segs.append({"id": name, "unit": u["id"], "start": round(s0, 3), "end": round(s1, 3), "duration": round(s1 - s0, 3),+ "shots": [i for i in u["shots"] if by_shot.get(i) and by_shot[i]["start"] < s1 - 0.05 and by_shot[i]["end"] > s0 + 0.05],+ "cut_in": why, "cuts_inside": len(inside), "beats": sum(1 for t in beats if s0 <= t < s1),+ "overlays_erased": erased, "files": files})+ if sheet_rows:+ _sheet(sheet_rows, sheet_labels, ddir / "segments.jpg")+ res = {"video": str(src), "limits": lim, "depth": "written" if model is not None else ("missing" if depth else "off"),+ "units": [u["id"] for u in units], "segments": segs}+ write_json(ddir / "drive.json", res)+ (ddir / "README.md").write_text("\n".join(readme(res, (b.get("production_plan") or {}).get("drive") or [])) + "\n", encoding="utf-8")+ return res+++def readme(res: dict, plan_units: list[dict]) -> list[str]:+ L = [T("# 动作驱动视频", "# Motion drive clips"), "",+ T("每段是原片的一截动作,字幕和贴纸已经擦掉,没有声音。拿去喂动作迁移或参考视频模型,每段都用同一张角色图。",+ "Each segment is a stretch of the source motion with subtitles and stickers erased and no sound. Feed it to a motion-transfer or "+ "reference-video model, with the same character image for every segment."), "",+ T("先打开 `segments.jpg` 看一遍:每段头到脚是不是都在画面里、有没有擦坏的地方。字幕正好压着手脚时,擦过的地方会糊,"+ "这时最好找到没有字幕的原片(舞蹈多半有原版)再跑一次。",+ "Look at `segments.jpg` first: is the whole body in frame in every segment, and did the erasing leave anything broken. Where a "+ "subtitle sits over hands or feet the erased patch blurs them; then find a copy without subtitles (most dances have an original upload) and run it again."), "",+ T("| 段 | 原片时间 | 时长 | 怎么切的 | 段内剪辑 | 拍数 | 擦掉的 | 镜头 |", "| Segment | Source time | Length | Cut at | Cuts inside | Beats | Erased | Shots |"),+ "|---|---|---|---|---|---|---|---|"]+ for s in res["segments"]:+ L.append(f"| `{s['id']}` | {s['start']:.1f}–{s['end']:.1f}s | {s['duration']:.1f}s | {_WHY.get(s['cut_in'], s['cut_in'])} | "+ f"{s['cuts_inside'] or '—'} | {s['beats'] or '—'} | {'、'.join(s['overlays_erased']) or '—'} | {shot_ids(s['shots'])} |")+ short = [s["id"] for s in res["segments"] if s["duration"] < 3]+ cut = [s["id"] for s in res["segments"] if s["cuts_inside"]]+ notes = []+ if cut:+ notes.append(T("{s} 段内有原片剪辑:Kling 动作控制要一镜到底,这几段用 Seedance 2.5 全能参考", "{s} contain source cuts: Kling Motion Control needs a single take, use Seedance 2.5 omni-reference for these", s="、".join(cut)))+ if short:+ notes.append(T("{s} 短于 3 秒:Kling 不收,前后多带一点再生成,或并进相邻的段", "{s} are under 3 s: Kling refuses them; extend them a little or merge with a neighbour", s="、".join(short)))+ if res["depth"] == "missing":+ notes.append(T("没装深度模型(transformers + torch),这次没出深度视频。更好的做法是用 Video Depth Anything 逐段跑:"+ "`python3 run.py --input_video drive/seg_01.mp4 --output_dir drive --encoder vits --grayscale`(Small 版可商用)",+ "No depth model installed (transformers + torch), so no depth videos this time. Better: run Video Depth Anything per segment: "+ "`python3 run.py --input_video drive/seg_01.mp4 --output_dir drive --encoder vits --grayscale` (the Small model allows commercial use)"))+ if notes:+ L += [""] + [f"- {n}" for n in notes]+ for u in plan_units:+ if u["id"] not in res["units"]:+ continue+ L += ["", f"## {u['id']}", "", T("Seedance 2.5(@视频1 = 驱动视频或深度视频,@图片1 = 角色图):", "Seedance 2.5 (@视频1 = drive or depth video, @图片1 = character image):"),+ "", "```text", u["prompts"]["seedance"], "```", "", T("Kling 动作控制(人物朝向选「跟随视频」):", "Kling Motion Control (orientation: match the video):"),+ "", "```text", u["prompts"]["kling"], "```", "", T("深度视频驱动:", "Depth-video drive:"), "", "```text", u["prompts"]["depth"], "```"]+ L += ["", T("## 接回原时间线", "## Back onto the timeline"), "",+ T("生成好的每段写进 `drive/results.json`:`{\"seg_01\": \"/绝对路径/seg_01.mp4\", ...}`,再跑 `rea-video drive <报告目录> --join`,"+ "然后 `rea-video remake <报告目录>`。", "List each generated segment in `drive/results.json`: `{\"seg_01\": \"/absolute/path/seg_01.mp4\", ...}`, run "+ "`rea-video drive <report folder> --join`, then `rea-video remake <report folder>`.")]+ return L+++def join(out: Path, results: Path | None = None) -> dict:+ """Generated segments -> per-shot clips in remake/mine.json. A shot is filled only when every segment over it is in."""+ from .remake import _fit_clip, _original_segment++ b = read_json(out / "breakdown.json")+ ddir = out / "drive"+ spec = read_json(ddir / "drive.json")+ got = read_json(results or ddir / "results.json")+ got = got.get("results", got) if isinstance(got, dict) else {}+ paths = {k: Path(v["video"] if isinstance(v, dict) else v) for k, v in got.items() if v}+ src = b["source"]+ w, h = (src["height"], src["width"]) if src.get("rotation") in (90, 270) else (src["width"], src["height"])+ w, h = w - w % 2, h - h % 2+ fps = float(src["fps"]) if src.get("fps") and src["fps"] <= 60 else 30.0+ jdir = ddir / "joined"+ jdir.mkdir(parents=True, exist_ok=True)+ blocks, cur = [], []+ for s in spec["segments"]:+ p = paths.get(s["id"])+ ok = p is not None and p.is_file()+ if ok and cur and cur[-1]["unit"] == s["unit"] and abs(cur[-1]["end"] - s["start"]) < 1e-3:+ cur.append(s)+ continue+ if cur:+ blocks.append(cur)+ cur = [s] if ok else []+ if cur:+ blocks.append(cur)+ mine_p = out / "remake" / "mine.json"+ mine = read_json(mine_p) if mine_p.is_file() else {}+ res = mine.setdefault("results", {})+ filled, missing = [], [s["id"] for s in spec["segments"] if not (paths.get(s["id"]) and paths[s["id"]].is_file())]+ for k, blk in enumerate(blocks, 1):+ fitted = []+ for s in blk:+ f = jdir / f"{s['id']}_fit.mp4"+ _fit_clip(paths[s["id"]], f, s["duration"], (w, h), fps)+ fitted.append(f)+ lst = jdir / f"block_{k:02d}.txt"+ lst.write_text("".join(f"file '{f.resolve()}'\n" for f in fitted), encoding="utf-8")+ whole = jdir / f"block_{k:02d}.mp4"+ _ff(["-f", "concat", "-safe", "0", "-i", str(lst), "-c", "copy", str(whole)])+ a, z = blk[0]["start"], blk[-1]["end"]+ for r in b["shots"]:+ if r["start"] >= a - 1e-3 and r["end"] <= z + 1e-3:+ clip = jdir / f"shot_{int(r['index']):03d}.mp4"+ _original_segment(whole, clip, r["start"] - a, r["duration"], (w, h), fps)+ res[str(r["index"])] = {"video": str(clip.resolve())}+ filled.append(r["index"])+ mine_p.parent.mkdir(parents=True, exist_ok=True)+ write_json(mine_p, mine)+ return {"filled_shots": filled, "missing_segments": missing, "mine": str(mine_p),+ "next": T("跑 `rea-video remake {o}` 出成片和对比片", "run `rea-video remake {o}` for the cut and the side-by-side", o=out)+ + (semi() + T("还缺 {m}", "still missing {m}", m="、".join(missing)) if missing else "")}diff --git a/rea_video/performance.py b/rea_video/performance.pyindex bc7c681..47428ae 100644--- a/rea_video/performance.py+++ b/rea_video/performance.py@@ -31,6 +31,10 @@ GUIDE = """画面里有人物、动物、卡通角色或数字人在表演(脸- arc:镜头里情绪有变化时按秒写,t 是相对镜头开头的秒:[{"t": 0.0, "state": "这一刻看得见的表情和动作"}];没变化写 []- voice:画面里的角色在这一镜开口(说话、笑、叹气)时,按听到的写语气、语速、音量、停顿("压低声音,语速慢,句尾带笑");听不到声音时只写口型看得出的(大笑、喊),语气语速不猜;画外旁白或没人开口留空- key:true = 表演是这一镜的看点(反应镜头、情绪爆发、反转时的表情),复刻时要专门保证+- move:只有大幅度的全身动作本身就是看点时才填(dance 舞蹈 / fight 打斗 / sport 健身运动),复刻会改用原片当动作驱动。这些都留空:带货、口播、讲解里的手势和展示商品,试穿转身、变装,走路、拿东西;全程唱歌或说话、身体只是小幅度动(点头、摆手、轻晃)的也留空,对口型 / 数字人就能做+- movers:move 不为空时,画面里同时在做这套动作的人数(整数)+- full_body:move 不为空时,做动作的人头到脚是不是整个都在画面里(true / false),手或脚经常出画就是 false+- backdrop:move 不为空时,人背后的背景:clean(纯色、简单室内、干净的墙或天空)或 busy(街道、人群、杂物多、有别的人在动)- en:把 face、body、arc 合成一句英文,只写看得见的动作,不写情绪词("eyes slightly red, corners of the mouth pressed down; at 1.5s she looks up"),给英文提示词用;上面几项已经是英文时留空"""@@ -45,6 +49,34 @@ def _txt(v, n: int = 160) -> str:return " ".join(str(v or "").split())[:n] if isinstance(v, (str, int, float)) else ""+MOVES = ("dance", "fight", "sport")+_MOVE_ALIASES = {"舞蹈": "dance", "跳舞": "dance", "舞": "dance", "打斗": "fight", "武打": "fight", "格斗": "fight", "功夫": "fight",+ "健身": "sport", "运动": "sport", "体育": "sport"}+++def _move(v: dict) -> dict:+ """move / movers / full_body / backdrop: only kept when the motion itself is the point of the shot."""+ m = str(v.get("move") or "").strip().lower()+ m = m if m in MOVES else _MOVE_ALIASES.get(m, "")+ if not m:+ return {}+ out: dict = {"move": m}+ try:+ n = int(v.get("movers") or 0)+ if n > 0:+ out["movers"] = min(n, 50)+ except (TypeError, ValueError):+ pass+ fb = v.get("full_body")+ if isinstance(fb, bool) or str(fb).lower() in ("true", "false"):+ out["full_body"] = fb is True or str(fb).lower() == "true"+ bd = str(v.get("backdrop") or "").strip().lower()+ bd = {"干净": "clean", "简单": "clean", "杂乱": "busy", "复杂": "busy"}.get(bd, bd)+ if bd in ("clean", "busy"):+ out["backdrop"] = bd+ return out++def clean(v) -> dict | None:"""One answer to stored form; None when it says nothing about acting."""if not isinstance(v, dict):@@ -60,8 +92,9 @@ def clean(v) -> dict | None:out = {"who": _txt(v.get("who"), 30), "emotion": _txt(v.get("emotion"), 20), "intensity": intensity_code(v.get("intensity")),"face": _txt(v.get("face")), "body": _txt(v.get("body")), "arc": sorted(arc, key=lambda a: a["t"])[:6],"voice": _txt(v.get("voice"), 100), "key": v.get("key") is True or str(v.get("key")).lower() == "true",+ **_move(v),"en": _txt(v.get("en"), 240) if _txt(v.get("en"), 240).isascii() else ""}- if not any(out[k] for k in ("emotion", "face", "body", "arc", "voice")):+ if not any(out.get(k) for k in ("emotion", "face", "body", "arc", "voice", "move")):return Nonereturn out@@ -125,8 +158,8 @@ def image_line(p: dict | None) -> str:FILMED = ("live_action", "stop_motion", "film_footage") # acted in front of a camera: the cues direct the actor-ROUTE_ZH = LangDict({"voice": "先配音再驱动", "transfer": "首帧 + 表演迁移", "first_frame": "首帧定表情", "shoot": "演员照着演"},- en={"voice": "voice first, then drive", "transfer": "first frame + performance transfer",+ROUTE_ZH = LangDict({"drive": "原片当动作驱动", "voice": "先配音再驱动", "transfer": "首帧 + 表演迁移", "first_frame": "首帧定表情", "shoot": "演员照着演"},+ en={"drive": "source clip drives the motion", "voice": "voice first, then drive", "transfer": "first frame + performance transfer","first_frame": "expression in the first frame", "shoot": "actor plays it"})@@ -146,6 +179,9 @@ def route_kind(p: dict | None, label: str = "") -> str:def route_text(kind: str) -> str:return {+ "drive": T("动作是这一镜的看点,文字写不出来:用原片这一段当动作驱动(去掉字幕后的驱动视频 + 角色图),步骤见「动作驱动」;表情写进角色图和提示词",+ "The motion is the point of the shot and words cannot carry it: drive it from this stretch of the source (the drive clip with "+ "captions removed + a character image), steps under “Motion drive”; the expression goes in the character image and the prompt"),"voice": T("有台词:先按语气做配音(TTS 只在情绪转折处加语气标签,或真人录),再用音频驱动的模型出口型和表情""(Kling Avatar、OmniHuman);用能直接出声的视频模型时,把台词和语气一起写进提示词","Speaking: make the voice with its delivery first (TTS with tone tags only where the emotion turns, or a real recording), "@@ -190,7 +226,9 @@ def table(b: dict) -> tuple[list[list], list[str]]:if p.get("key"):emo += T(" ★看点", " ★key")moves = semi().join(x for x in [p.get("body") or ""] + [f"{a['t']:.1f}s {a['state']}" for a in p.get("arc") or []] if x)- kind = route_kind(p, (r.get("base") or {}).get("label", ""))+ from .dance import move_of++ kind = "drive" if move_of(r) else route_kind(p, (r.get("base") or {}).get("label", ""))if kind not in kinds:kinds.append(kind)rows.append([f"#{r['index']}", p.get("who") or "—", emo, p.get("face") or "—", moves or "—", p.get("voice") or "—", ROUTE_ZH[kind]])diff --git a/rea_video/pipeline.py b/rea_video/pipeline.pyindex 052a5af..ee87a27 100644--- a/rea_video/pipeline.py+++ b/rea_video/pipeline.py@@ -620,6 +620,9 @@ def finalize(breakdown: dict, out: Path, engine: str | None = None) -> dict:"""(Re)classify every shot from stored features + VLM answers, plan replication,summarise and write breakdown.json / reports. Safe to call again after theclassifier changes (no re-decoding)."""+ from . import dance++ dance.mark(breakdown) # speech / singing share and product context per shot, for the motion-drive guardout = Path(out)set_lang(breakdown.get("lang", "zh"))# remember the engine: apply-review / correct / eval call finalize without one and must not reset itdiff --git a/rea_video/plan.py b/rea_video/plan.pyindex 2d6667b..28e43cf 100644--- a/rea_video/plan.py+++ b/rea_video/plan.py@@ -289,11 +289,19 @@ class Planner:def plan_shot(self, label: str, shot: dict, video: dict, engine: str = "seedance2.0") -> 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", Nonerule = 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": NOTE.get(label, "")}+ "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 = []diff --git a/rea_video/playbook.py b/rea_video/playbook.pyindex 86967ae..2caf2c9 100644--- a/rea_video/playbook.py+++ b/rea_video/playbook.py@@ -12,7 +12,7 @@ from __future__ import annotationsimport re-from . import entities, narrative, performance+from . import dance, entities, narrative, performancefrom .i18n import LangDict, T, model_nameNAME_ZH = LangDict({@@ -20,13 +20,13 @@ NAME_ZH = LangDict({"ai_drama": "AI 剧情短片", "ai_product": "AI 商品广告", "ai_mv": "AI 音乐 MV", "avatar": "数字人口播","ai_clip": "AI 短片段(萌宠 / 奇观 / 单场景)", "animation": "3D / 动画","film": "影视解说 / 混剪", "explainer": "动效科普 / 数据动画", "screen": "录屏教程 / 软件演示",- "slideshow": "图片推拉成片(图文 / 故事 / 推文)", "beat": "卡点混剪",+ "slideshow": "图片推拉成片(图文 / 故事 / 推文)", "beat": "卡点混剪", "dance": "舞蹈 / 动作表演",}, en={"talking_head": "talking head", "desk": "tabletop / unboxing / product", "vlog": "vlog", "live_drama": "live-action skit","ai_drama": "AI story short", "ai_product": "AI product ad", "ai_mv": "AI music video", "avatar": "digital-avatar talking head","ai_clip": "short AI clip (pets / spectacle / single scene)", "animation": "3D / animation","film": "film commentary / film-clip montage", "explainer": "motion-graphics explainer", "screen": "screen tutorial / software demo",- "slideshow": "stills with pan and zoom (photo story)", "beat": "beat-synced montage",+ "slideshow": "stills with pan and zoom (photo story)", "beat": "beat-synced montage", "dance": "dance / action performance",})_LIVE = ("live_action",)@@ -101,6 +101,8 @@ def kinds(b: dict) -> list[tuple[str, float]]:return []cast = entities.cast(b)s, audio = b.get("summary") or {}, b.get("audio") or {}+ if dance.is_motion_video(b): # the moves carry the video, however it was cut or made+ return [("dance", dance.share(b))]voice = float((audio.get("voice") or {}).get("ratio") or 0) if (audio.get("voice") or {}).get("present") else 0.0avg, music = float(s.get("avg_shot_s") or 9), bool((audio.get("music") or {}).get("present"))if _sound_type(b) != "music_mv" and ((audio.get("beat_synced_edit") and avg <= 1.6 and voice < 0.3)@@ -252,6 +254,26 @@ def _generate(b: dict) -> list[str]:return L+def _drive(b: dict) -> str | None:+ drive = (b.get("production_plan") or {}).get("drive") or []+ if not drive:+ return None+ n = sum(len(u["shots"]) for u in drive)+ s = sum(u["duration"] for u in drive)+ k = sum(u["segments_est"] for u in drive)+ kling = all(u["movers"] < 2 and len(u["shots"]) == 1 and u["full_body"] is not False and not u["camera_moves"] for u in drive)+ tool = T("Kling 动作控制或 Seedance 2.5", "Kling Motion Control or Seedance 2.5") if kling else T("Seedance 2.5 全能参考", "Seedance 2.5 omni-reference")+ first = drive[0]+ how = (T("直接拿原片当参考视频({t})", "the source clip as the reference video ({t})", t=tool) if first["pick"]["key"] == "ref"+ else T("深度视频驱动(`rea-video drive --depth`)", "a depth-video drive (`rea-video drive --depth`)"))+ return T("**动作驱动**:{n} 镜({s:.0f} 秒)的动作用原片当驱动,不用首尾帧生成。`rea-video drive <报告目录>` 擦掉字幕、在停顿处切成约 {k} 段;"+ "一张角色设定图贯穿每段;这条先用{h}。{w}。新场景和原片差很多时改深度视频,连空间、机位都要换时做白模;每段的路线和提示词见下方「动作驱动」",+ "**Motion drive**: the moves of {n} shot{p} ({s:.0f} s) are driven from the source, not generated from frames. `rea-video drive <report folder>` "+ "erases the captions and cuts about {k} segments at calm moments; one character sheet for every segment; start with {h}. {w}. If the new setting "+ "is far from the original, switch to a depth video, and to clay when the space and camera change too; routes and prompts per unit under “Motion drive” below",+ n=n, p="" if n == 1 else "s", s=s, k=k, h=how, w=first["pick"]["why"])++def _shoot_few(b: dict) -> str | None:"""A handful of live shots inside a generated video: point at the plan instead of measuring the whole film as if it were shot."""shoot = (b.get("production_plan") or {}).get("shoot") or []@@ -363,8 +385,12 @@ def _music(b: dict) -> str | None:bits.append(T("{t} {m}", "{t} {m}", t=key["tonic"], m=T("大调", "major") if key.get("mode") == "major" else T("小调", "minor")))if audio.get("beat_synced_edit"):bits.append(T("切镜卡在节拍上", "cuts land on the beat"))- return T("**配乐**:{x};找同速度、同情绪的曲子,风格和段落见「声音」", "**Music**: {x}; find a track at the same tempo and mood, style and sections under “Sound”",- x=T(",", ", ").join(bits) or T("有配乐", "music present"))+ x = T(",", ", ").join(bits) or T("有配乐", "music present")+ if dance.is_motion_video(b): # the moves were set to this track: another song moves every hit+ return T("**配乐**:{x};动作是踩着这首歌编的,用原曲(商用先确认版权)或同 BPM、重拍位置一样的曲子,生成和拼回都对着它",+ "**Music**: {x}; the moves were set to this song, so use it (check the rights for commercial use) or one at the same BPM with the "+ "accents in the same places, and generate and assemble against it", x=x)+ return T("**配乐**:{x};找同速度、同情绪的曲子,风格和段落见「声音」", "**Music**: {x}; find a track at the same tempo and mood, style and sections under “Sound”", x=x)def _sfx(b: dict) -> str | None:@@ -389,6 +415,7 @@ _ORDER_SPEC: dict[str, list] = {"slideshow": ["content", "material", _voice, _local, _edit, _packaging, _music],"avatar": ["content", "material", _voice, _avatar, _edit, _packaging, _music],"ai_mv": [_music, "content", "material", _generate, _shoot_few, _local, _edit, _packaging, _sfx], # the picture follows the song+ "dance": [_music, "material", _drive, _shoot, _generate, _edit, _packaging, _sfx], # the moves were set to the track}@@ -396,15 +423,15 @@ def steps(b: dict, kind: str, also: str | None = None) -> list[str]:"""The steps for this video in the order its kind is made; only steps with data behind them appear.`also`: a second kind covering a good part of the time; then every making step with data is listed."""live = kind in _LIVE_KINDS and not also- content, mat = _content(b), _material(b, live, refs=kind in _GENERATED_KINDS or bool(also))+ content, mat = _content(b), _material(b, live, refs=kind in _GENERATED_KINDS + ("dance",) or bool(also))spec = None if also else _ORDER_SPEC.get(kind)order = [{"content": content, "material": mat}.get(x, x) if isinstance(x, str) else x for x in spec] if spec else Noneif order is None:if live:- order = [content, mat, _shoot, _voice, _edit, _packaging, _music, _sfx]+ order = [content, mat, _shoot, _drive, _voice, _edit, _packaging, _music, _sfx]else: # a few live shots inside a generated video get one pointer; a real live share gets the full shoot stepsshoot = _shoot if also in _LIVE_KINDS or kind in _LIVE_KINDS else _shoot_few- order = [content, mat, _generate, _avatar, shoot, _code, _local, _voice, _edit, _packaging, _music, _sfx]+ order = [content, mat, _generate, _drive, _avatar, shoot, _code, _local, _voice, _edit, _packaging, _music, _sfx]out: list[str] = []for x in order:got = x(b) if callable(x) else xdiff --git a/rea_video/production.py b/rea_video/production.pyindex ff2a0da..54ab3eb 100644--- a/rea_video/production.py+++ b/rea_video/production.py@@ -557,8 +557,11 @@ def production_plan(b: dict, out: Path, engine: str = "seedance2.0") -> dict:"people": sum(r["duration"] for r in gen if (r.get("faces") or 0) > 0.3) >= 1.0}style = _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 framesunits: list[dict] = []- for run in _runs(shots, same_scene, GEN_LABELS, skip=set(reused)):+ for run in _runs(shots, same_scene, GEN_LABELS, skip=set(reused) | motion):for segm in _split_run(run, lim, hard, unit_min):prev = units[-1] if units else Noneunits.append(_unit(segm, len(units) + 1, lim, model, style, cast, prev, same_prev.get(segm[0]["index"], False), unit_min))@@ -600,6 +603,7 @@ def production_plan(b: dict, out: Path, engine: str = "seedance2.0") -> dict:plan["overlay_note"] = T("生成单元镜头上的{k}属于后期包装,不写进提示词;参考帧上带着的先擦掉,生成后按「剪辑包装层」的时间轴叠回","the {k} on the generated shots is post-production packaging: keep it out of the prompts, erase it from reference frames, ""and lay it back on from the packaging timeline after generation", k=join(on_gen))+ plan["drive"] = dance.units(b)plan["shoot"] = _setups(shots, sig, thr, b)code, cur = [], []for r in shots + [None]:@@ -669,6 +673,10 @@ def summary_line(plan: dict, b: dict) -> str:bits.append(T("{what} → {u} 个生成单元、{c} 次 {m} 调用", "{what} → {u} generation unit{us}, {c} {m} call{cs}",what=what, u=nu, us=_s(nu), c=plan["calls"], cs=_s(plan["calls"]), m=plan["model_name"])+ (T("(另有 {n} 镜是同一段成片重复使用,直接剪)", " (plus {n} shot{s} reusing the same clip, just cut)", n=again, s=_s(again)) if again else ""))+ if plan.get("drive"):+ from .dance import summary_bit++ bits.append(summary_bit(plan["drive"]))if plan["shoot"]:n_set = sum(len(s["setups"]) for s in plan["shoot"])n_shot = sum(len(s["shots"]) for s in plan["shoot"])@@ -700,7 +708,7 @@ def summary_line(plan: dict, b: dict) -> str:def report_parts(plan: dict) -> dict[str, list[str]]:"""The remake plan cut at its subsections, so a report can place each part under the step it belongs to:pre (AI notes and the input primer), units, shoot, code, local, footage. The summary line is left out."""- heads = {T("### 生成单元", "### Generation units"): "units", T("### 拍摄场次", "### Shooting scenes"): "shoot",+ heads = {T("### 生成单元", "### Generation units"): "units", T("### 动作驱动", "### Motion drive"): "drive", T("### 拍摄场次", "### Shooting scenes"): "shoot",T("### 代码合成", "### Code composition"): "code", T("### 本地重建", "### Local rebuild"): "local",T("### 影视原片", "### Film / TV source"): "footage"}parts: dict[str, list[str]] = {}@@ -840,6 +848,10 @@ def report_md(plan: dict) -> list[str]:if u.get("prompt_en"):L += ["", T("英文提示词:", "English prompt:"), "", "```text", u["prompt_en"], "```"]L += ["", "</details>"]+ if plan.get("drive"):+ from .dance import report_md as _drive_md++ L += _drive_md(plan["drive"])if plan["shoot"]:L += ["", T("### 拍摄场次", "### Shooting scenes"), "",T("同一场景的镜头集中拍完再换场景;场景内先拍大景别再拍特写,不用重新布光。每条前后多留约 1s 余量。",diff --git a/rea_video/remake.py b/rea_video/remake.pyindex c7dc127..956921b 100644--- a/rea_video/remake.py+++ b/rea_video/remake.py@@ -229,6 +229,9 @@ def _next_step(sh: dict) -> str:lab = sh["base"]["label"]need = (sh.get("replication") or {}).get("user_assets") or []+ if (sh.get("replication") or {}).get("executor") == "motion_drive":+ return T("动作驱动:rea-video drive 出驱动视频,按报告「动作驱动」的路线逐段生成,再 drive --join",+ "motion drive: rea-video drive for the drive clips, generate each segment by a route under “Motion drive”, then drive --join")if lab in GENERATED:return T("生成:用报告「生成单元」的提示词在网页上手动生成,或 remake-plan + remake-run(计费,先 --dry-run)","generate: paste the report's generation-unit prompt into a video model, or remake-plan + remake-run (paid; --dry-run first)")diff --git a/rea_video/report.py b/rea_video/report.pyindex 3991036..63208c8 100644--- a/rea_video/report.py+++ b/rea_video/report.py@@ -124,6 +124,9 @@ def _unit_of(b: dict) -> dict[int, str]:for s in plan.get("shoot", []):for i in s["shots"]:out[i] = s["id"]+ for d in plan.get("drive", []): # a filmed dance is both shot and driven; the drive unit is the remake route+ for i in d["shots"]:+ out[i] = d["id"]for c in plan.get("code", []):for i in c["shots"]:out[i] = c["id"]@@ -131,7 +134,8 @@ def _unit_of(b: dict) -> dict[int, str]:def _route(r: dict, units: dict[int, str]) -> str:- base = ROUTE_ZH.get(r["base"]["label"], r["replication"].get("executor", ""))+ base = (T("动作驱动", "motion drive") if (r.get("replication") or {}).get("executor") == "motion_drive"+ else ROUTE_ZH.get(r["base"]["label"], r["replication"].get("executor", "")))u = units.get(r["index"])return f"{base} · {u}" if u else base@@ -463,6 +467,9 @@ def _plan_md(b: dict) -> list[str]:if pre: # grouping rules, the model's prompt conventions, the input primer: needed when writing prompts, not to follow the stepspre = ["", f'<details class="ref"><summary>{html.escape(T("写提示词前看:分组规则、模型写法、能喂哪些输入", "Before writing prompts: grouping, the model's conventions, what it takes as input"))}</summary>', ""] + pre + ["", "</details>", ""]sub(T("AI 生成", "AI generation"), [f"**{plan['summary'].split(T(';', '; '))[0]}**", ""] + pre + parts["units"])+ if parts.get("drive"):+ steps.append(T("**动作驱动**:舞蹈 / 动作镜头用原片当驱动,见下方「动作驱动」", "**Motion drive**: the dance / action shots are driven from the source, see “Motion drive” below"))+ sub(T("动作驱动", "Motion drive"), parts["drive"])for key, title, step in (("code", T("代码合成", "Code build"), T("**录屏和动效**:见下方「代码合成」", "**Screen and motion graphics**: see “Code build” below")),("local", T("本地重建", "Local rebuild"), T("**静帧 / 推拉**:见下方「本地重建」", "**Stills / moves**: see “Local rebuild” below")),("footage", T("影视原片", "Film / TV source"), T("**影视片段**:见下方「影视原片」", "**Film / TV clips**: see “Film / TV source” below"))):diff --git a/rea_video/review.py b/rea_video/review.pyindex bcc53e8..a0bdccc 100644--- a/rea_video/review.py+++ b/rea_video/review.py@@ -13,7 +13,7 @@ from . import aspects, narrative, performancefrom .narrative import ROLE_GUIDEfrom .vlm import SHOT_PROMPT, shot_hints-PERF_TEMPLATE = {"who": "", "emotion": "", "intensity": "", "face": "", "body": "", "arc": [], "voice": "", "key": False, "en": ""}+PERF_TEMPLATE = {"who": "", "emotion": "", "intensity": "", "face": "", "body": "", "arc": [], "voice": "", "key": False, "move": "", "movers": 0, "full_body": None, "backdrop": "", "en": ""}SHOOT_LIKE = ("live_action", "avatar", "stop_motion", "film_footage") # shots where "how was it shot / lit" appliesAGENT_WEIGHT = 0.85 # agent answers are softened toward uniform before fusionIMAGE_SOURCES = ("ai_image", "photo", "graphic", "screenshot", "unknown")@@ -145,6 +145,10 @@ def build_tasks(breakdown: dict, out_dir: str) -> tuple[dict, dict]:past = hint_for(dl, pats)if past:prio, why = "high", why + [past]+ from .dance import maybe_motion, move_of++ if maybe_motion(rec, breakdown) and not move_of(rec):+ why = why + ["长镜头、动作量大、有配乐少台词:如果大幅度的全身动作本身是看点(舞蹈、打斗、健身),填 performance.move / movers / full_body / backdrop"]shoot_like = any(l in SHOOT_LIKE for l, _ in ranked[:2])shots.append({"id": rec["id"], "index": rec["index"], "start": rec["start"], "end": rec["end"], "duration": rec["duration"],diff --git a/rea_video/videomd.py b/rea_video/videomd.pyindex f7904a2..9161bfd 100644--- a/rea_video/videomd.py+++ b/rea_video/videomd.py@@ -261,6 +261,10 @@ def _next_steps(b: dict) -> list[str]: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"))+ 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, "+ "and `--join` puts the generated segments back; routes and prompts under “Motion drive” in `video/remake.md`"))if labels & {"ai_video", "cg_3d", "anim_2d", "stop_motion", "avatar"}:L.append(T("AI 类镜头:提示词在 `video/remake.md` 的「生成单元」;要自动生成跑 `rea-video remake-plan` + `remake-run --dry-run`,会计费,先问用户","AI shots: prompts are in the generation units of `video/remake.md`; for automatic generation run `rea-video remake-plan` + `remake-run --dry-run` (paid: ask the user first)"))diff --git a/rea_video/vlm.py b/rea_video/vlm.pyindex 4c5f3ec..7b397ad 100644--- a/rea_video/vlm.py+++ b/rea_video/vlm.py@@ -349,7 +349,7 @@ AI 仿定格风格(材质在帧间漂移)与真正的定格动画(同一"material_origin": "real|ai_generated|rendered|mixed(画面主要来自真实素材 / AI 生成 / 制作方渲染 / 混合)","embedded_assets": [{{"kind": "real_footage|photo|screenshot|screen_recording|product_photo|logo|ai_image", "description": "是什么、在画面哪里", "is_real_material": true}}],"ai_edits": [{{"kind": "face_swap|lip_sync|restyle|outfit_swap|bg_replace|object_edit|beautify", "evidence": "看到的破绽"}}],- "performance": {{"who": "", "emotion": "", "intensity": "low|mid|high", "face": "", "body": "", "arc": [], "voice": "", "key": false, "en": ""}},+ "performance": {{"who": "", "emotion": "", "intensity": "low|mid|high", "face": "", "body": "", "arc": [], "voice": "", "key": false, "move": "", "movers": 0, "full_body": null, "backdrop": "", "en": ""}},"replication": {{"image_prompt": "复刻首帧的中文图像提示词(主体、构图、光线、风格,具体可执行;有人物时写首帧的表情)","video_prompt": "复刻该镜头的中文视频提示词:写清动作过程和结束状态、运镜;人物表演写看得见的表情和动作(眼、眉、嘴、头、手),不写「开心」「难过」这类情绪词,幅度宁小勿大;只写想要的内容,不写否定句",diff --git a/skills/rea-video/SKILL.md b/skills/rea-video/SKILL.mdindex 8b3c8f5..fdc8d1d 100644--- a/skills/rea-video/SKILL.md+++ b/skills/rea-video/SKILL.md@@ -45,6 +45,7 @@ rea-video summary out/ref/breakdown.jsonrea-video review out/ref # 写出 review_tasks.json(每镜要看的图、工具判断、优先级)和 review_answers.json(答案模板)# 读 review_tasks.json 的 instructions,逐镜看 images 里的图(priority=high 必看),把 label_probs / evidence / description / narrative / embedded_assets 填进 review_answers.json;narrative 是「这个镜头在讲什么」:role 选叙事作用(抓注意 / 交代背景 / 补信息 / 给证据 / 转折 / 给结论 / 引导行动 / 渲染情绪),point 一句话写它讲的那一点,报告会连成「叙事线」;若某镜头实为多刀合并(暗底图形与暗底口播交替时容易被合成一个长镜头),可加 split_suggestion(cuts 切点秒数 + labels 各段类别 + note),报告会在该镜头标注拆分建议,镜头边界本身不变# 有人在演的镜头填 performance:主情绪、强度、看得见的表情和动作、镜头里的变化、说话的语气;复刻提示词和配音会照它还原表演+# 大幅度全身动作本身是看点(舞蹈、打斗、健身)的镜头再填 performance.move / movers / full_body / backdrop,复刻会改走「动作驱动」,按背景杂不杂、神态重不重要选驱动方式;带货、口播、边唱边小幅度动的不填(对口型 / 数字人就能做)# 顶层 cast 填整片的角色 / 场景 / 道具(同一个角色跨镜头认成同一个,外观写到能据此复刻)和一句视觉风格;没开 VLM 时报告的「角色、场景与道具」一节全靠这里# 顶层 story 填报告开头的「核心看点」:summary 一句话、hook 开头几秒怎么抓人、highlights 2–4 条能火的做法(手法 + 第几秒 + 为什么有效)# 画面里拍到带字的东西(手机屏幕、包装、招牌)时,每镜填 overlay_text:这一镜后期加的字幕 / 花字原文,其余 OCR 文字报告当成画面内容@@ -97,7 +98,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 code-remake out/ref` 出第一版(可改的工程 + 成片 + 打分),在它上面改,不要从零写;用户自己的素材用 `rea-video assemble` 拼回原时间线。代码渲染和用户自己的素材也可以在 ChatCut 里做。+先跑 `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 里做。## 参考文件diff --git a/skills/rea-video/references/remake.md b/skills/rea-video/references/remake.mdindex f3808a6..8a52804 100644--- a/skills/rea-video/references/remake.md+++ b/skills/rea-video/references/remake.md@@ -25,6 +25,7 @@- 往下改都从这一版开始:先改 `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/` 里的元素截图和关键帧条,用来补工具测不到的东西:标注怎么入场、图形是什么含义。+- **舞蹈 / 动作镜头**(看图时 `performance.move` 标出的):不走首尾帧,报告「动作驱动」写了路线和提示词:默认直接拿原片当参考视频;原背景杂乱或新场景差很多才转深度、做白模;神态要复刻时留在直接参考(深度和白模会丢表情)。先跑 `rea-video drive out/ref` 出去字幕、按停顿切好的驱动视频(`drive/README.md` 有每段的情况),先看 `drive/segments.jpg` 有没有擦坏手脚;生成好的段写进 `drive/results.json` 再 `rea-video drive out/ref --join`,然后 `rea-video remake`。- **真实素材**:列清单让用户提供;拿到后写进 `remake/mine.json` 再跑 `rea-video remake`,或放进 ChatCut 按原片节奏剪。- **表演和情绪**:报告「表演与情绪」一节逐镜写了情绪、表情、动作和语气,生成单元的提示词里已经带上表情和动作。改写提示词时保留看得见的表情和动作,不要换成「开心」「难过」这类词,也不要把幅度写大;有台词的镜头先做有语气的配音,再让画面跟着声音演。- **声音**:TTS(按脚本表里每句的语气)、BGM(按 BPM / 调性 / 情绪)、音效(按时间点)三条轨分别准备。