# Encoders and export presets

> What file an export produces, which H.264 encoder it uses and how to choose one.

Source: https://alexgalhardo.github.io/vukem-video/docs/guide/encoders-and-presets/

## You will learn

- what the export file is, and that there is one preset;
- how the encoder is detected and how to force one;
- how to check the choice.

## The idea

There is one **export preset**: an MP4 file with H.264 video, AAC audio at 48 kHz stereo and the project's own frame size and frame rate, with the index at the front (fast start). The name of a project is never part of the output path: the file is `<workspace>/exports/<project id>/<job id>.mp4`. Before the job is marked done, the file is verified (streams, duration, dimensions, pixel format and fast start). You can export a part of the timeline with a start and an end.

An H.264 encoder is needed only for export. The product tests the candidates on your machine with a real test encode, in this order: `h264_videotoolbox` (macOS), `h264_nvenc`, `h264_qsv`, `h264_amf`, `h264_mf` (Windows), `h264_vaapi` (Linux) and `libopenh264`, which the bundled FFmpeg has. `libx264` is used only when the FFmpeg is your own and `VUKEM_VIDEO_ALLOW_USER_X264` is `true`. The first that works is used. The result is cached for 24 hours.

To force one encoder, set `VUKEM_VIDEO_ENCODER` to its FFmpeg name. Only that one is tried; if it fails the export fails with `E_NO_ENCODER` and the reason, and the product never swaps it silently.

## Quick start

**CLI**

```bash
vukem-video doctor --full
vukem-video export --project prj_7k2m9x4q1b --start 0s --end 10s
VUKEM_VIDEO_ENCODER=libopenh264 vukem-video serve
```

**MCP**

`job_start` with `{"project_id": "prj_7k2m9x4q1b", "kind": "export"}`. The finished job reports the encoder used. There is no MCP tool for the diagnostic; ask the operator to run `vukem-video doctor --full`.

The result of the job has the path, the size, the duration and the encoder used. The export is composed in Go and the encoder reads the frames from a pipe, so a faster encoder shortens only part of the time; see [Troubleshooting: export is slow](/docs/troubleshooting/slow-export).

## Common mistakes

- `E_NO_ENCODER` on a machine with no working hardware encoder and an FFmpeg without OpenH264. Use the bundled FFmpeg, or set `VUKEM_VIDEO_FFMPEG` to a build that has `libx264` and set `VUKEM_VIDEO_ALLOW_USER_X264=true`.
- Pointing `VUKEM_VIDEO_ENCODER` at an encoder the machine does not have.
- Expecting other containers or codecs. This release writes MP4 with H.264 only.

## Next steps

- [Jobs and the queue](/docs/guide/jobs)
- [Troubleshooting: export is slow](/docs/troubleshooting/slow-export)
