# Export

MP4, GIF and PNG from the CLI, with social presets, safe areas, captions, seamless loops and motion blur.

`exports` is a map of named targets. `motion-sdk render scene.json --export <name>` renders one; its format decides the output.

```json title="apps/docs/examples/export.json"
{
  "canvas": { "width": 1080, "height": 1080, "fps": 30 },
  "camera": {
    "position": [0, 1, 6],
    "target": [0, 0, 0],
    "move": { "preset": "arc", "easing": "linear" }
  },
  "lighting": { "rig": "neon_rim" },
  "environment": {
    "background": {
      "radial_gradient": { "inner": "#1a0b2e", "outer": "#05030a" }
    }
  },
  "post": { "bloom": 1 },
  "nodes": {
    "knot": {
      "mesh": { "geometry": { "torus_knot": {} }, "material": "preset:neon" }
    }
  },
  "timeline": {
    "duration": 4,
    "loop": "loop",
    "tracks": {
      "spin": {
        "target": "knot",
        "property": "rotation",
        "keyframes": [
          { "t": 0, "value": [0, 0, 0], "easing": "linear" },
          { "t": 4, "value": [0, 360, 0] }
        ]
      }
    }
  },
  "exports": {
    "x": {
      "preset": "x_1x1",
      "captions": [
        { "start": 0, "end": 2, "text": "One prompt.", "style": "bold_pop" },
        { "start": 2, "end": 4, "text": "One loop.", "style": "bold_pop" }
      ]
    },
    "gif": { "preset": "x_gif" },
    "story": { "preset": "tiktok", "framing": "cover" },
    "poster": { "preset": "x_image", "frame_time": 1 }
  }
}
```

![Render of export](/renders/export.jpg)

```bash
motion-sdk render scene.json --export x                       # MP4
motion-sdk render scene.json --export gif --dither fs         # GIF, Floyd-Steinberg
motion-sdk render scene.json --preset slide_16x9 --format png-sequence -o frames/
motion-sdk render scene.json --export x --motion-blur 8       # 8 subframes, 180° shutter
motion-sdk render scene.json --export x --require-seamless    # fail on a loop seam
motion-sdk render scene.json --export x --encoder ffmpeg      # libx264 from PATH
```

## Presets

A preset fixes size, fps, format, the loop default, the platform's duration limit and a safe area.

| Preset | Size | Format | Safe area (top, right, bottom, left) |
| --- | --- | --- | --- |
| `x_16x9`, `x_1x1`, `x_9x16` | 1920x1080, 1080x1080, 1080x1920 @ 30 | MP4 | 5%, 5%, 10%, 5% |
| `x_gif` | 480x480 @ 15 | GIF | 5% |
| `x_image` | 1600x900 | PNG | 5% |
| `linkedin` | 1080x1080 @ 30 | MP4 | 5%, 5%, 10%, 5% |
| `instagram_reel` | 1080x1920 @ 30 | MP4 | 13%, 10%, 22%, 6% |
| `tiktok` | 1080x1920 @ 30 | MP4 | 8%, 12%, 20%, 6% |
| `slide_16x9`, `slide_4x3` | 1920x1080, 1440x1080 @ 30 | MP4 | 5% |
| `slide_still` | 1920x1080 | PNG | 5% |
| `web_embed` | 1920x1080 @ 60 | HTML (browser player, not rendered by the CLI) | none |

The older names `x_landscape`, `x_square` and `x_portrait` still work. Override any field per export, including `width`, `height`, `fps`, `safe_area` and `framing` (`contain` keeps the whole design visible; `cover` crops to fill).

## Captions

`captions` are burned in with `bold_pop`, `minimal`, `karaoke` or `boxed` styles, wrapped to the safe width and kept inside the safe area. X autoplays muted, so caption X exports.

## Frames and Loops

- Frame `i` is at `start + i / fps`, independent of anything rendered before it.
- For looping exports, the frame after the last is compared with the first, and the wrap step with an ordinary step. `--require-seamless` fails the export on a seam.
- `motion_blur: {"samples": 8, "shutter": 0.5}` averages subframes in linear light. A shot's own `motion_blur`, and a `whip` transition, take over for the frames they cover.

## Formats

- **MP4**: H.264 4:2:0, BT.709, fast start, a keyframe every 2 s. Width and height must be even. A scene with [`audio`](/docs/features/timeline#audio) gets an AAC sound track when `ffmpeg` is on PATH, or a WAV beside the video when it isn't.
- **GIF**: one global palette, ordered or Floyd-Steinberg dithering, frame-difference transparency, infinite loop.
- **PNG** and **PNG sequences**: lossless.

## Licensing

H.264 is covered by patents. The default encoder is [OpenH264](https://github.com/cisco/openh264) (BSD-2-Clause), compiled from source. Cisco pays the royalties only for its own prebuilt binaries, so if you ship MP4 export in a product, check whether you need an H.264 patent licence, or build without the `openh264` feature and use `--encoder ffmpeg`. The ffmpeg path links nothing: it runs an `ffmpeg` binary from PATH. GIF and PNG have no such constraints.

## API Reference

### ExportTarget

One output to render. Pick a `preset`, then override anything.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `captions` | `Caption[]` | — | Burned-in captions (X autoplays muted, so captions matter). |
| `duration` | `number (≥ 0)` | — | Seconds to render. Defaults to the main timeline duration. |
| `format` | `ExportFormat` | — | Override the preset's file type. |
| `fps` | `integer (1 to 120)` | — | Override the preset's frame rate. |
| `frame_time` | `number` | — | Time of the still frame for `png` (defaults to `start`). |
| `framing` | `Framing` | `"contain"` | How the scene adapts to a different aspect ratio than the canvas. |
| `height` | `integer (16 to 8192)` | — | Override the preset's height in pixels (MP4 needs an even number). |
| `motion_blur` | `MotionBlur` | — | Average subframes for motion blur (off by default). |
| `preset` | `ExportPreset` | — | The platform preset: size, fps, format, duration limit and safe area. |
| `quality` | `Quality` | `"high"` | Render quality. `draft` is a fast preview for self-review. |
| `safe_area` | `SafeArea` | — | Margins kept clear of platform UI (defaults to the preset's). |
| `seamless_loop` | `boolean` | — | Make the last frame flow into the first (requires a looping timeline whose duration matches the export duration). |
| `start` | `number (≥ 0)` | `0` | Start time in seconds on the main timeline. |
| `width` | `integer (16 to 8192)` | — | Override the preset's width in pixels (MP4 needs an even number). |
### ExportPreset

Tuned output presets. Each fixes size, fps, format, loop default, the platform's duration limit and the safe area kept clear of platform UI.

| Value | Description |
| --- | --- |
| `"x_16x9"` | X/Twitter 16:9 video, 1920x1080 MP4. |
| `"x_1x1"` | X/Twitter 1:1 video, 1080x1080 MP4. |
| `"x_9x16"` | X/Twitter 9:16 vertical video, 1080x1920 MP4. |
| `"x_landscape"` | Same as `x_16x9` (older name). |
| `"x_square"` | Same as `x_1x1` (older name). |
| `"x_portrait"` | Same as `x_9x16` (older name). |
| `"x_gif"` | Looping 1:1 GIF tuned for size, 480x480 @ 15fps (X takes GIFs up to 15 MB). |
| `"x_image"` | X link-card / post image, 1600x900 PNG. |
| `"linkedin"` | LinkedIn feed video, 1:1 1080x1080 MP4 (fills the mobile feed). |
| `"instagram_reel"` | Instagram Reel, 9:16 1080x1920 MP4; keeps clear of the caption and action-button overlays. |
| `"tiktok"` | TikTok, 9:16 1080x1920 MP4; keeps clear of the caption and side-bar overlays. |
| `"slide_16x9"` | 16:9 slide background/hero video, 1920x1080 MP4. |
| `"slide_4x3"` | 4:3 slide video, 1440x1080 MP4. |
| `"slide_still"` | Slide still (poster frame), 1920x1080 PNG. |
| `"web_embed"` | Self-contained interactive HTML embed (websites, slides with web embeds). |
### ExportFormat

| Value | Description |
| --- | --- |
| `"mp4"` |  |
| `"webm"` |  |
| `"gif"` |  |
| `"png"` |  |
| `"png_sequence"` |  |
| `"html"` |  |
### Framing

Aspect-ratio adaptation.

| Value | Description |
| --- | --- |
| `"contain"` | Widen/narrow the view so the canvas' safe area stays fully visible. |
| `"cover"` | Fill the frame, cropping the edges. |
### SafeArea

Fractions of the frame (0..0.5) kept clear on each side, e.g. of a platform's overlaid buttons and captions. Burned-in captions stay inside.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `bottom` (required) | `number (0 to 0.5)` | — | Fraction of the height kept clear at the bottom. |
| `left` (required) | `number (0 to 0.5)` | — | Fraction of the width kept clear on the left. |
| `right` (required) | `number (0 to 0.5)` | — | Fraction of the width kept clear on the right. |
| `top` (required) | `number (0 to 0.5)` | — | Fraction of the height kept clear at the top. |
### Quality

| Value | Description |
| --- | --- |
| `"standard"` |  |
| `"high"` |  |
| `"draft"` | Fast preview (self-review loop). |
### MotionBlur

Motion blur by averaging subframes across the shutter interval.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `samples` | `integer (2 to 64)` | `8` | Subframes rendered and averaged per output frame. |
| `shutter` | `number (0 to 1)` | `0.5` | Fraction of the frame interval the shutter is open (0.5 = 180°). |
### Caption

A timed caption.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `end` (required) | `number` | — | Seconds when the caption leaves. |
| `position` | `CaptionPosition` | `"bottom"` | Where the caption sits inside the safe area. |
| `start` (required) | `number` | — | Seconds when the caption appears. |
| `style` | `CaptionStyle` | `"bold_pop"` | How the caption looks and animates. |
| `text` (required) | `string` | — | The caption's words. |
### CaptionStyle

| Value | Description |
| --- | --- |
| `"bold_pop"` | Big bold words that pop in (short-form video look). |
| `"minimal"` | Clean small subtitles. |
| `"karaoke"` | Word-by-word highlight. |
| `"boxed"` | Text on a rounded translucent box. |
### CaptionPosition

| Value | Description |
| --- | --- |
| `"top"` |  |
| `"center"` |  |
| `"bottom"` |  |
