# Export is slow

> What decides the time of an export, and what to check before you change anything.

Source: https://alexgalhardo.github.io/vukem-video/docs/troubleshooting/slow-export/

## You will learn

- where an export spends its time;
- what to check and what to change;
- what is measured and what is not.

## The idea

An export has four steps: it plans the frames, composes each frame in Go, feeds the frames to FFmpeg, and verifies the file. Measured on the project's own benchmark, the limit is **composing the frames** (FFmpeg decoding the sources and converting them to RGBA), and the encoder barely matters. A hardware encoder therefore shortens only a small part of the time. The time grows with the number of frames, the frame size and the number of layers with effects on screen.

The numbers on a table of the repository, `docs/perf/`, are those of one machine at one commit, and a busy machine measures several times slower than an idle one. Measure your own machine before you decide something is wrong.

## Quick start

1. Check what else the machine is doing. Exports share the CPU with ingests, transcriptions and your other programs.
2. Read the job, which reports the encoder used and the duration:

```bash
vukem-video job:list --project prj_7k2m9x4q1b --state all
vukem-video job:show job_4h8k2m6p9t
vukem-video doctor --full
```

3. Export a short range to compare: `vukem-video export --project prj_7k2m9x4q1b --start 0s --end 5s`.

| Check | What to do |
| --- | --- |
| The encoder is `libopenh264` and a hardware encoder exists | `doctor --full` shows why the hardware one failed; fix the driver, or force one with `VUKEM_VIDEO_ENCODER`. The gain is small |
| The project is larger than the output needs | set the frame size to what the platform shows; 1080 x 1920 is the usual vertical size |
| The sources are very large or of a heavy codec | the import makes a proxy for the editor, but the export reads the original: re-encode a smaller source |
| Several exports are queued | `VUKEM_VIDEO_MAX_EXPORTS` is 2 per workspace and 1 per user or key; the rest wait |
| The disk is almost full or slow | the workspace and `tmp/` live on one volume; free space and use a fast disk |
| A container with a small CPU limit | give it more CPUs |

## Common mistakes

- Changing the encoder to speed up an export that is limited by composing.
- Starting an export while a long transcription runs on a small machine.
- Cancelling and restarting a long export: the work is lost. Use `job:show --wait` to follow it.

## Next steps

- [Encoders and export presets](/docs/guide/encoders-and-presets)
- [Jobs and the queue](/docs/guide/jobs)
