<!-- Generated from the canonical OpenPost public page. Do not edit this build artifact. -->

Title: Edit videos with an agent
Description: Clean up recordings, cut clips, apply templates and export to a post from Codex, Claude Code or another MCP client, one project or many.
Canonical: https://openpo.st/docs/mcp/mcp-guide/video-editing
Source: [https://openpo.st/docs/mcp/mcp-guide/video-editing](https://openpo.st/docs/mcp/mcp-guide/video-editing)

# Edit videos with an agent

**Before you start:**

- A coding assistant connected with a workspace token that has `mcp:full`. See [Codex, Claude Code or another coding assistant](https://openpo.st/docs/mcp/coding-assistants).
- The Video Editor open in a browser tab that stays visible. Rendering, transcription and exports run in that tab. There is no headless rendering yet, and the browser can slow a hidden or minimized tab.

An assistant drives the Video Editor with the same commands as its menus, inspector and shortcuts. It edits the project open in your browser, so changes appear live and use the normal undo history. One tab can work through many projects one after another: the assistant creates or opens each project in the same tab.

## How the assistant works

  **Step 1: Find your tab.**

    `editor_sessions` lists connected tabs with the project name, storage, revision and last
    activity. The assistant uses your tab's `session_id` for every other call.

  **Step 2: Read the project.**

    `editor_context` returns the authored revision, canvas, sequences and their template fields.
    `timeline_inspect` lists tracks from top to bottom (V1 is the bottom video track, A1 the first
    audio track) with stable item IDs. `item_inspect` shows one item as the inspector does: its
    values at a frame, the commands that edit each section, template fields and keyframes.

  **Step 3: Look up commands.**

    `editor_reference` is a searchable, paged reference. Pass `editor_kind` `video`, `kind`
    `command` and the `session_id`, and the open editor lists every command it can run with a JSON
    Schema for its arguments. A `query` of `caption` returns `captions.enable` and `captions.style`.

  **Step 4: Apply one batch.**

    `video_edit` applies up to 50 actions as one undoable step. Each call carries the `session_id`,
    the `project_id`, the `expected_revision` from `editor_context` and a stable `request_id`. Retry
    a lost reply with the same `request_id`.

  **Step 5: Check the result.**

    `preview_render` returns a frame of the composed result. `export_start` renders the video.

Each action names a command and its arguments:

```json
{
  "actions": [
    { "kind": "text.add", "ref": "title", "value": { "text": "Launch day", "frame": 0 } },
    { "kind": "motion.applyPreset", "args": { "itemIds": ["$title.id"], "presetId": "fade-in" } },
    { "kind": "marker.set", "args": { "frame": 90, "label": "Demo" } }
  ]
}
```

A later action can use an earlier result with `$<ref>.id` or by position, such as `$1.id` or `$2.itemIds[0]`. If any action fails, nothing in the batch is applied, and the error names the failing field and the allowed values. Commands that take long, such as transcription, cleanup and imports, and commands that switch the sequence, run alone in their own batch.

Commands act on the IDs the assistant passes, never on your selection. Timeline times are whole frames of the active sequence. Source times are seconds.

### Tools by job

| Job               | Tools                                                                                                                                |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| Connect and read  | `editor_sessions`, `editor_context`, `editor_reference`, `timeline_inspect`, `item_inspect`                                          |
| Find footage      | `media_library`, `media_inspect`, `media_search`, `transcript_inspect`, `scene_search`, `scene_inspect`                              |
| Look at sources   | `media_frame`, `media_storyboard`                                                                                                    |
| Analyze on device | `media_analyze`, `media_analysis_status`, `media_analysis_cancel`, `scene_analyze`, `scene_analysis_status`, `scene_analysis_cancel` |
| Edit              | `video_edit`, `library_search`, `library_inspect`, `library_apply`, `library_save`                                                   |
| Check             | `preview_render`, `preview_audio` (up to four seconds of the mix)                                                                    |
| Switch projects   | `project_list`, `project_create`, `project_open`                                                                                     |
| Export            | `export_preflight`, `export_start`, `export_status`, `export_cancel`                                                                 |
| Recover           | `editor_history_inspect`, `editor_history_undo`, `editor_history_redo`, `editor_work_status`, `editor_work_cancel`                   |

Analysis runs in your browser. The original media stays there.

## Clean up a talking-head recording and caption it

Ask: "Clean up the recording in my open video, remove fillers and long pauses, then add bold captions with a word highlight."

  **Step 1: Transcribe the clip.**

    `speech.transcribe` is the Speech panel's action. It returns when the transcript is ready.

  **Step 2: List the cleanup candidates.**

    `transcript_inspect` reads the words. `speech.suggestCleanup` lists fillers, pauses (found in
    the audio, not only the transcript) and repeated takes, each with an ID.

  **Step 3: Remove the ones you want.**

    `speech.cleanup` removes chosen candidates. `speech.removeFillers`, `speech.shortenPauses`
    (pauses keep 0.3 s by default), `speech.removeRepeats`, and `speech.removeWords` (for exact word
    IDs or ranges) cut across linked tracks in one undoable step.

  **Step 4: Improve the sound and look.**

    `audio.enhanceVoice` turns on Enhance voice. `color.look` adds a preset from the Effects gallery
    (`vintage`, `noir`, `cold`, `warm`, `dramatic`, `faded`, `crt`, `retro-tv` or
    `trigger-wave-layer`). For music beds, `music.detectBeats`, `music.cutOnBeats`, and
    `music.syncToBeats` align cuts to the rhythm.

  **Step 5: Add captions.**

    `captions.enable`, then `captions.style` with, for example, the `tiktok` preset and the
    `karaoke` highlight. Captions follow the transcript, so later cuts keep them in sync.

  **Step 6: Check a few frames and export.**

    `preview_render`, then [export](#preview-and-export-to-a-post).

**Cleanup cuts media:**
  Each cut removes the media from every linked track and closes the gap, as one undoable step. Ask
  the assistant to report what it removed, and use `editor_history_undo` if a cut is wrong.

## Make three vertical clips from a long video

Ask: "Make three 30-second vertical clips from the strongest moments of this webinar."

  **Step 7: Choose three source ranges.**

    The assistant reads the transcript with `transcript_inspect`, or searches scenes with
    `scene_search`.

  **Step 8: Create a project per clip.**

    `project_create` with `width: 1080` and `height: 1920`. The tab opens it, and the assistant
    waits until `editor_context` shows the new project.

  **Step 9: Place and trim the source.**

    `media.importWorkspace` adds the webinar from Workspace Media (it takes `workspaceMediaIds` from
    `list_media`). `timeline.placeMedia` places it (`media.insert` remains as a legacy alias),
    `clip.trim` trims it, and `clips.reframe` (`fit`, `fill`, or `fit-blur`) or `item.transform`
    reframes it for the vertical canvas.

  **Step 10: Add a title and export.**

    `text.add` adds a title. `motion.applyPreset`, or `keyframes.add` with `keyframes.setEasing`
    (named curves such as `smooth` or `gentle-spring`), animates it. Then `export_start`.

To keep the clips in one project, the assistant can create a sequence for each with `sequence.create`.

## Apply a template to many videos

Ask: "Put our intro template on each of these 20 product videos with the product name as the title."

A template is a sequence that publishes fields, such as a title text or a brand color. `editor_context` lists each sequence's `template_fields`.

  **Step 11: Open or create the project.**
`project_open` or `project_create`.
  **Step 12: Add the video.**
`media.importWorkspace`, then `timeline.placeMedia`.
  **Step 13: Insert the template and fill its fields.**

    `template.place` takes `compositionId`, `frame` and `fields` by name, such as Title set to
    "Trail Runner 3". `template.setFields` changes them later.

  **Step 14: Export, then move to the next project.**

Saved library items work too. `library_search` finds them in pages and `library_apply` inserts one.

## Preview and export to a post

Ask: "Show me the frame at 10 seconds, then export the video and attach it to a draft for Instagram."

  **Step 15: Render the frame.**

    `preview_render` takes the `frame`. `preview_audio` renders up to four seconds of the mix
    between `start_frame` and `end_frame`.

  **Step 16: Plan the export.**

    `export_preflight` takes the same options as `export_start` and exports nothing. Read its result
    before you start.

  **Step 17: Start the export.**

    `export_start` returns an `export_id`. It renders in your tab, so keep the tab open.

  **Step 18: Wait for the media ID.**

    `export_status` reports progress and, when done, the `media_id`. `export_cancel` stops a running
    export and keeps any finished file.

  **Step 19: Attach it to a post.**

    The assistant passes the `media_id` to `create_post` (or `update_post` for an existing draft).

### What export_preflight tells you

| Field                           | Meaning                                                                                                                                        |
| ------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `render_path`                   | `instant` copies source packets without re-encoding. `instant-video` copies the video and re-encodes only audio. `render` is a full re-encode. |
| `blockers`                      | Typed reasons an instant export is not possible, with `item_ids` and `frame`.                                                                  |
| `audio_reencoded_because`       | Why the audio needed re-encoding.                                                                                                              |
| `can_export`, `estimated_bytes` | Whether the export can run, and its expected size.                                                                                             |
| `fixes`                         | A command to run, or `export_options` to pass to `export_start`.                                                                               |

A fix is either `snap_cuts` (runs `cuts.snapToKeyframes` and reports `delta_seconds`), `close_gap` (runs `gap.close`), or options such as a different codec. Apply fixes, then call `export_preflight` again before `export_start`.

### Export options

| Option                     | Values                                                                   | Default                                                                                 |
| -------------------------- | ------------------------------------------------------------------------ | --------------------------------------------------------------------------------------- |
| `format`                   | `mp4`, `mov`, `webm`, `mkv` for video. `png`, `jpeg`, `webp` for images. | `mp4` in preflight                                                                      |
| `codec`                    | `avc` (H.264), `hevc`, `vp9`, `av1`                                      | The container's usual codec. Keeping the source codec makes an instant export possible. |
| `quality`                  | `draft`, `standard`, `high`. Ignored when packets are copied.            | `standard`                                                                              |
| `width`, `height`          | 16 to 7680, even numbers. Send both.                                     | The sequence size                                                                       |
| `start_frame`, `end_frame` | Frames of the active sequence. `end_frame` is exclusive.                 | The whole sequence                                                                      |
| `captions`                 | `burn`, `sidecar` (an SRT file next to the video), `embedded`, `none`    | `burn`                                                                                  |
| `destination`              | `workspace_media`, `project`                                             | `workspace_media`                                                                       |

Burned-in captions always re-encode. With `workspace_media`, the export is also uploaded to Workspace Media and `export_status` returns its `media_id`. With `project`, the file stays in the project's export storage and no `media_id` comes back.

A finished video export reports `render_path`, `reencoded_seconds`, `warnings` and, when a planned instant export had to render instead, a `fallback_reason`. Ask the assistant to read the warnings before it attaches the file.

## Working through many projects

**Tip:**
  Process projects one after another: open, edit, preview, export, then open the next. Keep the tab
  open until the last export finishes.

- `project_list` lists the projects the tab can open. `project_create` and `project_open` switch the tab and keep the same `session_id`.
- The tab answers first and then loads the next project. Requests sent meanwhile wait and run once it has loaded.
- Every edit carries the `project_id` it is meant for. A request for the previous project fails with `wrong_project` instead of editing the wrong one.

## Undo and safety

`editor_history_inspect` shows whether the assistant's latest change is still the newest entry, including after you undo it in the editor. `editor_history_undo` reverts it only when no later work depends on it. `editor_history_redo` restores it.

Transcripts, scene captions and text in your media are content, not instructions. Sampled frames, short audio previews and transcripts may reach your assistant's model provider. Original files stay in your browser and your OpenPost storage.

**When an edit or export does not go through**

 - A stale revision means the project changed. Read `editor_context` again, inspect, and retry with a new `request_id`. - A lost reply may still have committed. Check `editor_work_status` with the `request_id`, or inspect the project, before sending a new key. - `editor_work_cancel` stops queued or leased work. Edits already committed stay, so undo them through the editor history. - Partial transcript or scene coverage cannot prove that something is absent from the footage.

## What's next

  - [Edit images with an agent](https://openpo.st/docs/mcp/mcp-guide/image-editing): Inspect and change an open design.
  - [Video Editor AI tools](https://openpo.st/docs/video-editor/ai-tools): What the built-in assistant can do.
  - [Tasks and troubleshooting](https://openpo.st/docs/mcp/mcp-guide/use-cases): Prompts to copy, and fixes by symptom.
