# Exporting

> Render a project to an MP4, GIF, WAV or AAC file, wait for it, and find the verified file.

Source: https://stuarty.com/docs/guide/exporting/

## You will learn

- how to start an export and follow it;
- what must be true before an export is accepted.

## The idea

An export is a **job**. It renders the current revision, encodes an MP4 with FFmpeg and verifies the file (streams, duration, dimensions, pixel format and fast start) before the job is marked `succeeded`. A file that fails verification is never reported as done.

The export is refused while the lint finds an error, with `E_LINT_BLOCKING` and the first findings. Warnings never block.

## Quick start

**CLI**

```bash
stuarty lint --project prj_7k2m9x4q1b
stuarty export --project prj_7k2m9x4q1b
```

The CLI waits for the job. Use `--no-wait` to return at once and `stuarty job:show <job id> --wait` later.

**MCP**

`job_start` with `{"project_id": "prj_7k2m9x4q1b", "kind": "export", "wait_ms": 25000}`, then `job_get` with `wait_ms` until the state is final.

The result of a succeeded export has the file path under `<workspace>/exports/<project id>/<job id>.<extension>`, its size and its duration.

## Formats

An export is an MP4 unless you choose another format with `--format` (CLI) or `args.format` (MCP and HTTP API).

| Format | File | What it is |
| --- | --- | --- |
| `mp4` | `.mp4` | H.264 video and AAC audio (the default); needs an H.264 encoder |
| `gif` | `.gif` | the composed frames, no audio; needs no encoder; always opaque (the project background is drawn into every frame, there is no transparent GIF); capped at 480 pixels wide (the height keeps the aspect) and 15 fps, and the job warns when it scales the project down |
| `wav` | `.wav` | the audio mix as 16-bit PCM, 48 kHz, stereo |
| `aac` | `.m4a` | the same mix as AAC in an MP4 container |
| `png` | `.png` | one frame at the size of the project, chosen with `--at` (the start by default) |

```bash
stuarty export --project prj_7k2m9x4q1b --format gif
stuarty export --project prj_7k2m9x4q1b --format png --at 2s
```

With MCP: `job_start` with `{"project_id": "prj_7k2m9x4q1b", "kind": "export", "args": {"format": "wav"}}`. For a frame, add `"at": "2s"` to `args`; `at` is only for `png`.

### Choose the range

`--start` and `--end` export only part of the timeline (by default, all of it).

### Copy the file where you want it

The workspace keeps the file under `exports/`. `--out <file>` also copies it to the path you give once the job succeeds (it implies `--wait`, and the workspace keeps its own copy). It refuses to replace a file unless you add `--force`.

```bash
stuarty export --project prj_7k2m9x4q1b --out ~/teaser.mp4
```

## Exchange a timeline with OpenTimelineIO

`otio:export` writes the timeline of a project as an [OpenTimelineIO](https://opentimelineio.org) file, to open it in another editor. It writes the file on the machine that runs the command, in the current folder as `<project name>.otio`, or where `--out` says; it refuses to replace a file unless you add `--force`. The command lists what the format cannot carry (for example effects), so nothing is lost silently.

```bash
stuarty otio:export --project prj_7k2m9x4q1b --out cut.otio
stuarty otio:import cut.otio --project prj_7k2m9x4q1b --dry-run
stuarty otio:import cut.otio --project prj_7k2m9x4q1b --base-revision 12
```

`otio:import` reads a file from the machine that runs the server and applies it to the project as one batch, so one `undo` reverts it. The frame rate of the file must be the project's. The media of the file are never opened: a reference is matched by name to an asset already in the project, and the ones that match nothing are listed as unresolved. `--dry-run` shows what would change; `--base-revision` defaults to the current revision. The HTTP API has `GET` and `POST /api/v1/projects/{id}/otio`. There is no MCP tool for OpenTimelineIO.

## Export a project bundle

A bundle is one file, `<name>.vvbundle`, that holds a project and everything it needs, to back it up or hand it to someone else. It is a zip with the project document, the original media, the fonts the project uses and, unless you leave it out, the operation log with the history of edits. Proxies, thumbnails and transcripts are not included; they are made again when the bundle is opened.

A project made of texts alone, with no timeline, exports too: its bundle holds the description, the goal, the brief and the texts, and has no document, log or media. It needs a release that reads it; an older one refuses it and asks to be updated.

```bash
stuarty bundle:export --project prj_7k2m9x4q1b --wait
stuarty bundle:export --project prj_7k2m9x4q1b --no-log --wait
stuarty bundle:export --project prj_7k2m9x4q1b --out ~/launch-teaser.vvbundle
```

Like an export, a bundle is a job: `--wait` follows it, and the file is written under `<workspace>/exports/<project id>/` as `bundle-r<revision>-<job id>.vvbundle`. `--no-log` leaves the history out, which hides who edited and why. A project in the trash cannot be exported. `--out <file>` copies the bundle out of the workspace when the job succeeds (it implies `--wait`, creates missing folders, and refuses to replace a file unless you add `--force`); against a remote server it downloads the file instead. The same `--out` works on `export` and `template:export`. The command prints the final path.

## Import a project bundle

`bundle:import` creates a project from a `.vvbundle` file. It reads the file on the machine that runs the server, checks it before it changes anything, and copies the media and the fonts it carries into the workspace. The project opens at once; its assets show as ingesting while the proxies, thumbnails and transcripts are made again.

```bash
stuarty bundle:import launch-teaser.vvbundle
stuarty bundle:import launch-teaser.vvbundle --as-new
stuarty bundle:import launch-teaser.vvbundle --dry-run
```

Without `--as-new` the project keeps its id and its history of edits. If a project with that id exists, even in the trash, the import is refused with `E_ID_EXISTS`. With `--as-new` the project gets a new id and starts at revision 1 with no history, because the history of another project does not belong to a new one. A server with accounts requires `--as-new`. `--dry-run` checks the file and reports what would be created. A file that is damaged, too large, has a different format or comes from a newer version of the product is refused with `E_VALIDATION` and a reason, and nothing is imported. The HTTP API has the same operation as `POST /api/v1/projects/import`.

There is no MCP tool for bundles. The projects page of the editor has **Import a bundle** (a file path on the machine of the server, with the option to import as a new project) and **Export bundle** on each project.

## Draw the export on the GPU (optional)

By default the export draws every frame on the CPU, and the output is the same on every machine. A GPU path exists for machines with a graphics adapter, but `stuarty-render`, the helper program that runs it, is **not shipped yet**: no archive, installer or image carries it. To try it, build it from the source (it needs the Rust toolchain pinned in `rust-toolchain.toml`):

```sh
bash scripts/build-renderer.sh host
```

This writes `renderer/dist/stuarty-render` (`stuarty-render.exe` on Windows) and its SHA-256. Copy the file next to the server executable, or into `../libexec/stuarty/` relative to it (the server looks next to the executable first, as it does for FFmpeg), then start the server with:

```sh
STUARTY_EXPORT_RENDERER=gpu stuarty serve
```

`stuarty-render --probe` tells whether the machine has an adapter. When the helper is missing, has no adapter, or runs inside a sandbox that hides the devices, the export falls back to the CPU path and still succeeds.

## Export an image

An image document exports to PNG (the default), JPEG or WebP with `stuarty image:export <id> --format webp`. WebP is lossless unless you give `--quality` from 1 to 100, and it keeps transparency; PNG does too, and JPEG is flattened on white. `--preset` or `--width` and `--height` resample the result. The file lands in `exports/images/<id>/` of the workspace. WebP is encoded by the bundled FFmpeg, so a build without the `libwebp` encoder answers `E_EXPORT_FAILED` with the reason `webp_unavailable`; PNG and JPEG still export.

## Common mistakes

- No H.264 encoder works on this machine: `E_NO_ENCODER`. `gif`, `wav` and `aac` still export.
- Importing a bundle whose project id already exists: `E_ID_EXISTS`. Use `--as-new`.
- Too many exports at once: `E_QUEUE_FULL`, retryable. `STUARTY_MAX_EXPORTS` sets the limit.

## Next steps

- [How an agent verifies its work](/docs/agents/verify)
