# Trim & process video

Canonical: https://interlatent.com/docs/ivy/trimming

Trim video by timestamps or meaningful action sections, create processed views, and keep source and output times clear.

## Subtask segmentation and semantic trimming

Section: https://interlatent.com/docs/ivy/trimming#semantic-trimming

Describe the sections you want to keep, such as each item-placement step in a packing video. Ask your agent to use segment_subtasks with a convention that defines those steps. Review the labeled sections, then export the selected intervals as separate clips. Your prompt can steer section size, labels, and boundary rules.

### Prompt

```text
Use subtask segmentation to separate this video into packing steps. Start a new section when the immediate action changes, and retain repeated attempts. Show me the timestamped sections. After I select the steps to keep, export each one as a separate MP4 with half a second of context on each side.
```

- [Subtask segmentation and semantic trimming guide](https://interlatent.com/docs/ivy/subtask-segmentation)

## Extract a time range

Section: https://interlatent.com/docs/ivy/trimming#extract

Give your agent the episode, camera, and start and end times. Ask for a separate video artifact when you want an excerpt while keeping the source recording. Check the returned duration and inspect the beginning and end of the exported interval.

### Prompt

```text
Create a separate video excerpt from 12 to 24 seconds of this episode’s main camera. Preserve the source recording. Return a downloadable MP4 and inspect the first and last frames. State the source interval and the output duration.
```

Note: The interval uses seconds on the source clip. In a new excerpt, output time starts at zero: source time 12 seconds becomes output time 0 seconds.

## Find a segment from annotations

Section: https://interlatent.com/docs/ivy/trimming#from-labels

Use existing annotations to locate an action before cutting video. Ask for an interval with context, such as one second before a grasp and one second after it. If several intervals match, review the interval list before generating the excerpts.

### Prompt

```text
Find saved “grasp” intervals in this episode. List each interval with one second of context on either side, clamped to the video duration. After I choose an interval, export it as a separate MP4. Keep the source unchanged.
```

- [Query action intervals](https://interlatent.com/docs/ivy/query-reference)

## Create a processed view

Section: https://interlatent.com/docs/ivy/trimming#derived-views

A Python recipe can resize frames, draw timestamps or measurements, crop a fixed region, and render a new video view. Specify the camera, interval, output dimensions, and playback rate. Tell your agent whether a crop should be fixed or follow a tracked object.

### Prompt

```text
Create a separate processed view for 0–10 seconds of this episode: half-resolution frames with the source timestamp in the top-left corner. Keep the source frame rate and preserve the source video. Return the new view and inspect its first, middle, and last frames.
```

Note: Cropping or resizing changes image coordinates. A saved detection box must be transformed before it can be drawn on a differently sized view.

## Use ffmpeg for explicit transformations

Section: https://interlatent.com/docs/ivy/trimming#ffmpeg

For an ffmpeg operation, specify the intended output rather than only a command: interval, resolution, frame rate, codec, and whether audio should be retained. Your coding agent can process a downloaded video locally, or use supported processing inside an annotation recipe. A local ffmpeg command does not update the Ivy project.

### Prompt

```text
Help me create a browser-playable MP4 excerpt from this video, source seconds 12–24, at 640 pixels wide with aspect ratio preserved. Tell me whether you will run ffmpeg locally on a downloaded file or create an Ivy artifact. Keep the source and report any frame-rate or audio changes.
```

- [Python and ffmpeg examples](https://interlatent.com/docs/ivy/custom-code#ffmpeg)

## Editing the working clip

Section: https://interlatent.com/docs/ivy/trimming#edit-source

An in-place trim changes the working clip rather than creating a separate excerpt. A whole-clip trim across cameras also changes its time base; time-bound annotations and recorded data need to follow that edit. A single-camera edit has different synchronization implications. Specify the scope before making either change.

Note: Use a separate artifact for excerpts and overlays. If you intend to change the working clip, ask your agent to explain the camera and timeline effects first. This does not modify an already built Dataset snapshot.

## Choose an artifact or a Dataset export

Section: https://interlatent.com/docs/ivy/trimming#export

Use an artifact for a preview, excerpt, overlay, or report. Build a Dataset when you need an export of recordings with their annotations and derived outputs. Review the build estimate to see the selected recordings and which derived cameras or episode files will be included.

- [Review & export](https://interlatent.com/docs/ivy/review-and-export)
