# Closeup: Keeping a take

> Trim a take, change its speed, keep it as a video or a GIF, and add buttons of your own that send it somewhere.

Source: https://cesarvenzac.com/closeup/docs/keeping

A finished take plays in a sheet, with Download, and any buttons of your own beside it.

## Trim and speed

Drag the yellow handles to trim a video, or move them with the arrow keys, a tenth of a second at a time or a second with Shift. Play it at 0.5×, 1×, 1.5× or 2×. The preview loops the part kept, at its speed, and Download saves it as kept; your own actions get the video as kept too.

## Video or GIF

- A video trimmed or sped is played through once at that speed and recorded again, its sound kept at its pitch: it takes as long as the edited take lasts.
- A GIF is 15 frames a second, at most 800 pixels wide, with one palette for the whole take, its most used colours kept exactly and a median cut of the rest. Each frame stores only what changed, so a page that mostly holds still weighs little. It loops.

## A regular MP4

Chrome records a fragmented MP4, with no index of its samples and a length of zero, which some players and editors trip on. Closeup rewrites it as a regular MP4 when the take stops: the same samples, not encoded again, indexed, with its length.

## Your own actions

`addAction` puts a button of your own on the finished take, beside Download, to keep it somewhere:

```typescript
import { addAction } from "@cesarvenzac/closeup";

addAction({
  label: "Save to library",
  // Optional: its icon, as paths on a 24-unit grid.
  icon: `<path d="M12 13v8"/><path d="m8 17 4-4 4 4"/>`,
  // Optional: which takes to offer it on.
  when: (take) => take.kind === "video",
  async run(take, { progress }) {
    await upload(take.blob, progress); // progress(0…1)
    return "Saved."; // said when it's done
  },
});
```

A take is `{ kind, blob, type, width, height, seconds?, script? }`: a photo or a video, its file and type, its size, its length, and the script it played if one did. A video trimmed or sped is made first, then the button counts up while `run` works; once it's done it shows a tick and stays pressed, and what `run` returned is said. A thrown error's message is said instead, and the button can be pressed again. `addAction` returns what takes it away again.

## Closeup's docs

- [Overview](https://cesarvenzac.com/closeup.md): Film any part of a web page in close-up, sharp at any size, with a drawn cursor and sound.
- [Getting started](https://cesarvenzac.com/closeup/docs/getting-started.md): Install Closeup, open it on a shortcut or on an element, and film a first take.
- [Filming](https://cesarvenzac.com/closeup/docs/filming.md): Picking what to film, the frame and its background, the cursor, and the camera that closes in on clicks and pans as you scroll.
- [Scripts](https://cesarvenzac.com/closeup/docs/scripts.md): Draw the cursor's path once and play it on every take: the editor, what each point does, and the JSON a script is kept as.
- [Keeping a take](https://cesarvenzac.com/closeup/docs/keeping.md): Trim a take, change its speed, keep it as a video or a GIF, and add buttons of your own that send it somewhere.
- [API reference](https://cesarvenzac.com/closeup/docs/api.md): Everything the package exports: opening it, actions on a take, scripts, and their types.
