Guides · Trim a video

# Trim a video

Put `-ss` (the start) and `-t` (the length) on the input, and name the output. The response holds the clip’s download URL.

## The request

Request

```bash
curl https://media.logicboostkit.com/ffmpeg/process \
  -H "Authorization: Basic $MEDIA_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "task": {
      "inputs": [
        {
          "file_path": "dir_pi23jgy1yxlmigi873bz/source.mp4",
          "options": [
            "-ss",
            "00:00:02",
            "-t",
            "3"
          ]
        }
      ],
      "outputs": [
        {
          "file": "clip.mp4",
          "options": [
            "-c:v",
            "libx264",
            "-crf",
            "23",
            "-c:a",
            "aac"
          ]
        }
      ]
    }
  }'
```

Response

```http
HTTP/1.1 200 OK
X-Request-Id: job_0mv6hcx5429ir9i0kjnput8u

{
  "ok": true,
  "result": [
    {
      "file_name": "clip.mp4",
      "size_bytes": 6291456,
      "download_url": "https://…"
    }
  ],
  "usage": {
    "time_sec": 3.1,
    "input_size_gb": 0.8,
    "output_size_gb": 0.005859375,
    "gb_sec": 2.498164062
  },
  "request_id": "job_0mv6hcx5429ir9i0kjnput8u",
  "amount_usd": 0.033275545
}
```

The input is a file you uploaded ([POST /file](https://media.logicboostkit.com/docs/post-file)). The full reference is [POST /ffmpeg/process](https://media.logicboostkit.com/docs/post-ffmpeg-process).

## The options, explained

What each option does

- `-ss 00:00:02`: On the input: where the clip starts, as hh:mm:ss or seconds. Placed before the input, the seek is fast.
- `-t 3`: On the input: how long the clip is, in seconds. Use -to for an end time instead.
- `-c:v libx264 -crf 23`: Re-encode the video, so the clip starts exactly at -ss.
- `-c:a aac`: Encode the audio as AAC.

## Variations

### Fast, without re-encoding

Copies the streams: the job takes seconds, and the cut falls on the nearest keyframe, so it may start a little early.

```
In the output: "options": ["-c", "copy"]
```

### From a time to a time

On the input, `-to` gives the end time instead of a length.

```
In the input: "options": ["-ss", "00:01:30", "-to", "00:02:10"]
```

## What it costs

A 3-second clip from a 0.8 GB video, cut without re-encoding: (0.8 GB + 0.1 GB) × 2.5 s = 2.250 GB-seconds, which is USD 0.0300 at USD 0.01332 per GB-second.

The seconds are an example; every response reports the job’s own. Failed jobs are not charged. See [Pricing](https://media.logicboostkit.com/pricing).
