> ## Documentation Index
> Fetch the complete documentation index at: https://docs.viggle.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Viggle Remake

> 把视频里的人换成你自己的角色，同时保留原视频的动作、运镜和节奏。

Viggle Remake 用你提供的图片中的角色替换视频里的人。你只需发送一段驱动视频和一张或多张角色图。Remake 会保留驱动视频的动作、运镜和节奏，把人物换成你的角色。输出为 768p MP4。

它适合给现有片段换角：把你的吉祥物放进一段舞蹈视频、替换广告里的演员，或者把一段录制好的表演变成另一个角色。如果想让角色从零开始表演某个动作，请参阅 [Video Remix](https://docs.viggle.ai/zh/v1/video/video-remix)。如果想根据参考素材生成新镜头，请参阅[参考生视频](https://docs.viggle.ai/zh/v1/video/reference-to-video.md)。

Remake 使用 `POST /v1/videos`，与 Viggle H3 是同一个端点。只要发送了驱动视频或任一角色图字段，就会走 Remake，任务 ID 以 `anim_` 开头。

> [!WARNING]
>
> Remake 始终需要驱动视频。只带角色图、没有 `driving_video` 或 `driving_video_url`（包括 URL 为空或 `null`）的请求，无论图片数量、`prompt` 或 `enhance_mode` 如何，都会在扣费前被拒绝，返回 `400 INVALID_REQUEST`。如需用 Viggle H3 从图片生成视频，请使用[首帧生视频](https://docs.viggle.ai/zh/v1/video/first-frame-to-video.md)或[参考生视频](https://docs.viggle.ai/zh/v1/video/reference-to-video.md)。

## 选择增强模式

`enhance_mode` 决定 Remake 在渲染前做多少准备工作，同时决定价格。

| `enhance_mode` | 驱动视频 | 每秒价格 | 工作方式 | 建议图片数 |
| - | - | - | - | - |
| `normal` | 5–16 秒 | \$0.01（1 积分） | 最轻量的处理：以最少的准备把你的角色换进去 | 1 张，或 2–3 张并使用目标标签 |
| `planner`（默认） | 5–16 秒 | \$0.05（5 积分） | 增加一轮规划，在渲染前准备好提示词和关键帧 | 1 张，或 2–3 张并使用目标标签 |
| `agent` | 5–60 秒 | \$0.10（10 积分） | 由 AI 智能体规划并执行整个编辑。`prompt` 会被当作自由形式的指令 | 1–10 张，按顺序 |

驱动视频时长范围和价格由 API 强制执行，所有模式都最多接受 10 张角色图。另外两列是每种模式擅长什么的参考建议。

建议从默认的 `planner` 开始。`normal` 的价格只有它的五分之一。片段超过 16 秒、人数超过 3 人，或者你更想用文字描述编辑内容时，请使用 `agent`。

## 角色图与目标标签

每张角色图替换驱动视频中的一个人。

* 只替换一个人：发送一张图即可，不需要提示词。
* 使用 `planner` 或 `normal` 替换多人：建议使用 2–3 张图，并让提示词开头按顺序为每张图写一个标签：`<Character1>`、`<Character2>`、`<Character3>`。在每个标签后描述这张图替换视频中的哪个人。不加标签时，通常只会用到第一张图。
* 使用 `agent`：按顺序发送 1–10 张图，依次对应 Character1、Character2 等。标签可选，你可以直接用文字说明谁替换谁。

```text theme={null}
<Character1>the person in white on the left<Character2>the person in red on the right
```

## 请求内容

上传文件时发送 `multipart/form-data`；所有输入都是 URL 时，可以发送 JSON（或 `application/x-www-form-urlencoded`）。

| 参数 | 是否必填 | 说明 |
| - | - | - |
| `driving_video` 或 `driving_video_url` | 是，二选一 | 要保留其动作的视频。两者只能选一个，不能同时发送。缺少时请求返回 `400` |
| `character_image` | 图片来源之一 | 图片文件。每张图重复一次该字段，按顺序发送 |
| `character_image_url` | 图片来源之一 | 图片 URL。在表单中可重复 |
| `character_image_urls` | 图片来源之一 | 有序的图片 URL 列表：JSON 请求体中为 JSON 数组，表单中为 JSON 数组字符串 |
| `prompt` | 否 | 目标标签，或智能体的编辑指令 |
| `enhance_mode` | 否 | `normal`、`planner`（默认）或 `agent` |
| `watermark` | 否 | 默认 `false`。不影响价格 |

每个请求只能使用一种图片来源：上传文件、`character_image_url` 或 `character_image_urls`。上传文件和 URL 不能混用。Remake 没有 `quality`、`duration_s`、`resolution`、`aspect_ratio` 或 `seed` 参数；发送 `quality` 会被拒绝并返回 `400`。输出时长跟随驱动视频。完整结构见[创建视频](https://docs.viggle.ai/zh/v1/api-reference/videos/create-a-video.md)。

### 媒体要求

| 输入 | 要求 |
| - | - |
| 驱动视频时长 | `normal` 和 `planner` 为 5–16 秒，精确校验（16.2 秒会被拒绝）。`agent` 为 5–60 秒：时长校验按整秒计算（60.9 秒可通过），但计费向上取整，因此 60.9 秒的视频按 61 秒计费 |
| 驱动视频文件 | 最大 100 MiB，至少 64×64 像素，宽高均为偶数 |
| 角色图 | 最多 10 张。上传文件每张最大 20 MiB。任何可解码的图片（JPEG、PNG 等）均可；不要求固定尺寸、宽高比或全身构图 |
| URL | 必须是公开的 `https://` URL。`http://` 会被拒绝 |

驱动视频时长超出所选 `enhance_mode` 的范围时，会在创建时被拒绝并返回 `400 INVALID_REQUEST`，不会扣费。

## 价格

Remake 按驱动视频的秒数计费，向上取整，费率由 `enhance_mode` 决定：

```text theme={null}
credits = ceil(driving video seconds) × 1 (normal) | 5 (planner) | 10 (agent)
```

一段 8.3 秒的驱动视频按 9 秒计费：`normal` 为 9 积分（$0.09），`planner` 为 45 积分（$0.45），`agent` 为 90 积分（\$0.90）。

* 提交时预扣这笔金额。如果余额不足，请求失败并返回 `402 INSUFFICIENT_CREDITS`，不会运行任务。这次尝试仍可能以失败的 `anim_` 任务出现在 `GET /v1/videos` 中。
* 任务变为 `ready` 时，按成片时长以相同费率结算。结算金额不会超过预扣金额，因此结算只会产生退款。
* 失败的任务全额退款。
* 如果预扣环节繁忙，请求可能失败并返回 `429 RATE_LIMITED`。请退避后重试。

## Remake 一段视频

导出 `VIGGLE_API_KEY` 后，直接运行下面任一脚本即可。脚本使用 Viggle 托管的示例驱动视频（6.88 秒，一名舞者）和示例角色图，采用默认的 `planner` 模式。该示例按 7 秒计费：35 积分（\$0.35）。每个脚本每 10 秒轮询一次，并打印视频 URL。cURL 版本需要 `jq`。

```bash cURL theme={null}
#!/usr/bin/env bash
set -euo pipefail
API="https://apis.viggle.ai/v1"

video_id=$(curl -sS --fail-with-body "$API/videos" \
  -H "Authorization: Bearer $VIGGLE_API_KEY" \
  -F driving_video_url="https://assets.viggle.ai/pub/www/developers/sample-motion-97bb074a.mp4" \
  -F character_image_url="https://assets.viggle.ai/pub/www/developers/threed-source-image-3f2f6787.webp" | jq -er '.id')
echo "Submitted $video_id"

for _ in $(seq 1 720); do
  video=$(curl -sS --fail-with-body "$API/videos/$video_id" \
    -H "Authorization: Bearer $VIGGLE_API_KEY")
  case $(echo "$video" | jq -r '.status') in
    ready) echo "$video" | jq -r '.video_url'; exit 0 ;;
    failed|cancelled) echo "$video" | jq -c '.error' >&2; exit 1 ;;
  esac
  sleep 10
done
echo "Timed out waiting for $video_id" >&2; exit 1
```

```javascript Node.js theme={null}
// 需要 Node.js 20+。保存为 remake.mjs，然后运行：node remake.mjs
const API = "https://apis.viggle.ai/v1";
const headers = { Authorization: `Bearer ${process.env.VIGGLE_API_KEY}` };

async function call(path, init = {}) {
  const res = await fetch(`${API}${path}`, { ...init, headers });
  const body = await res.json();
  if (!res.ok) throw new Error(`HTTP ${res.status}: ${JSON.stringify(body.error)}`);
  return body;
}

const form = new FormData();
form.append("driving_video_url", "https://assets.viggle.ai/pub/www/developers/sample-motion-97bb074a.mp4");
form.append("character_image_url", "https://assets.viggle.ai/pub/www/developers/threed-source-image-3f2f6787.webp");
const { id } = await call("/videos", { method: "POST", body: form });
console.log(`Submitted ${id}`);

for (let i = 0; i < 720; i++) {
  const video = await call(`/videos/${id}`);
  if (video.status === "ready") {
    console.log(video.video_url);
    process.exit(0);
  }
  if (video.status === "failed" || video.status === "cancelled") {
    throw new Error(`${video.status}: ${JSON.stringify(video.error)}`);
  }
  await new Promise((resolve) => setTimeout(resolve, 10000));
}
throw new Error(`Timed out waiting for ${id}`);
```

```python Python theme={null}
import os
import time

import requests

API = "https://apis.viggle.ai/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['VIGGLE_API_KEY']}"}


def check(resp):
    if not resp.ok:
        raise RuntimeError(f"HTTP {resp.status_code}: {resp.text}")
    return resp.json()


# 通过 files= 传递字段，requests 会以 multipart/form-data 发送。
video = check(requests.post(f"{API}/videos", headers=HEADERS, timeout=300, files={
    "driving_video_url": (None, "https://assets.viggle.ai/pub/www/developers/sample-motion-97bb074a.mp4"),
    "character_image_url": (None, "https://assets.viggle.ai/pub/www/developers/threed-source-image-3f2f6787.webp"),
}))
print("Submitted", video["id"])

for _ in range(720):
    video = check(requests.get(f"{API}/videos/{video['id']}", headers=HEADERS))
    if video["status"] == "ready":
        print(video["video_url"])
        break
    if video["status"] in ("failed", "cancelled"):
        raise RuntimeError(f"{video['status']}: {video['error']}")
    time.sleep(10)
else:
    raise TimeoutError(f"Timed out waiting for {video['id']}")
```

如需上传本地文件，请改为以 `driving_video` 和 `character_image` 发送：

```bash theme={null}
curl https://apis.viggle.ai/v1/videos \
  -H "Authorization: Bearer $VIGGLE_API_KEY" \
  -F driving_video=@driving.mp4 \
  -F character_image=@character.png
```

创建请求会返回任务 ID：

```json theme={null}
{ "id": "anim_8c41d2e0-7a9b-4f13-a6d2-3b5e7c9f1a24", "status": "queued", "progress": null, "created_at": "2026-11-20T09:12:03Z" }
```

### 多人替换或 agent 模式

使用托管媒体时，可以发送 JSON。下面的请求体发往同一个端点，并带上 `Content-Type: application/json`，然后以同样方式轮询返回的 `anim_` ID。

```bash 两人（planner） theme={null}
curl https://apis.viggle.ai/v1/videos \
  -H "Authorization: Bearer $VIGGLE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "driving_video_url": "https://example.com/driving.mp4",
    "character_image_urls": ["https://example.com/first.jpg", "https://example.com/second.jpg"],
    "prompt": "<Character1>the person in white on the left<Character2>the person in red on the right"
  }'
```

```bash Agent theme={null}
curl https://apis.viggle.ai/v1/videos \
  -H "Authorization: Bearer $VIGGLE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "driving_video_url": "https://example.com/driving.mp4",
    "character_image_urls": ["https://example.com/first.jpg", "https://example.com/second.jpg"],
    "prompt": "Replace the dancer in white with the first character and the dancer in red with the second",
    "enhance_mode": "agent"
  }'
```

## 获取结果

用 `anim_` ID 轮询 `GET /v1/videos/{video_id}`。任务排队期间，响应中包含 `queue_position` 和 `estimated_wait_seconds`。`status` 为 `ready` 时，下载 `video_url`。

* 链接有效期为一小时，每次读取都会返回新链接。
* 视频在任务结束 24 小时后删除。请复制到你自己的存储中。
* 只有创建该任务的 API 密钥可以读取它。它也会出现在 `GET /v1/videos` 中。
* Remake 任务提交后无法取消。

参阅[任务生命周期](https://docs.viggle.ai/zh/v1/concepts/task-lifecycle.md)和[错误](https://docs.viggle.ai/zh/v1/production/errors.md)。

## 后续步骤

> [card] [对结果进行超分](https://docs.viggle.ai/zh/v1/video/upscale.md)
>
> 用 FlashVSR 把 768p 输出放大一倍，每秒 \$0.01。

> [card] [Video Remix](https://docs.viggle.ai/zh/v1/video/video-remix)
>
> 让角色表演一段动作视频，可选 alpha 输出。

> [card] [价格](https://docs.viggle.ai/zh/v1/pricing.md)
>
> 所有价格及计算示例。

> [card] [创建视频（API 参考）](https://docs.viggle.ai/zh/v1/api-reference/videos/create-a-video.md)
>
> `POST /v1/videos` 的所有字段、限制和错误。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.