示例

这份文档给出几份可以直接参考的 v2 JSON 片段。

1. 最小可用示例

{
  "meta": {
    "version": "2.0.0",
    "width": 1920,
    "height": 1080,
    "fps": 30,
    "background": "#000000"
  },
  "tracks": [
    {
      "id": "main",
      "clips": [
        {
          "type": "text",
          "start": 0,
          "duration": 3,
          "text": "Hello, world",
          "transform": {
            "x": "50%",
            "y": "50%"
          },
          "style": {
            "fontSize": 72,
            "fontWeight": 700,
            "fill": "#ffffff",
            "textAlign": "center"
          },
          "animations": [
            {
              "type": "fadeIn",
              "duration": 0.5
            }
          ]
        }
      ]
    }
  ]
}

2. 视频 + 标题 + CTA

{
  "meta": {
    "version": "2.0.0",
    "width": 1920,
    "height": 1080,
    "fps": 30,
    "background": "#000000"
  },
  "assets": {
    "videos": [
      {
        "id": "hero-video",
        "src": "https://example.com/hero.mp4"
      }
    ]
  },
  "tracks": [
    {
      "id": "main",
      "clips": [
        {
          "type": "video",
          "start": 0,
          "duration": 8,
          "src": { "$ref": "hero-video" },
          "muted": true,
          "transform": {
            "x": "50%",
            "y": "50%",
            "width": "100%",
            "height": "100%"
          }
        },
        {
          "type": "text",
          "start": 0.5,
          "duration": 3,
          "text": "Launch Faster",
          "transform": {
            "x": "50%",
            "y": "18%"
          },
          "style": {
            "fontSize": 72,
            "fontWeight": 700,
            "fill": "#ffffff",
            "textAlign": "center",
            "shadowColor": "#000000",
            "shadowBlur": 20
          },
          "animations": [
            {
              "type": "slideIn",
              "direction": "up",
              "distance": 120,
              "duration": 0.6,
              "easing": "easeOutCubic"
            }
          ]
        },
        {
          "type": "text",
          "start": 5.5,
          "duration": 2,
          "text": "Start Today",
          "transform": {
            "x": "50%",
            "y": "85%"
          },
          "style": {
            "fontSize": 48,
            "fontWeight": 600,
            "fill": "#22c55e",
            "textAlign": "center"
          },
          "transition": {
            "type": "fade",
            "duration": 0.2
          }
        }
      ]
    }
  ]
}

3. 外部字幕 URL 示例

{
  "meta": {
    "version": "2.0.0",
    "width": 1920,
    "height": 1080,
    "fps": 30
  },
  "assets": {
    "videos": [
      {
        "id": "host",
        "src": "https://example.com/host.mp4"
      }
    ]
  },
  "tracks": [
    {
      "clips": [
        {
          "type": "video",
          "start": 0,
          "duration": 8,
          "src": { "$ref": "host" },
          "transform": {
            "x": "50%",
            "y": "50%",
            "width": "100%",
            "height": "100%"
          }
        },
        {
          "type": "subtitle",
          "start": 0,
          "duration": 8,
          "words": {
            "src": "https://example.com/subtitle.json"
          },
          "config": {
            "position": "bottom",
            "fontSize": 60,
            "highlightColor": "#22d3ee",
            "backgroundColor": "rgba(0,0,0,0.4)"
          }
        }
      ]
    }
  ]
}

远程字幕接口应返回:

{
  "words": [
    {
      "word": "hello",
      "punctuated_word": "Hello",
      "start": 0,
      "end": 0.4
    },
    {
      "word": "world",
      "punctuated_word": "world!",
      "start": 0.4,
      "end": 0.9
    }
  ]
}

4. talking-head 模板示例

{
  "meta": {
    "version": "2.0.0",
    "width": 1920,
    "height": 1080,
    "fps": 30,
    "background": {
      "type": "linear",
      "angle": 135,
      "stops": [
        { "offset": 0, "color": "#020617" },
        { "offset": 1, "color": "#1d4ed8" }
      ]
    }
  },
  "assets": {
    "videos": [
      { "id": "host", "src": "https://example.com/host.mp4" }
    ],
    "subtitles": [
      {
        "id": "sub-main",
        "words": [
          {
            "word": "hello",
            "punctuated_word": "Hello",
            "start": 0,
            "end": 0.4
          },
          {
            "word": "world",
            "punctuated_word": "world!",
            "start": 0.4,
            "end": 0.9
          }
        ]
      }
    ]
  },
  "tracks": [
    {
      "id": "main",
      "clips": [
        {
          "type": "template",
          "template": "talking-head",
          "start": 0,
          "duration": 6,
          "data": {
            "src": { "$ref": "host" },
            "words": { "$ref": "sub-main" },
            "title": "Weekly Update",
            "speaker": "Alex Chen",
            "role": "Founder",
            "showLowerThird": true,
            "config": {
              "position": "bottom",
              "fontSize": 64,
              "highlightColor": "#22d3ee"
            }
          }
        }
      ]
    }
  ]
}

5. 音频淡入淡出示例

{
  "type": "audio",
  "start": 0,
  "duration": 10,
  "src": "https://example.com/bgm.mp3",
  "volume": 0.6,
  "fadeIn": 1.2,
  "fadeOut": 1.5,
  "loop": true
}

6. 动画循环示例

{
  "type": "text",
  "start": 0,
  "duration": 4,
  "text": "Pulse",
  "transform": {
    "x": "50%",
    "y": "50%"
  },
  "style": {
    "fontSize": 80,
    "fill": "#ffffff"
  },
  "animations": [
    {
      "type": "scale",
      "from": 1,
      "to": 1.1,
      "duration": 0.5,
      "loop": true,
      "easing": "easeInOutSine"
    }
  ]
}