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

# 视频剪辑与动图转换

> 使用 frame 的区间写法剪辑视频、截取动图片段，并在视频与动图之间互相转换。

`frame` 除了取单帧，还可以写成**区间**来选取一段内容。配合 `fmt`，可以完成四类操作：

| 源 | 输出格式 | 操作 |
| :- | - | - |
| 视频 | `mp4` / `mov`，或不指定 | **视频剪辑** |
| 视频 | `gif` / `webp` / `avif` / `png` | **视频转动图** |
| 动图 | `gif` / `webp` / `avif` / `png`，或不指定 | **截取动图片段** |
| 动图 | `mp4` / `mov` | **动图转视频** |

## 区间写法

格式：`起点:终点`，多段用半角逗号分隔，按顺序拼接。

| 源 | 单位 | 区间范围 |
| :- | - | - |
| 视频 | 毫秒 | 含起点，不含终点 |
| 动图 | 帧序号，从 1 开始 | 含起点与终点 |

| 写法 | 视频 | 动图 |
| :- | - | - |
| `3000:8000` | 第 3 秒到第 8 秒 | – |
| `1:10` | – | 第 1 帧到第 10 帧 |
| `:5000` | 开头到第 5 秒 | 开头到第 5000 帧 |
| `-3000:` | 最后 3 秒 | 倒数第 3000 帧到结尾 |
| `-5:` | 最后 5 毫秒 | 最后 5 帧 |
| `0:2000,10000:12000` | 两段拼接，共 4 秒 | – |

* **负数**表示从末尾倒数；**省略起点**表示从头开始，**省略终点**表示直到结尾。
* 终点超出实际长度时自动截到结尾；起点超出实际长度时返回错误。
* 最多 20 段。

## 视频剪辑

[https://example.com/video.mp4?frame=3000:8000](https://example.com/video.mp4?frame=3000:8000)

* 逐帧精确，音频同步裁剪。
* 可同时使用 `w`、`h`、水印等参数。
* 输出时长（各段之和）至多 60 秒；源视频至多 100 MB。

## 视频转动图

[https://example.com/video.mp4?frame=0:3000\&fmt=gif\&w=320](https://example.com/video.mp4?frame=0:3000\&fmt=gif\&w=320)

| 参数 | 含义 | 默认值 |
| :- | - | :-: |
| `fps` | **帧率**，只能低于源视频帧率 | 15 |
| `w`、`h` | **尺寸**。不指定时长边自动限制：GIF 为 480，其余格式为 720 | – |

* 选取的总时长至多 30 秒。
* HDR 视频会自动转换为 SDR 画面。
* 缩放、裁剪、水印、质量等图片参数均可使用。

## 截取动图片段

[https://example.com/anim.gif?frame=1:10](https://example.com/anim.gif?frame=1:10)

输出仍是动图，可同时用 `fmt` 转换格式。

## 动图转视频

[https://example.com/anim.gif?fmt=mp4](https://example.com/anim.gif?fmt=mp4)

* 不带 `frame` 即转换整段，带区间则只转换选中的帧。
* 每帧的显示时长与原动图一致。
* 默认编码为 H.264，`vcodec=hevc` 可改为 HEVC。

## 动图播放参数

以下参数作用于动图输出：

| 参数 | 含义 | 取值 |
| :- | - | - |
| `loop` | **播放次数**，`0` 为无限循环。AVIF 不支持 | 0 \~ 65535 |
| `reverse` | **倒放** | `1` |
| `skip` | **抽帧**：每保留 1 帧，丢弃其后 N 帧。总时长不变，体积减小 | 0 \~ 100 |
| `interval` | **统一帧时长**，单位毫秒，用于变速 | 10 \~ 60000 |

[https://example.com/anim.gif?skip=1\&fmt=webp](https://example.com/anim.gif?skip=1\&fmt=webp)


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