> ## 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.

# 视频超分（FlashVSR）

> 用 FlashVSR 将任意视频的宽和高各放大一倍。上传文件或传入 URL；按源视频每秒 $0.01 计费。

FlashVSR 将你已有的视频固定放大 2 倍：1280×720 的源视频会返回 2560×1440。你发送一个视频，得到一个超分后的 MP4。没有目标分辨率设置，也没有其他可调参数。

可以用它在发布前让成片更清晰，例如 768p 的 [Viggle Remake](https://docs.viggle.ai/zh/v1/video/remake.md) 结果、[Video Remix](https://docs.viggle.ai/zh/v1/video/video-remix) 渲染任务，或任何其他来源的素材。对于 [Viggle H3](https://docs.viggle.ai/zh/v1/video/generate-video) 视频，你也可以在生成时直接请求 `1080p`、`2k` 或 `4k`。

## 请求内容

以 `multipart/form-data` 调用 `POST /v1/videos/super-resolution`。

| 参数 | 必填 | 说明 |
| - | - | - |
| `video` | 二选一 | 以文件上传的源视频 |
| `video_url` | 二选一 | 源视频的公开 `http(s)://` URL |
| `watermark` | 否 | 默认 `false`。在结果中添加 Viggle 水印 |

发送 `video` 或 `video_url`，不能同时发送。

### 源视频限制

| | 限制 |
| - | - |
| 文件大小 | 最大 100 MiB |
| 时长 | 0.5–600 秒 |
| 尺寸 | 至少 64×64 像素，宽和高均为偶数 |

超出这些限制的源视频会在创建时被拒绝，返回 `400 INVALID_REQUEST`。

## 价格

按源视频每秒 1 积分（\$0.01）计费，向上取整到整秒。时长由服务自行测量。

```text theme={null}
credits = ceil(source seconds)
```

4.2 秒的源视频消耗 5 积分（$0.05）。下面 6.88 秒的示例视频消耗 7 积分（$0.07）。失败的任务会退款。

> [!WARNING]
>
> 如果余额不足以支付该任务，请求仍会被接受并返回 `status: "queued"`，随后任务以 `failed` 结束，`error.code: "INSUFFICIENT_CREDITS"`。大批量提交前请先调用 `GET /v1/credits` 查看余额。

## 对视频进行超分

导出 `VIGGLE_API_KEY`，然后直接运行以下任一脚本。脚本对 Viggle 托管的示例视频进行超分；准备好后换成你自己的 URL 即可。每个脚本每 5 秒轮询一次，并打印超分后的视频 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/super-resolution" \
  -H "Authorization: Bearer $VIGGLE_API_KEY" \
  -F video_url="https://assets.viggle.ai/pub/www/developers/sample-motion-97bb074a.mp4" | jq -er '.id')
echo "Submitted $video_id"

for _ in $(seq 1 120); 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 5
done
echo "Timed out waiting for $video_id" >&2; exit 1
```

```javascript Node.js theme={null}
// Node.js 20+。保存为 upscale.mjs，然后运行：node upscale.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("video_url", "https://assets.viggle.ai/pub/www/developers/sample-motion-97bb074a.mp4");
const { id } = await call("/videos/super-resolution", { method: "POST", body: form });
console.log(`Submitted ${id}`);

for (let i = 0; i < 120; 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, 5000));
}
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/super-resolution", headers=HEADERS, timeout=300, files={
    "video_url": (None, "https://assets.viggle.ai/pub/www/developers/sample-motion-97bb074a.mp4"),
}))
print("Submitted", video["id"])

for _ in range(120):
    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(5)
else:
    raise TimeoutError(f"Timed out waiting for {video['id']}")
```

要上传本地文件，以 `video` 字段发送：

```bash theme={null}
curl https://apis.viggle.ai/v1/videos/super-resolution \
  -H "Authorization: Bearer $VIGGLE_API_KEY" \
  -F video=@input.mp4
```

创建请求返回一个 `vsr_` ID：

```json theme={null}
{ "id": "vsr_5b7e2c90-d14f-4a6e-8c3b-9f1d2a4e6b70", "status": "queued", "progress": null, "created_at": "2026-11-20T09:12:03Z" }
```

## 获取结果

用 `GET /v1/videos/{video_id}` 读取任务，原样传入 `vsr_` ID。`status` 为 `ready` 时，下载 `video_url`。

* 链接有效期为一小时，每次读取都会返回新链接。
* 请及时下载。超分后的文件在任务结束 24 小时后删除；之后读取任务仍显示 `ready`，但 `video_url` 为 `null`。
* 超分任务不会出现在 `GET /v1/videos` 中。请保存创建时拿到的 `vsr_` ID。
* 只有创建该任务的 API 密钥才能读取它。

见[任务生命周期](https://docs.viggle.ai/zh/v1/concepts/task-lifecycle.md)和[限制与保留期](https://docs.viggle.ai/zh/v1/concepts/limits-and-retention.md)。

## 后续步骤

> [card] [Viggle Remake](https://docs.viggle.ai/zh/v1/video/remake.md)
>
> 替换视频中的人物，再对 768p 结果进行超分。

> [card] [Video Remix](https://docs.viggle.ai/zh/v1/video/video-remix)
>
> 把角色放到动作视频上。

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

> [card] [视频超分（API 参考）](https://docs.viggle.ai/zh/v1/api-reference/videos/upscale-a-video.md)
>
> `POST /v1/videos/super-resolution` 的全部字段和错误。


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