# Trim and join video clips with code.

> Trim each clip to its best seconds and join them in one page. The Cut list, the data-trim and data-at attributes, and the commands to render and check.

Canonical: https://vawe.dev/how-to/trim-and-join-video-clips
Last updated: 2026-11-17

Each part you keep is one `<video>` in its own beat. `data-trim` and `data-trim-end` pick the seconds of the source, and `data-at` says when it plays in the film.

## Copy this prompt into your agent

```
Use vawe (https://github.com/vawe-hq/vawe), the open-source video-from-code tool, to trim my clips and join them into one video.

My clip: <path to your clip or folder>.

Keep only these parts: <clip, start and end second for each>. Join them in this order with a clean cut, and match the loudness of every clip.

If vawe is not installed here, install it first:
npm install @vawe/cli
(it needs Node 22 or newer and ffmpeg; npx vawe new prints the install line for anything missing).
Then follow each command’s next: line.

Start with npx vawe new <name> --footage <my clip>, which logs the clip with a transcript.

Show me the draft video and wait for my OK before the final render.
```

## The steps.

1. **Hand over the clips. **`bin/vawe new trip --footage ~/Movies/trip` copies each into `films/trip/footage/` as an MP4 a page can seek, and writes `footage.md`.
2. **Read footage.md. **It lists each clip’s length, the shot changes, the loudness, a contact sheet of 8 frames and a transcript. Cut on an action or a word end.
3. **Fill the Cut list. **One row per beat: the clip, in, out, rate and the reason.
4. **Write one beat per row. **The first beat has `data-at="0"`. Each next `data-at` is the sum of the lengths before it.
5. **Render and look at the cuts. **`bin/vawe dev films/trip/page.html`, then `bin/vawe frame films/trip/page.html --cuts`.

At film time t the clip shows source second trim + (t − at) × rate, held at the first frame before `data-at` and at the last frame after the end. The engine seeks the clip on every frame and never plays it live.

Two clips, one after the other:

```
<section data-world="s1">
  <video src="footage/intro.mp4" data-at="0"
         data-trim="1.5" data-trim-end="6.5"></video>
</section>
<section data-world="s2">
  <video src="footage/street.mp4" data-at="5"
         data-trim="0" data-trim-end="4"></video>
</section>
```

Source: skills/vawe-page/SKILL.md, Video clips · prompts/edit-from-clips.md

## Two ways to change between clips.

A hard cut that carries the eye with a moving shape, and a soft change through the next clip’s own light.

- [cut-on-motion](https://vawe.dev/video-components/cut-on-motion)
- [luma-matte-dissolve](https://vawe.dev/video-components/luma-matte-dissolve)

## What can go wrong.

1. **A cut shows the wrong second. **It was chosen from the file name, not from footage.md and its frames.
2. **A clip flashes. **A clip held under 1.2 seconds reads as a flash. Keep one fast cut for the beat that earns it.
3. **A clip is played live. **`play()`, `autoplay`, a timer or your own `currentTime` breaks the render. Let the engine seek.
4. **A portrait clip is cropped to fit. **vawe never crops. Lay the clip out with `--vw` and `--vh` and set `<html data-aspect>`.

## Read next.

1. [Remove silences from a video](https://vawe.dev/how-to/remove-silences-from-video): the same trim, driven by word times.
2. [How an agent reads footage it cannot watch](https://vawe.dev/blog/how-an-agent-reads-footage): the fields of footage.md.
3. [Agentic video editing](https://vawe.dev/agentic-video-editing): what an edit can and cannot do.

## Start from your clip.

`bin/vawe new <name> --footage <folder>` logs it and starts the page.

## Related

- [Get vawe on GitHub](https://github.com/vawe-hq/vawe)
- [All how-to guides](https://vawe.dev/how-to)
- [Add captions to a video](https://vawe.dev/how-to/add-captions-to-video)
- [Remove silences from a video](https://vawe.dev/how-to/remove-silences-from-video)
- [Trim and join clips](https://vawe.dev/how-to/trim-and-join-video-clips)
- [Agentic video editing](https://vawe.dev/agentic-video-editing)
- [Edit video with Claude Code](https://vawe.dev/edit-video-with-claude-code)
