# ffmpeg

`/v1/ffmpeg/jobs` 是一个扩展接口，对你以 URL 指定的文件执行媒体操作（例如 `trim`、`concat`），异步。

## 创建任务

传 `operation` 与输入 `input_url`（或 `input_urls`）。需要时还可传 `image_url`、`audio_url`、`audio_urls`、`subtitle_url`、`webhook_url`；其余字段是该操作自己的参数。文件上传请用 `POST /v1/ffmpeg/upload`（multipart），不要走本接口。

密钥的模型白名单会按操作名校验。

```bash
curl https://api.novapi.ai/v1/ffmpeg/jobs \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "trim",
    "input_url": "https://example.com/input.mp4",
    "start": 10,
    "end": 25
  }'
```

## 轮询

`GET /v1/ffmpeg/jobs/{id}`。`status` 用词与视频一致。失败的任务是 HTTP 200，`status: failed` 并带 `error` 对象。`cost` 单位为积分。

```json
{
  "id": "<job-id>",
  "object": "ffmpeg.job",
  "operation": "trim",
  "status": "completed",
  "progress": 100,
  "result_url": "https://...",
  "cost": <credits>
}
```

## 计费

任务被接收时预扣费用，任务失败时退回。

## 相关链接
- [ffmpeg 操作（参考）](https://www.novapi.ai/zh/docs/ffmpeg)
