---
title: "Export Video to MP4 | Rendley SDK Docs"
description: "Export video to MP4 or WebM with the Rendley SDK. Configure resolution, bitrate, format and track progress. Client-side or server-side."
url: https://docs.rendley.com/sdk/getting-started/export/
---

# Export

The Rendley SDK allows you to export the final video using both [client-side](https://docs.rendley.com/sdk/rendering/render-on-device/) and [server-side](https://docs.rendley.com/sdk/rendering/render-on-server/) approaches. Each method has its strengths and weaknesses, so you can choose the one that best fits your application needs.

To export the final video, simply call the [`export()`](https://docs.rendley.com/sdk/api-reference/classes/Engine.html#export) function, which will return an [`ExportResult`](https://docs.rendley.com/sdk/api-reference/interfaces/ExportResult.html) containing a Blob (or an `outputChunkHelper` for chunked output) and the file extension.

```
const result = await Engine.getInstance().export();
```

### Export segments of the video

In addition to exporting the complete video, you can also export specific segments. To do this, specify the `from` and `to` parameters in seconds.

```
const result = await Engine.getInstance().export({
  from: 1.02,
  to: 5.33,
});
```

### Export specific tracks

You can specify which tracks to export by setting the `type` parameter to either `video_only` or `audio_only`.

To export only the video track:

```
const result = await Engine.getInstance().export({
  type: "video_only",
});
```

To export only the audio track:

```
const result = await Engine.getInstance().export({
  type: "audio_only",
});
```

If the rendering is successful, the [`result`](https://docs.rendley.com/sdk/api-reference/interfaces/ExportResult.html) variable will contain the final Blob of the video, along with the file extension.

### Resolution scaling

You can export the project at a different resolution than the one configured on the [Display](https://docs.rendley.com/sdk/getting-started/display/). `resolutionScale` multiplies both dimensions:

```
const result = await Engine.getInstance().export({
  resolutionScale: 0.5, // 1920x1080 becomes 960x540
});
```

### Canceling an export

An export can be canceled in flight:

```
await Engine.getInstance().cancelExport();
```

The SDK emits `render:canceled` on the event bus once the cancellation is done. Use [`Settings.setRenderCancelFailTimeout`](https://docs.rendley.com/sdk/getting-started/settings/#cancel-timeout) to configure how long the SDK waits before forcing the stop.

### Large files and chunked output

When your rendered file exceeds the browser’s allocation limit (around 2GB on Chrome), enable chunked output in the [Settings](https://docs.rendley.com/sdk/getting-started/settings/#chunked-output-2gb-files). The exported result will be returned as an [`OutputChunkHelper`](https://docs.rendley.com/sdk/api-reference/classes/OutputChunkHelper.html) instead of a single blob:

```
Engine.getInstance().getSettings().setRenderUseChunkedOutput(true);

const result = await Engine.getInstance().export();

if (result?.outputChunkHelper) {
  const helper = result.outputChunkHelper;
  const chunks = helper.getChunks();

  for (const chunk of chunks) {
    const bytes = await helper.readChunkAsBytes(chunk.id);
    await uploadToServer(bytes); // or stream to OPFS, a worker, etc.
    helper.removeChunk(chunk.id); // free memory as soon as the chunk is written
  }
}
```

Each chunk reports its `id`, `size`, and position in the output. Read it in whichever form suits the destination:

| Method | Returns | When to use |
| --- | --- | --- |
| `readChunkAsBytes(id)` | `Uint8Array` | Streaming to a fetch body, OPFS, or a worker. |
| `readChunkAsBlob(id)` | `Blob` | Passing to a browser API that needs a `Blob`. Doubles memory use during the read. |
| `readChunkAsUrl(id)` | `string` (object URL) | Previewing a chunk in a `<video>` or an `<a href>`. Revoke the URL after use. |
| `removeChunk(id)` | `void` | Free a chunk once you’ve moved it somewhere safe. |
| `removeAllChunks()` | `void` | Tear everything down at once. |

#### Native save dialog

On browsers that support the File System Access API, `OutputChunkHelper` can pipe every chunk into a user-chosen file in one call:

```
const helper = result.outputChunkHelper;

if (helper.isSaveToFileSupported()) {
  await helper.browseAndSaveToFile("my-video.mp4", (progress) =>
    console.log(`Saved ${Math.round(progress * 100)}%`),
  );
}
```

The picker returns control when the user selects a destination, then streams chunks straight to disk without keeping them all in memory.

Warning

Avoid using the `readMergedChunks*` helpers on `OutputChunkHelper` for browser-side merging, they are bound to the browser’s max allocation size. Stream the chunks directly to disk, OPFS, or a network endpoint.

### Tracking progress

Listen to the [Engine events](https://docs.rendley.com/sdk/user-interface/listening-to-events/) to track progress and completion:

```
Engine.getInstance().events.on("time", (time) => {
  console.log("Current time:", time);
});

Engine.getInstance().events.on("render:completed", () => {
  console.log("Export completed");
});

Engine.getInstance().events.on("render:error", ({ name, message }) => {
  console.error("Export failed:", name, message);
});
```

Info

To learn more about on-device rendering and best practices, check out this [guide](https://docs.rendley.com/sdk/rendering/render-on-device/).

Info

To learn more about server rendering and best practices, check out this [guide](https://docs.rendley.com/sdk/rendering/render-on-server/).

## What to read next

- **[Render in the browser](https://docs.rendley.com/sdk/rendering/render-on-device/)** encodes on the user machine with WebCodecs.
- **[Render on a server](https://docs.rendley.com/sdk/rendering/render-on-server/)** runs the same pipeline headlessly for production volume.
- **[Best practices](https://docs.rendley.com/sdk/best-practices/)** covers memory, preloading and keeping playback smooth.

[Previous pageFFmpeg in the browser](https://docs.rendley.com/sdk/getting-started/ffmpeg/) [Next pageRender in the browser](https://docs.rendley.com/sdk/rendering/render-on-device/)
