Files
SnapOtter/apps/docs/zh-CN/tools/video/video-to-gif.md
T
SnapOtterandGitHub 4963ab3bbd feat(docs-i18n): translate all documentation into 20 languages
All 181 docs markdown files translated into 20 languages (apps/docs/<locale>/**). Companion to the i18n code PR; admin-merged because the file count exceeds GitHub's per-PR CI trigger limit. Validated by pnpm i18n:check (all surfaces, 0 stale/missing) and a clean all-locale docs build.
2026-07-11 13:52:47 +08:00

50 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
description: "将视频片段转换为动画 GIF。"
i18n_source_hash: f729dde8cd55
i18n_provenance: human
i18n_output_hash: 1f4d73d93ecc
---
# Video to GIF {#video-to-gif}
将视频片段转换为动画 GIF,并可配置帧率、宽度、起始时间和时长。
## API Endpoint {#api-endpoint}
`POST /api/v1/tools/video/video-to-gif`
接受包含视频文件和 JSON `settings` 字段的 multipart 表单数据。这是一个异步端点:它会立即返回 `202 Accepted`,进度通过 SSE 在 `GET /api/v1/jobs/{jobId}/progress` 处流式传输。
## Parameters {#parameters}
| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| fps | integer | No | `12` | 输出帧率(1-30 |
| width | integer | No | `480` | 输出宽度,单位为像素(64-1280)。高度按比例缩放 |
| startS | number | No | `0` | 起始时间,单位为秒(必须 >= 0) |
| durationS | number | No | `5` | 时长,单位为秒(大于 0,最大 60) |
## Example Request {#example-request}
```bash
curl -X POST http://localhost:1349/api/v1/tools/video/video-to-gif \
-H "Authorization: Bearer si_your-api-key" \
-F "file=@clip.mp4" \
-F 'settings={"fps": 15, "width": 320, "startS": 2, "durationS": 8}'
```
## Example Response {#example-response}
```json
{
"jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"async": true
}
```
## Notes {#notes}
- 较低的 `fps``width` 值会生成更小的 GIF 文件。480px 宽、12 fps 的 GIF 通常是不错的平衡。
- 最长时长为 60 秒。更长的片段会生成非常大的文件。
- 在任务完成前,可通过 SSE 在 `GET /api/v1/jobs/{jobId}/progress` 处获取进度更新。