# Reframe

> POST /v1/reframe: the parameters, what a finished job returns, and revisions that correct single scenes.

Reframing crops a horizontal video to a narrower shape. The crop follows the main subject, the person speaking and the action; where the important content cannot fit, it shows the whole frame over a blurred copy of itself. Shots and scenes are detected, and on-screen captions (name supers) are moved into view.

## Request

All fields but the input are optional:

```json
{
  "input": {"url": "https://example.com/interview.mp4"},
  "target_aspect": "9:16",
  "strategy": "auto",
  "smoothness": 0.5,
  "output": {"height": 1920, "crf": 20},
  "debug_overlay": false,
  "webhook": {"url": "https://example.com/hooks/vapi", "secret": "a-long-random-secret"}
}
```

| Field | Values | |
|---|---|---|
| `input` | `{"url"}` or `{"upload_id"}` | The video. See [Jobs](jobs.md#inputs). |
| `target_aspect` | `9:16` (default), `1:1`, `4:5` | The output's shape. The source must be wider than it. |
| `strategy` | `auto` (default), `follow`, `static`, `fit_blur` | `auto`: follow the main subject, the whole frame over a blur when it cannot fit; `follow`: always crop on the main subject; `static`: one fixed crop per shot; `fit_blur`: always the whole frame. |
| `smoothness` | 0 to 1, default 0.5 | Higher is calmer camera motion. |
| `output.height` | 320 to 3840 | Default: the largest standard size that does not upscale the source much (9:16: 1920 or 1280). |
| `output.crf` | 12 to 35, default 20 | H.264 quality; lower is better and bigger. |
| `debug_overlay` | `true` or `false` | Also produce `debug.mp4` with the detections and the crop drawn on it. |
| `webhook` | `{"url", "secret"}` | Called when the job finishes. See [Jobs](jobs.md#webhooks). |
| `revision_of` | `job_...` | Revise an earlier job instead of giving `input`. See below. |
| `overrides` | a list | Corrections per scene, for revisions. See below. |

Videos up to 10 minutes long. The output is as long as the input, with its audio.

## Result

A job that succeeded has:

- `outputs.video`: the vertical MP4; `outputs.analysis`: the analysis as JSON; `outputs.debug` with `debug_overlay`.
- `result.source` and `result.output`: width, height and length of each.
- `result.scenes`: each scene with its `id` (`f` and its first frame, e.g. `f1820`), start and end, how it is framed (`mode`, `reason`, the `subjects` followed, `zoom`), the `people` in it (ids you can pick) and a `preview_url`: a picture of the source with the people and the crop marked, next to the output frame.
- `result.shots` and `result.captions`: the detected shots and on-screen captions.
- `usage`: the seconds of output charged.

## Revisions

An editor reviewing the result can correct single scenes. A revision takes `revision_of` instead of `input`; the earlier job's input and parameters apply unless given again, and the analysis is reused, so a revision takes a fraction of the first run's time. It is charged like any job, per second of output.

```json
{
  "revision_of": "job_...",
  "overrides": [
    {"scene": "f3339", "mode": "fit_blur"},
    {"scene": "f2072", "subject": 331, "zoom": 1.5},
    {"scene": "f1661", "center_x": 0.62},
    {"scene": "f2384", "smoothness": 0.9, "captions": false},
    {"split_at_s": 101.4},
    {"scene": "f2467", "merge": true}
  ]
}
```

Per scene:

- `mode`: `auto`, `follow`, `static` or `fit_blur`;
- `subject`: follow this person (an id from the scene's `people`);
- `center_x`: one fixed crop centered here (0 is the left edge, 1 the right);
- `zoom`: 1 to 4 (closer, limited by the resolution), with `center_y`;
- `smoothness`: as the request's;
- `captions: false`: leave on-screen captions where the crop puts them.

`{"split_at_s": 101.4}` starts a new scene where the detector missed a cut; `{"scene": "f2467", "merge": true}` joins a scene with the one before it. Splits apply first, then merges, then the scene corrections. A revision's `overrides` replace the earlier list as a whole. Scene ids that do not exist are refused with `422 invalid_override`.

## Probe

`POST /v1/probe` with an `input` inspects a video for free: container, length, streams, resolution, rotation, frame rate. Its `result.media` is what VAPI found. A probed upload's length is remembered, so `POST /v1/estimates` can price it.
