# ffmpeg

`/v1/ffmpeg/jobs` is an extension that runs media operations (for example `trim` or `concat`) on files you point to by URL. It is asynchronous.

## Create a job

Send `operation` and the input as `input_url` (or `input_urls`). Operations that need them also accept `image_url`, `audio_url`, `audio_urls`, `subtitle_url` and `webhook_url`; the remaining fields are the operation's own parameters. Files are uploaded through `POST /v1/ffmpeg/upload` (multipart), not through this endpoint.

The key's model allowlist is checked against the operation name.

```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
  }'
```

## Poll

`GET /v1/ffmpeg/jobs/{id}`. `status` uses the same words as video. A failed job is HTTP 200 with `status: failed` and an `error` object. `cost` is in credits.

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

## Billing

The cost is pre-deducted when the job is accepted and refunded if the job fails.

## See also
- [ffmpeg operations (reference)](https://www.novapi.ai/docs/ffmpeg)
