# Video clips

> Send a recorded video clip with a decision: typed answers about the clip, each Box with the time it was seen. Gemini gets the clip itself; every other model gets frames labelled with their time plus the soundtrack.

Source: https://docs.tarkova.com/curva/guides/video/

## How it works, step by step

1. **Your clip** (data_base64, url, part, file, mp4, webm, mov): A video asset on POST /v1/decide carries the clip inline, by https URL, as a multipart part, or as a file id from POST /v1/files. An inline clip can be up to 16 MiB, and a stored file up to 256 MiB. In the example: A 6 s test clip at 1024×576, made from two labelled photos: 3 s of a driver with no phone, then 3 s of a driver holding one.
2. **Questions** (auto set, Noul, Choice, Box, Extract, Verbal mode): With no questions and no ask, the request gets the auto set: happening, attention, event and where. Video is answered in verbal mode with no debias, so the model is asked once. In the example: Two questions: phone_in_hand, a yes or no, and where, a Box around the driver's phone.
3. **Clip checks** (First bytes, ffprobe, 2 minutes, 40 MP): Curva reads the container from the file's first bytes, then ffprobe reads its headers. A clip over 2 minutes or 40 million pixels is refused before any decoding, and a server without ffmpeg and ffprobe answers in one sentence with the install command. In the example: At 6 s and 1024×576, the clip passed both limits.
4. **Clip or frames** (Gemini native, Frame path, 16 MiB line): If every model the request may use is a Gemini model and the clip is at most 16 MiB, the model gets the clip itself as one video part. Any other model, or a bigger clip, takes the frame path. In the example: Gemini 3.1 Flash-Lite got the clip itself. Qwen3-VL on Bedrock took the frame path.
5. **Timed frames** (Scene changes, Steady frames, At most 16, 1568 px, Time labels, Soundtrack): On the frame path, ffmpeg picks scene changes plus a steady frame every 2 s (or every sixteenth of a clip over 32 s), keeps at most 16 and scales them to at most 1568 px. Each frame is labelled with its time, and Gemini on this path also gets the soundtrack as 16 kHz wav. In the example: Curva's frame rule on this clip picks 0, 2, 3 and 5 s. The frame at 3 s is the cut between the photos.
6. **The model answers** (Probabilities, Box with at_ms, Cache key): The model gives a probability for each answer, and a Box comes back with at_ms, the time of the frame it is on. The clip is part of the cache key, so the same request again comes from the cache with no model call. In the example: One request each. Flash-Lite: phone_in_hand 0.95, box at 3,000 ms, in 4,444 ms. Qwen3-VL: 0.5, box at 3,000 ms, in 2,468 ms. The repeat of each returned cached: true.
7. **Audit and receipt** (Salted hash, Signed receipt, Audit log, Feedback): The audit log keeps a salted hash of the clip, not the clip, and the temporary folder for the request is removed when it ends. The decision can carry a signed receipt that anyone can check offline, and your true answers go back as feedback. In the example: Both decisions returned with a signed receipt and calibrated: false, because this question has no labels yet.

For hours of recordings searched by time, use the [library](/curva/guides/library/#recordings) instead.

A short clip can be judged like a picture: a dashcam clip (seat belt, phone in hand), a site
camera clip (helmet), a phone video for an insurance claim. Give the clip a name, ask your own
questions or none at all, and a vision model answers with types and probabilities as for any
other decision. A Box on a video says where and when.

```python

from curva import Asset

d = curva.decide(Asset.video("dashcam.mp4"))                # no questions: what is happening, what needs attention
d["happening"].value, d["attention"].noul, d["event"].value, d["where"].box   # a box carries "at_ms"
```

```ts

const d = await decide("clip: a site camera", { no_helmet: "Anyone without a helmet?", where: { type: "box", instructions: "the person without a helmet" } },
                       { assets: { clip: Asset.video("site.mp4") } });
```

With no `questions` and no `ask`, a request with a video asset is answered with the built-in
`auto` set: `happening` (one sentence), `attention` (a calibrated probability that something is
unusual, unsafe or worth a person's attention), `event` (a short label, or `nothing`) and `where`
(a Box with `at_ms`). Your own questions work exactly as for pictures (`noul`, `choice`, `box`,
`extract`), and a ready-made set such as `ask="driving"` is a starting point.

## What the model gets

- **Gemini models** take the clip itself as one video part (mp4, webm or mov, up to 16 MiB), when
  every model the request may use is a Gemini model.
- **Every other model**, and clips over 16 MiB, get up to 16 frames, each labelled with its time
  (`clip at 4.0 s:`): scene changes, plus one frame at least every 2 seconds (clips over 32 s use a wider gap, seconds / 16), scaled to at most
  1568 px. Gemini on the frame path also gets the soundtrack as 16 kHz wav. This needs `ffmpeg` and
  `ffprobe` on the server's PATH (or `CURVA_FFMPEG=/path/to/ffmpeg`); a server without them answers
  in one sentence with the install command.
- `CURVA_VIDEO_FRAMES=1` sends frames to Gemini too, for a like-for-like comparison.

Box answers on a video carry `at_ms`, the time in milliseconds of the frame the box is on. A
`deadline_ms` covers fetching and probing the clip and reading its frames too. Video is answered in verbal mode (one call, no debias), not with `explain`, `mode: "logprobs"` or
`learn`. The clip is part of the cache key; the audit log keeps only a salted hash of it.

## Limits

| | |
|---|---|
| Length | 2 minutes |
| Frame size | 40 million pixels |
| Inline (`data_base64`, `url`, `part`) | 16 MiB; the whole request also fits the server's body limit (16 MB by default, `--max-body-mb`), and base64 adds a third, so send a clip over about 12 MB by `url` or `file` |
| Through `file` (an id from `POST /v1/files`) | 256 MiB |
| Frames per clip to a model without video input | 16 |
| Time for ffprobe / ffmpeg | 15 s / 60 s, then the request fails |

ffmpeg runs with `-protocol_whitelist file,pipe`, an empty environment and no network, writes
only into a temporary folder that is removed when the request ends, and is told the container
(`mov` or `matroska`) from the file's first bytes, so a playlist or any other file that is not an
mp4, mov or webm is never opened. At most one ffmpeg per two cores runs at a time. A clip whose headers claim a length over 2
minutes or a frame over the pixel cap is refused before any decoding; a picture or a text file sent
as video, a cut-off clip or an audio-only file gets a 422 with one sentence.

## Over HTTP

```json
POST /v1/decide
{
  "state": "clip: a 6 second dashcam video",
  "assets": {"clip": {"type": "video", "data_base64": "AAAAGGZ0eXBpc29t..."}},
  "questions": {
    "phone_in_hand": {"type": "noul", "instructions": "The driver holds a phone in a hand"},
    "where": {"type": "box", "instructions": "the driver's phone"}
  }
}
```

`type: "video"` takes exactly one of `data_base64`, `url` (https, fetched by the server), `part`
(a field of a `multipart/form-data` request) or `file` (`file_...` from `POST /v1/files`, for
clips over 16 MiB). `format` (`mp4`, `webm`, `mov`) is optional: it is read from the file's first
bytes. The answer is the usual decision; a Box answer is
`[{"top": 0.12, "left": 0.40, "bottom": 0.55, "right": 0.70, "at_ms": 4000}]`.

## Measured

Measured live on 2026-10-21 on 94 clips, each 6 s at 10 fps,
960×540, made with ffmpeg as a slow zoom over a hand-labelled Wikimedia Commons photo (CC licensed sources). One request per clip asks the four `driving`
questions and a Box. "Native" sends the clip itself; "frames" sends the timed frames.
Latency is the server's own, laptop to provider; p50 and p90 are over fresh calls (a clip asked
under two questions is answered once, then from the cache).

| Path | Model | Question | n | Positives | Accuracy | Precision | Recall | p50 | p90 | $ per clip |
|---|---|---|---|---|---|---|---|---|---|---|
| Native | Gemini 3.1 Flash-Lite | phone in hand | 35 | 22 | 91% | 100% | 86% | 2.9 s | 10.4 s | 0.0005 |
| Native | Gemini 3.1 Flash-Lite | no helmet | 42 | 18 | 93% | 100% | 83% | 2.8 s | 5.7 s | 0.0005 |
| Native | Gemini 3.1 Flash-Lite | no seat belt | 6 | 2 | 100% | 100% | 100% | cached | cached | |
| Native | Gemini 3.1 Flash-Lite | eyes closed | 11 | 3 | 82% | 100% | 33% | 3.0 s | 6.0 s | 0.0005 |
| Native | Gemini 3.1 Flash-Lite | **all** | 94 | 45 | 91% | 100% | 82% | 2.8 s | 7.8 s | 0.0005 |
| Frames | Qwen3-VL 235B on Bedrock | phone in hand | 35 | 22 | 86% | 100% | 77% | 3.1 s | 3.5 s | 0.0018 |
| Frames | Qwen3-VL 235B on Bedrock | no helmet | 42 | 18 | 95% | 100% | 89% | 3.0 s | 3.6 s | 0.0018 |
| Frames | Qwen3-VL 235B on Bedrock | no seat belt | 6 | 2 | 100% | 100% | 100% | cached | cached | |
| Frames | Qwen3-VL 235B on Bedrock | eyes closed | 11 | 3 | 91% | 100% | 67% | 3.1 s | 3.3 s | 0.0018 |
| Frames | Qwen3-VL 235B on Bedrock | **all** | 94 | 45 | 91% | 100% | 82% | 3.0 s | 3.5 s | 0.0018 |
| Frames | Gemini 3.1 Flash-Lite | phone in hand | 35 | 22 | 89% | 100% | 82% | 4.3 s | 5.7 s | 0.0013 |
| Frames | Gemini 3.1 Flash-Lite | no helmet | 42 | 18 | 95% | 100% | 89% | 3.5 s | 6.3 s | 0.0013 |
| Frames | Gemini 3.1 Flash-Lite | no seat belt | 6 | 2 | 100% | 100% | 100% | cached | cached | |
| Frames | Gemini 3.1 Flash-Lite | eyes closed | 11 | 3 | 100% | 100% | 100% | 3.8 s | 11.7 s | 0.0013 |
| Frames | Gemini 3.1 Flash-Lite | **all** | 94 | 45 | 94% | 100% | 87% | 3.7 s | 6.3 s | 0.0013 |

277 of the 282 answered calls returned a Box, and every one of those carried `at_ms`; the other 5
returned no Box. Two calls on the Gemini frame path failed at the provider on the first
run and were answered on a second; the table keeps each clip's last call. Total spend $0.28.

**Against the quality bar:** precision passes (100% on every path, bar 95%). Recall does not (82%
to 87% over all questions, bar 90%; best is no helmet at 89%). Latency does not (p50 2.8 s to
3.7 s, bar 1.5 s; p90 3.5 s to 7.8 s, bar 2.5 s). The set is smaller than the bar asks (45
positives and 49 negatives over four questions, bar 50 and 50 per question). The misses are kept in the
eval's call log for the next round.

## Known limits

- The clips above were made from still photos, so the frame path saw 3 near-identical
  frames of each; a real clip with movement is sampled at scene changes and may land on a frame
  where the thing asked about is not visible.
- Frames are picked by a fixed rule (scene changes plus one every 2 s), not by the question, so a
  short event between two picked frames can be missed.
- A Box with `at_ms` is as exact as the frame times the model saw; on the native Gemini path the
  model picks the time itself.
- No real recorded clip with motion, and no clip longer than 6 s, has been measured yet.
- ffmpeg is an outside program: a server without it answers pictures and audio but not video.
