{
  "format": "mosael-workflow",
  "version": 1,
  "workflow_revision": 1,
  "name": "任意长度的连续视频",
  "description": "输入一个想法和总时长，拆成一段一段，每段接着上一段的尾巴往下拍，接成一条不切镜头的长片。每段都是一次付费视频生成：开跑前按段数估算费用，max_segments 和 max_spend 是上限；断了可以从中断处继续。",
  "graph_hash": "368661bba928e44c3c4973c6decd6e3143c6955671fc7e28bba5b081885f407b",
  "graph": {
    "meta": {
      "template_id": "long_take_video",
      "template_version": 7,
      "source": "official"
    },
    "nodes": [
      {
        "id": "start",
        "type": "start",
        "name": "开始",
        "position": {
          "x": 40,
          "y": 300
        },
        "config": {
          "params": {
            "idea": "",
            "target_seconds": 60,
            "segment_seconds": 5,
            "overlap_seconds": 0.92,
            "max_segments": 12,
            "max_spend": 0,
            "style": "",
            "entity_ids": "",
            "aspect_ratio": "16:9",
            "resolution": "720p"
          },
          "required_params": [
            "idea"
          ]
        }
      },
      {
        "id": "plan",
        "type": "chain_plan",
        "name": "算要拍几段",
        "position": {
          "x": 40,
          "y": 620
        },
        "config": {
          "target_seconds": "{{start.target_seconds}}",
          "longest_seconds": "{{start.segment_seconds}}",
          "overlap_seconds": "{{start.overlap_seconds}}"
        }
      },
      {
        "id": "split",
        "type": "llm",
        "name": "把想法拆成一段一段",
        "position": {
          "x": 340,
          "y": 300
        },
        "config": {
          "profile_id": "",
          "model": "",
          "preset": "precise",
          "system": "你是分镜导演。这是一条不切镜头的连续长片,一段接一段往下拍:同一场景、同一人物、同一机位逻辑。只写下一段**接着发生什么**,不重复外观描述,不写切镜、转场。用英文写,每段一两句。",
          "prompt": "想法:{{start.idea}}\n总时长约 {{start.target_seconds}} 秒,每段 {{start.segment_seconds}} 秒。opening 写第一段(要交代人物、场景、光线、机位),next 写后面每一段:**next 要写满 {{plan.following}} 段**,超过 {{start.max_segments}} 段时写到这个数为止。",
          "response_format": "json_schema",
          "json_schema_name": "long_take_segments",
          "json_schema": {
            "type": "object",
            "properties": {
              "opening": {
                "type": "string"
              },
              "next": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            },
            "required": [
              "opening",
              "next"
            ],
            "additionalProperties": false
          },
          "json_schema_strict": "true",
          "temperature": 0.6,
          "max_tokens": 16000
        }
      },
      {
        "id": "beats",
        "type": "chain_plan",
        "name": "把每段要演的铺开",
        "position": {
          "x": 340,
          "y": 620
        },
        "config": {
          "target_seconds": "{{start.target_seconds}}",
          "longest_seconds": "{{start.segment_seconds}}",
          "overlap_seconds": "{{start.overlap_seconds}}",
          "beats": "{{split.json.next}}"
        }
      },
      {
        "id": "estimate",
        "type": "video_cost_estimate",
        "name": "估算费用",
        "position": {
          "x": 660,
          "y": 620
        },
        "config": {
          "provider": "",
          "provider_profile_id": "",
          "model": "",
          "items": "",
          "extra_items": 1,
          "seconds_each": "{{start.segment_seconds}}",
          "resolution": "720p",
          "max_spend": "{{start.max_spend}}"
        },
        "inputs": [
          "items"
        ]
      },
      {
        "id": "video_project",
        "type": "project_sequence_create",
        "name": "建立项目与时间线",
        "position": {
          "x": 660,
          "y": 120
        },
        "config": {
          "name": "长片",
          "fps": 24,
          "width": 1920,
          "height": 1080
        }
      },
      {
        "id": "opening",
        "type": "ai_generate",
        "name": "拍第一段",
        "position": {
          "x": 660,
          "y": 420
        },
        "config": {
          "provider": "",
          "provider_profile_id": "",
          "model": "",
          "kind": "video",
          "prompt": "{{start.style}} {{split.json.opening}}",
          "parameters": {
            "duration_seconds": "{{start.segment_seconds}}",
            "aspect_ratio": "{{start.aspect_ratio}}",
            "resolution": "{{start.resolution}}"
          },
          "entity_ids": "{{start.entity_ids}}"
        }
      },
      {
        "id": "segments",
        "type": "loop_foreach",
        "name": "一段接一段往下拍",
        "position": {
          "x": 980,
          "y": 420
        },
        "config": {
          "items": "",
          "inputs": {
            "style": "{{start.style}}",
            "scene": "{{split.json.opening}}",
            "overlap_seconds": "{{start.overlap_seconds}}",
            "segment_seconds": "{{start.segment_seconds}}",
            "entity_ids": "{{start.entity_ids}}",
            "aspect_ratio": "{{start.aspect_ratio}}",
            "resolution": "{{start.resolution}}"
          },
          "body": {
            "nodes": [
              {
                "id": "tail",
                "type": "video_frame",
                "name": "取上一段的最后一帧",
                "position": {
                  "x": 80,
                  "y": 140
                },
                "config": {
                  "asset_id": "{{loop.previous}}"
                }
              },
              {
                "id": "extend",
                "type": "ai_generate",
                "name": "接着往下拍",
                "position": {
                  "x": 390,
                  "y": 140
                },
                "config": {
                  "provider": "",
                  "provider_profile_id": "",
                  "model": "",
                  "kind": "video",
                  "prompt": "{{input.style}} {{input.scene}} One continuous shot with no cut, the same person in the same place, carrying on from the given clip. What happens now: {{loop.item.beat}}",
                  "parameters": {
                    "duration_seconds": "{{input.segment_seconds}}",
                    "aspect_ratio": "{{input.aspect_ratio}}",
                    "resolution": "{{input.resolution}}"
                  },
                  "source_assets": [
                    "{{tail.asset_id}}:first_frame"
                  ],
                  "entity_ids": "{{input.entity_ids}}"
                }
              }
            ],
            "edges": [
              {
                "id": "tail_extend",
                "source": "tail",
                "target": "extend"
              }
            ]
          },
          "output": "{{extend.asset_id}}",
          "previous_initial": "",
          "max_items": "{{start.max_segments}}",
          "max_spend": "{{start.max_spend}}"
        },
        "inputs": [
          "items",
          "previous_initial"
        ]
      },
      {
        "id": "clear_timeline",
        "type": "timeline_clear",
        "name": "清空时间线",
        "position": {
          "x": 1300,
          "y": 300
        },
        "config": {
          "sequence_id": ""
        },
        "inputs": [
          "sequence_id"
        ]
      },
      {
        "id": "append_opening",
        "type": "timeline_append",
        "name": "摆上第一段",
        "position": {
          "x": 1600,
          "y": 300
        },
        "config": {
          "sequence_id": "",
          "asset_id": ""
        },
        "inputs": [
          "sequence_id",
          "asset_id"
        ]
      },
      {
        "id": "assemble",
        "type": "loop_foreach",
        "name": "把后面每一段接上去",
        "position": {
          "x": 1900,
          "y": 300
        },
        "config": {
          "items": "",
          "inputs": {
            "sequence_id": "{{video_project.sequence_id}}",
            "search_seconds": "{{start.segment_seconds}}",
            "overlap_seconds": "{{start.overlap_seconds}}"
          },
          "body": {
            "nodes": [
              {
                "id": "append_segment",
                "type": "timeline_append",
                "name": "接到时间线上",
                "position": {
                  "x": 390,
                  "y": 140
                },
                "config": {
                  "sequence_id": "{{input.sequence_id}}",
                  "asset_id": "{{loop.item}}",
                  "start": 0
                }
              }
            ],
            "edges": []
          },
          "output": "{{loop.item}}",
          "previous_initial": ""
        },
        "inputs": [
          "items",
          "previous_initial"
        ]
      },
      {
        "id": "export_final",
        "type": "export_sequence",
        "name": "导出成片",
        "position": {
          "x": 2200,
          "y": 300
        },
        "config": {
          "sequence_id": "",
          "quality": "high"
        },
        "inputs": [
          "sequence_id"
        ]
      },
      {
        "id": "output",
        "type": "output",
        "name": "交付成片",
        "position": {
          "x": 2500,
          "y": 300
        },
        "config": {
          "values": {
            "video_asset_id": "{{export_final.asset_id}}",
            "segments": "{{segments.results}}"
          }
        }
      }
    ],
    "edges": [
      {
        "id": "start_plan",
        "source": "start",
        "target": "plan"
      },
      {
        "id": "plan_split",
        "source": "plan",
        "target": "split"
      },
      {
        "id": "split_project",
        "source": "split",
        "target": "video_project"
      },
      {
        "id": "project_opening",
        "source": "video_project",
        "target": "opening"
      },
      {
        "id": "split_beats",
        "source": "split",
        "target": "beats"
      },
      {
        "id": "beats_estimate",
        "source": "beats",
        "target": "estimate"
      },
      {
        "id": "estimate_opening",
        "source": "estimate",
        "target": "opening"
      },
      {
        "id": "opening_segments",
        "source": "opening",
        "target": "segments"
      },
      {
        "id": "segments_clear",
        "source": "segments",
        "target": "clear_timeline"
      },
      {
        "id": "clear_opening",
        "source": "clear_timeline",
        "target": "append_opening"
      },
      {
        "id": "opening_assemble",
        "source": "append_opening",
        "target": "assemble"
      },
      {
        "id": "assemble_export",
        "source": "assemble",
        "target": "export_final"
      },
      {
        "id": "export_output",
        "source": "export_final",
        "target": "output"
      },
      {
        "id": "d-beats-rounds-estimate-items",
        "source": "beats",
        "target": "estimate",
        "kind": "data",
        "source_output": "rounds",
        "target_input": "items"
      },
      {
        "id": "d-beats-rounds-segments-items",
        "source": "beats",
        "target": "segments",
        "kind": "data",
        "source_output": "rounds",
        "target_input": "items"
      },
      {
        "id": "d-opening-asset_id-segments-previous_initial",
        "source": "opening",
        "target": "segments",
        "kind": "data",
        "source_output": "asset_id",
        "target_input": "previous_initial"
      },
      {
        "id": "d-video_project-sequence_id-clear_timeline-sequence_id",
        "source": "video_project",
        "target": "clear_timeline",
        "kind": "data",
        "source_output": "sequence_id",
        "target_input": "sequence_id"
      },
      {
        "id": "d-video_project-sequence_id-append_opening-sequence_id",
        "source": "video_project",
        "target": "append_opening",
        "kind": "data",
        "source_output": "sequence_id",
        "target_input": "sequence_id"
      },
      {
        "id": "d-opening-asset_id-append_opening-asset_id",
        "source": "opening",
        "target": "append_opening",
        "kind": "data",
        "source_output": "asset_id",
        "target_input": "asset_id"
      },
      {
        "id": "d-segments-results-assemble-items",
        "source": "segments",
        "target": "assemble",
        "kind": "data",
        "source_output": "results",
        "target_input": "items"
      },
      {
        "id": "d-opening-asset_id-assemble-previous_initial",
        "source": "opening",
        "target": "assemble",
        "kind": "data",
        "source_output": "asset_id",
        "target_input": "previous_initial"
      },
      {
        "id": "d-video_project-sequence_id-export_final-sequence_id",
        "source": "video_project",
        "target": "export_final",
        "kind": "data",
        "source_output": "sequence_id",
        "target_input": "sequence_id"
      }
    ]
  }
}
