# How to Build Custom Export Presets with FFmpeg Codec Selection (H.264, H.265, ProRes) in Clypra

> Learn to build custom export presets in Clypra using FFmpeg codec selection. Configure H.264, H.265, and ProRes with custom presets and streamline your export workflow.

- Repository: [Abdulkabir Musa/Clypra](https://github.com/AIEraDev/Clypra)
- Tags: how-to-guide
- Published: 2026-07-16

---

**To build custom export presets in Clypra, define a new preset object in [`src/lib/export/exportPresets.ts`](https://github.com/AIEraDev/Clypra/blob/main/src/lib/export/exportPresets.ts) with your desired FFmpeg codec configuration, expose it via `getExportPresets()`, and invoke the export through the Tauri API with your preset ID.**

Clypra's export system centralizes all video encoding settings in TypeScript configuration files, giving developers granular control over FFmpeg command generation. The architecture separates preset definitions from execution logic, allowing you to add new codec profiles—including H.264, H.265, and ProRes—without modifying the core export engine. By leveraging the preset system in [`src/lib/export/exportPresets.ts`](https://github.com/AIEraDev/Clypra/blob/main/src/lib/export/exportPresets.ts), you can create custom export workflows that automatically map to the appropriate FFmpeg `-c:v` and `-preset` flags.

## Understanding Clypra's Export Architecture

Clypra separates export configuration into two primary layers. The **preset definition layer** in [`src/lib/export/exportPresets.ts`](https://github.com/AIEraDev/Clypra/blob/main/src/lib/export/exportPresets.ts) maintains the `exportPresets` array containing all available codec configurations, while the **execution layer** in [`src/lib/export/videoExport.ts`](https://github.com/AIEraDev/Clypra/blob/main/src/lib/export/videoExport.ts) handles FFmpeg command construction and native invocation.

When an export initiates, [`videoExport.ts`](https://github.com/AIEraDev/Clypra/blob/main/videoExport.ts) destructures the configuration object at line 132, applying a default fallback of `"h264"` if no codec is specified:

```ts
const {
  …,
  codec = "h264",
  preset = "medium",
  …
} = config;

```

The `buildExportCommand` helper then assembles the FFmpeg command string, inserting the `-c:v` flag followed by your codec value and the `-preset` flag for quality tuning.

## Creating a Custom Export Preset

To add a new FFmpeg-based export preset to Clypra, modify the preset definition file and expose it through the existing API.

### Step 1: Define the Preset Configuration

Open [`src/lib/export/exportPresets.ts`](https://github.com/AIEraDev/Clypra/blob/main/src/lib/export/exportPresets.ts) and append a new object to the `exportPresets` array. Each preset requires a unique `id`, human-readable `name`, and the specific FFmpeg parameters:

- **codecValue**: The FFmpeg encoder identifier (`"h264"`, `"h265"`, or `"prores"`)
- **preset**: The FFmpeg quality preset (`"ultrafast"`, `"fast"`, `"medium"`, `"slow"`, or `"veryslow"`)
- **pixelFormat**: The pixel format (e.g., `"yuv420p"`, `"yuv444p10le"`)

### Step 2: Export the Preset

Ensure your new preset is returned by `getExportPresets()`. This function aggregates all entries and makes them available to the UI layer and Tauri API.

### Step 3: Invoke the Export

Call the Tauri command `export_video` with your preset ID, or allow users to select it from the UI which reads from `getExportPresets()`.

### Example: High-Quality ProRes 4444 Preset

Add the following configuration to [`src/lib/export/exportPresets.ts`](https://github.com/AIEraDev/Clypra/blob/main/src/lib/export/exportPresets.ts) to create a broadcast-quality ProRes preset:

```ts
export const exportPresets = [
  // existing presets …
  {
    id: "prores-4444",
    name: "ProRes 4444 (HQ)",
    codec: "ProRes",
    codecLabel: "ProRes 4444 HQ",
    codecValue: "prores",
    preset: "slow",
    crf: 0,
    pixelFormat: "yuv444p10le",
    extension: "mov",
    description: "Apple ProRes 4444 with highest color fidelity",
  },
];

```

When selected, Clypra generates the FFmpeg command:

```bash
ffmpeg -i input.mov -c:v prores -preset slow -pix_fmt yuv444p10le output.mov

```

## Implementing Exports in Application Code

### Retrieving Available Presets

Access the preset list within your UI components or export logic:

```ts
import { getExportPresets } from "@/lib/export/exportPresets";

const presets = await getExportPresets();
// Returns array of preset objects including your custom configurations

```

### Executing the Export

Use the Tauri API to invoke the export with your custom preset parameters:

```ts
import { invoke } from "@tauri-apps/api";

async function exportProject(projectId: string, presetId: string) {
  const preset = presets.find(p => p.id === presetId);
  if (!preset) throw new Error("Preset not found");

  await invoke("export_video", {
    projectId,
    config: {
      codec: preset.codecValue,   // "h264" | "h265" | "prores"
      preset: preset.preset,      // FFmpeg quality preset
      crf: preset.crf,
      pixelFormat: preset.pixelFormat,
    },
  });
}

// Usage with the ProRes 4444 preset
exportProject("myProject123", "prores-4444");

```

### Debugging FFmpeg Commands

For troubleshooting, manually build the command string using the internal helper:

```ts
import { buildExportCommand } from "@/lib/export/videoExport";

const command = buildExportCommand({
  input: "input.mov",
  output: "output.mov",
  codec: "prores",
  preset: "slow",
  pixelFormat: "yuv444p10le",
});
console.log(command);
// Output: ffmpeg -i input.mov -c:v prores -preset slow -pix_fmt yuv444p10le output.mov

```

## Choosing Between H.264, H.265, and ProRes

Clypra supports three primary codec families, each mapped to specific FFmpeg encoders:

- **H.264** (`codecValue: "h264"`): Industry-standard format offering wide compatibility and efficient compression. Best for web delivery and general playback.
- **H.265/HEVC** (`codecValue: "h265"`): Advanced compression delivering smaller file sizes at equivalent quality, though requiring hardware support for playback.
- **ProRes** (`codecValue: "prores"`): Intra-frame codec preserving maximum color fidelity and editing flexibility. Ideal for post-production workflows and broadcast standards.

## Summary

- **Custom presets** are defined in [`src/lib/export/exportPresets.ts`](https://github.com/AIEraDev/Clypra/blob/main/src/lib/export/exportPresets.ts) and must include `codecValue`, `preset`, and `pixelFormat` properties.
- **FFmpeg command generation** occurs in [`src/lib/export/videoExport.ts`](https://github.com/AIEraDev/Clypra/blob/main/src/lib/export/videoExport.ts), which maps your preset values to `-c:v` and `-preset` flags.
- **Default fallback** is `"h264"` when no codec is specified in the export configuration.
- **Three-step workflow**: Define the preset in the configuration array, expose it via `getExportPresets()`, and invoke it through the Tauri `export_video` command.
- **Codec selection** determines the FFmpeg encoder used: `h264` for compatibility, `h265` for efficiency, or `prores` for professional quality.

## Frequently Asked Questions

### How do I set a default custom preset for all exports?

Modify the default destructuring values in [`src/lib/export/videoExport.ts`](https://github.com/AIEraDev/Clypra/blob/main/src/lib/export/videoExport.ts) at line 132, changing `codec = "h264"` to your preferred codec string (e.g., `codec = "prores"`). Alternatively, ensure your UI passes the desired preset ID by default when calling the export function.

### Can I add custom FFmpeg flags beyond the preset system?

Clypra's `buildExportCommand` function constructs the FFmpeg command internally. To add custom flags, you would need to extend the configuration interface in [`videoExport.ts`](https://github.com/AIEraDev/Clypra/blob/main/videoExport.ts) to accept additional parameters and modify the command builder to append them to the generated string.

### Why does my ProRes export show different file sizes than expected?

ProRes is a constant bitrate (CBR) intra-frame codec, meaning file sizes scale with resolution and frame rate rather than scene complexity. Verify your `pixelFormat` setting (e.g., `yuv444p10le` for 4444 vs `yuv422p10le` for 422) and ensure your `crf` value is set to `0` for lossless quality, as ProRes ignores CRF values but Clypra may apply other quality filters if configured incorrectly.

### What FFmpeg quality preset should I choose for H.265 exports?

For **H.265 (HEVC)** exports, use `"slow"` or `"veryslow"` presets to maximize compression efficiency and quality per bit. The `"medium"` preset offers a balance between encoding speed and file size, while `"ultrafast"` sacrifices compression ratio for speed. Note that H.265 encoding is significantly more CPU-intensive than H.264 regardless of preset choice.