# Output Customization Guide

Learn how to customize and configure the output formats and deliverables from
Yemaya pipelines.

## Table of Contents

1. [Overview](#overview)
2. [Game Output Formats](#game-output-formats)
3. [Film Output Formats](#film-output-formats)
4. [Asset Export Settings](#asset-export-settings)
5. [Platform-Specific Builds](#platform-specific-builds)
6. [Localization](#localization)
7. [Marketing Assets](#marketing-assets)
8. [Custom Export Pipelines](#custom-export-pipelines)
9. [Post-Processing](#post-processing)

---

## Overview

Yemaya supports flexible output customization to deliver your content in the
exact formats you need.

### Output Categories

| Category        | Examples                          |
| --------------- | --------------------------------- |
| **Executables** | Game builds, installers           |
| **Video**       | DCP, ProRes, H.265, HLS           |
| **Audio**       | WAV, FLAC, AAC, stems             |
| **Assets**      | GLB, FBX, USD, PSD                |
| **Documents**   | PDF, Markdown, Word               |
| **Marketing**   | Screenshots, trailers, press kits |

---

## Game Output Formats

### Build Configurations

```typescript
const gameOutputConfig: GameOutputConfig = {
  // Target platforms
  platforms: {
    pc: {
      enabled: true,
      os: ['windows', 'macos', 'linux'],
      architecture: ['x64', 'arm64'],
      installer: true,
      portable: true,
    },
    web: {
      enabled: true,
      format: 'webgl2',
      compression: 'gzip',
      streaming: true,
    },
    mobile: {
      enabled: true,
      ios: {
        minVersion: '14.0',
        deviceTypes: ['iphone', 'ipad'],
      },
      android: {
        minSdk: 24,
        targetSdk: 34,
        abi: ['arm64-v8a', 'armeabi-v7a'],
      },
    },
    console: {
      switch: { enabled: true },
      playstation: { enabled: false },
      xbox: { enabled: false },
    },
  },

  // Build settings
  build: {
    compression: 'lz4',
    stripDebug: true,
    obfuscate: false,
    signExecutables: true,
  },

  // Engine export
  engine: {
    type: 'godot',
    version: '4.2',
    exportTemplates: 'custom',
    includeSource: false,
  },
};
```

### Quality Presets

```typescript
const qualityPresets = {
  ultra: {
    resolution: { max: '4K' },
    textures: 'high',
    shadows: 'raytraced',
    antialiasing: 'taa',
    postProcessing: 'full',
  },
  high: {
    resolution: { max: '1440p' },
    textures: 'high',
    shadows: 'cascaded',
    antialiasing: 'msaa4x',
    postProcessing: 'standard',
  },
  medium: {
    resolution: { max: '1080p' },
    textures: 'medium',
    shadows: 'simple',
    antialiasing: 'fxaa',
    postProcessing: 'minimal',
  },
  low: {
    resolution: { max: '720p' },
    textures: 'low',
    shadows: 'blob',
    antialiasing: 'none',
    postProcessing: 'none',
  },
};
```

### Installer Configuration

```typescript
const installerConfig = {
  windows: {
    type: 'nsis', // 'nsis' | 'msi' | 'inno'
    includeUninstaller: true,
    addToStartMenu: true,
    createDesktopShortcut: true,
    requireAdmin: false,
    customPages: ['license', 'readme'],
  },
  macos: {
    type: 'dmg',
    background: 'assets/installer-bg.png',
    iconPositions: {
      app: { x: 150, y: 150 },
      applications: { x: 450, y: 150 },
    },
    notarize: true,
    codesign: true,
  },
  linux: {
    formats: ['appimage', 'deb', 'rpm', 'flatpak'],
    desktopEntry: true,
    mimeTypes: ['.yemaya-save'],
  },
};
```

---

## Film Output Formats

### Video Deliverables

```typescript
const filmOutputConfig: FilmOutputConfig = {
  // Master deliverables
  master: {
    format: 'prores',
    codec: 'ProRes 4444 XQ',
    resolution: '4096x2160',
    frameRate: 24,
    colorSpace: 'ACES',
    bitDepth: 16,
    audio: {
      format: 'pcm',
      sampleRate: 48000,
      bitDepth: 24,
      channels: '5.1',
    },
  },

  // DCP (Digital Cinema Package)
  dcp: {
    enabled: true,
    resolution: '4K',
    colorSpace: 'DCI-P3',
    encryption: {
      enabled: true,
      kdm: true,
    },
    audio: '5.1',
  },

  // Streaming versions
  streaming: {
    enabled: true,
    formats: [
      {
        name: '4K HDR',
        resolution: '3840x2160',
        codec: 'hevc',
        bitrate: 25000,
        hdr: 'HDR10',
      },
      {
        name: '1080p',
        resolution: '1920x1080',
        codec: 'h264',
        bitrate: 8000,
        hdr: false,
      },
      {
        name: '720p',
        resolution: '1280x720',
        codec: 'h264',
        bitrate: 4000,
        hdr: false,
      },
    ],
    hlsPlaylist: true,
    dashManifest: true,
  },

  // Broadcast
  broadcast: {
    enabled: false,
    format: 'xdcam',
    standard: 'EBU',
  },
};
```

### Audio Deliverables

```typescript
const audioOutputConfig = {
  // Full mix
  fullMix: {
    format: 'wav',
    sampleRate: 48000,
    bitDepth: 24,
    channels: '5.1',
    normalization: 'R128',
    loudness: -24, // LUFS
  },

  // Stems
  stems: {
    enabled: true,
    separate: ['dialogue', 'music', 'sfx', 'ambience', 'foley'],
    format: 'wav',
    bitDepth: 24,
  },

  // M&E (Music & Effects)
  mAndE: {
    enabled: true,
    format: 'wav',
    channels: '5.1',
  },

  // Music-only
  musicOnly: {
    enabled: true,
    format: 'wav',
    includeAlternates: true,
  },
};
```

---

## Asset Export Settings

### 3D Models

```typescript
const modelExportConfig = {
  // Formats to export
  formats: ['glb', 'fbx', 'usd', 'obj'],

  // Per-format settings
  settings: {
    glb: {
      draco: true,
      dracoLevel: 7,
      embedTextures: true,
      binaryBuffer: true,
    },
    fbx: {
      version: '2020',
      ascii: false,
      embedMedia: true,
      bakeAnimations: true,
    },
    usd: {
      variant: 'usdz',
      materialX: true,
      subdivision: 'catmull-clark',
    },
    obj: {
      includeNormals: true,
      includeMtl: true,
      triangulate: true,
    },
  },

  // LOD export
  lods: {
    export: true,
    levels: [
      { name: 'LOD0', quality: 1.0 },
      { name: 'LOD1', quality: 0.5 },
      { name: 'LOD2', quality: 0.25 },
      { name: 'LOD3', quality: 0.1 },
    ],
    format: 'separate-files', // or 'combined'
  },

  // Animation export
  animations: {
    format: 'embedded', // 'embedded' | 'separate'
    fps: 30,
    bake: true,
    optimize: true,
  },
};
```

### Textures

```typescript
const textureExportConfig = {
  // Master format
  master: {
    format: 'png',
    bitDepth: 16,
    colorSpace: 'linear',
  },

  // Game-ready formats
  gameReady: {
    formats: ['png', 'basis', 'ktx2'],
    compression: {
      basis: { quality: 128 },
      ktx2: { supercompression: 'zstd' },
    },
  },

  // Resolution variants
  variants: [
    { suffix: '_4k', scale: 1.0, maxSize: 4096 },
    { suffix: '_2k', scale: 0.5, maxSize: 2048 },
    { suffix: '_1k', scale: 0.25, maxSize: 1024 },
    { suffix: '_512', scale: 0.125, maxSize: 512 },
  ],

  // Channel packing
  channelPacking: {
    enabled: true,
    preset: 'unity-hdrp', // or 'unreal', 'godot'
    maps: {
      arm: ['ao', 'roughness', 'metallic'],
      normal: ['normal'],
    },
  },
};
```

### Audio Assets

```typescript
const audioAssetExport = {
  // Music
  music: {
    format: 'ogg',
    quality: 8,
    sampleRate: 44100,
    loopMetadata: true,
  },

  // Sound effects
  sfx: {
    format: 'wav',
    sampleRate: 48000,
    bitDepth: 16,
    mono: true,
  },

  // Voice
  voice: {
    format: 'ogg',
    quality: 6,
    sampleRate: 44100,
    stereo: true,
  },

  // Ambience
  ambience: {
    format: 'ogg',
    quality: 7,
    sampleRate: 48000,
    seamlessLoop: true,
  },
};
```

---

## Platform-Specific Builds

### Steam

```typescript
const steamConfig = {
  enabled: true,
  appId: '1234567',

  // Depot configuration
  depots: {
    windows: {
      depotId: '1234568',
      fileMapping: [{ source: 'build/windows/*', dest: '.' }],
    },
    macos: {
      depotId: '1234569',
      fileMapping: [{ source: 'build/macos/*', dest: '.' }],
    },
    linux: {
      depotId: '1234570',
      fileMapping: [{ source: 'build/linux/*', dest: '.' }],
    },
  },

  // Achievements
  achievements: {
    generate: true,
    iconSize: 64,
  },

  // Trading cards (if applicable)
  tradingCards: false,

  // Workshop
  workshop: {
    enabled: false,
  },
};
```

### Nintendo Switch

```typescript
const switchConfig = {
  enabled: true,

  // Display modes
  display: {
    docked: {
      resolution: '1920x1080',
      fps: 60,
    },
    handheld: {
      resolution: '1280x720',
      fps: 30,
    },
  },

  // Controllers
  controllers: {
    joycon: true,
    proController: true,
    touchScreen: true,
  },

  // Features
  features: {
    rumble: true,
    hdRumble: true,
    nfc: false,
    userSelector: true,
  },

  // Submission
  submission: {
    rating: 'ESRB-E',
    languages: ['en', 'ja', 'es', 'fr', 'de'],
    screenshots: 5,
    trailer: true,
  },
};
```

### Mobile (iOS/Android)

```typescript
const mobileConfig = {
  ios: {
    bundleId: 'com.studio.gamename',
    version: '1.0.0',
    buildNumber: 1,

    capabilities: ['game-center', 'in-app-purchase', 'push-notifications'],

    icons: {
      generate: true,
      source: 'assets/icon-1024.png',
    },

    launchScreen: {
      type: 'storyboard',
      backgroundColor: '#000000',
    },

    appStoreMetadata: {
      generate: true,
      screenshots: { required: ['iphone6.5', 'ipad12.9'] },
    },
  },

  android: {
    packageName: 'com.studio.gamename',
    versionCode: 1,
    versionName: '1.0.0',

    signing: {
      keystore: 'release.keystore',
      keyAlias: 'release',
    },

    split: {
      abi: true,
      density: false,
      language: true,
    },

    playStore: {
      track: 'internal',
      generateScreenshots: true,
    },
  },
};
```

---

## Localization

### Language Configuration

```typescript
const localizationConfig: LocalizationConfig = {
  // Supported languages
  languages: [
    { code: 'en', name: 'English', default: true },
    { code: 'es', name: 'Spanish' },
    { code: 'fr', name: 'French' },
    { code: 'de', name: 'German' },
    { code: 'ja', name: 'Japanese' },
    { code: 'zh-Hans', name: 'Simplified Chinese' },
    { code: 'ko', name: 'Korean' },
  ],

  // Content to localize
  content: {
    ui: true,
    dialogue: true,
    subtitles: true,
    voiceOver: false, // or 'ai-generated' or 'professional'
    marketing: true,
  },

  // Output format
  output: {
    format: 'json', // 'json' | 'po' | 'xliff' | 'csv'
    structure: 'per-language', // 'per-language' | 'single-file'
    includeContext: true,
  },

  // Font configuration
  fonts: {
    fallbacks: {
      ja: 'NotoSansJP',
      ko: 'NotoSansKR',
      'zh-Hans': 'NotoSansSC',
    },
    dynamicLoading: true,
  },
};
```

### Subtitle/Caption Export

```typescript
const subtitleConfig = {
  formats: ['srt', 'vtt', 'ass'],

  styling: {
    font: 'Arial',
    fontSize: 24,
    color: '#FFFFFF',
    outline: true,
    outlineColor: '#000000',
    shadow: true,
  },

  positioning: {
    vertical: 'bottom',
    margin: 50,
  },

  accessibility: {
    sdh: true, // Subtitles for Deaf and Hard-of-hearing
    audioDescriptions: true,
  },
};
```

---

## Marketing Assets

### Screenshots

```typescript
const screenshotConfig = {
  // Automatic capture
  automatic: {
    enabled: true,
    count: 20,
    selectBest: 5,
  },

  // Resolutions
  resolutions: [
    { name: 'steam', width: 1920, height: 1080 },
    { name: 'switch', width: 1280, height: 720 },
    { name: 'appstore', width: 2688, height: 1242 },
    { name: 'playstore', width: 2560, height: 1440 },
  ],

  // Post-processing
  postProcess: {
    logo: true,
    border: false,
    watermark: false,
  },

  // Output
  output: {
    format: 'png',
    quality: 100,
    organizeByPlatform: true,
  },
};
```

### Trailers

```typescript
const trailerConfig = {
  // Generate trailer
  generate: true,

  // Versions
  versions: [
    {
      name: 'announcement',
      duration: 60,
      style: 'cinematic',
      music: 'epic',
    },
    {
      name: 'gameplay',
      duration: 90,
      style: 'gameplay-focused',
      voiceover: false,
    },
    {
      name: 'launch',
      duration: 45,
      style: 'hype',
      includeReviews: true,
    },
  ],

  // Resolutions
  resolutions: ['4k', '1080p', '720p'],

  // Platforms
  platformVersions: {
    youtube: { aspectRatio: '16:9' },
    instagram: { aspectRatio: '1:1', duration: 60 },
    tiktok: { aspectRatio: '9:16', duration: 60 },
  },

  // Output
  output: {
    codec: 'h264',
    quality: 'high',
    subtitles: true,
  },
};
```

### Press Kit

```typescript
const pressKitConfig = {
  generate: true,

  contents: {
    factSheet: true,
    description: {
      short: true, // 100 words
      medium: true, // 300 words
      long: true, // 1000 words
    },
    credits: true,
    releaseHistory: true,
    awards: true,
  },

  media: {
    logo: {
      formats: ['png', 'svg', 'eps'],
      variants: ['color', 'white', 'black'],
    },
    icons: {
      sizes: [16, 32, 64, 128, 256, 512, 1024],
    },
    screenshots: true,
    gifs: true,
    trailers: true,
    keyArt: true,
  },

  output: {
    format: 'zip',
    structure: 'presskit.io-compatible',
  },
};
```

---

## Custom Export Pipelines

### Defining Custom Exports

```typescript
const customExport: CustomExportPipeline = {
  name: 'unity-asset-bundle',

  // Input specification
  input: {
    types: ['model', 'texture', 'audio'],
    filter: { tags: ['environment'] },
  },

  // Processing steps
  steps: [
    {
      name: 'convert-models',
      action: 'convert',
      config: { format: 'fbx', version: '2020' },
    },
    {
      name: 'pack-textures',
      action: 'pack-textures',
      config: { atlas: true, maxSize: 4096 },
    },
    {
      name: 'optimize',
      action: 'optimize',
      config: { target: 'mobile' },
    },
    {
      name: 'bundle',
      action: 'unity-bundle',
      config: { compression: 'lz4' },
    },
  ],

  // Output
  output: {
    path: 'exports/unity-bundles',
    naming: '{asset}-{platform}.bundle',
  },
};
```

### Pipeline Hooks

```typescript
const exportHooks = {
  beforeExport: async (assets, config) => {
    // Validate assets before export
    await validateAssets(assets);
    return assets;
  },

  afterConvert: async (assets, config) => {
    // Custom processing after format conversion
    await addCustomMetadata(assets);
    return assets;
  },

  beforeBundle: async (assets, config) => {
    // Final checks before bundling
    await verifyCompatibility(assets);
    return assets;
  },

  afterExport: async (bundle, config) => {
    // Post-export actions
    await uploadToServer(bundle);
    await notifyTeam(bundle);
  },
};
```

---

## Post-Processing

### Batch Operations

```typescript
const postProcessConfig = {
  // Run after all exports
  operations: [
    {
      name: 'generate-manifests',
      action: 'create-manifest',
      config: { format: 'json' },
    },
    {
      name: 'calculate-checksums',
      action: 'checksum',
      config: { algorithm: 'sha256' },
    },
    {
      name: 'compress-bundles',
      action: 'compress',
      config: { format: 'zip', level: 9 },
    },
    {
      name: 'upload-cdn',
      action: 'upload',
      config: {
        destination: 's3://releases/',
        acl: 'public-read',
      },
    },
  ],
};
```

### Verification

```typescript
const verificationConfig = {
  // Verify all outputs
  verify: {
    checksums: true,
    signatures: true,
    compatibility: true,
  },

  // Report
  report: {
    generate: true,
    format: 'html',
    include: ['files', 'sizes', 'checksums', 'issues'],
  },

  // Notifications
  notify: {
    onSuccess: ['email', 'slack'],
    onFailure: ['email', 'slack', 'pagerduty'],
  },
};
```

---

## Examples

### Example 1: Indie Game Multi-Platform

```typescript
const indieGameOutput = {
  platforms: {
    pc: { enabled: true, os: ['windows', 'linux'] },
    web: { enabled: true },
    mobile: { enabled: true, ios: true, android: true },
  },
  localization: {
    languages: ['en', 'es', 'fr', 'de', 'ja'],
  },
  marketing: {
    screenshots: 10,
    trailer: true,
    pressKit: true,
  },
};
```

### Example 2: Film Festival Submission

```typescript
const festivalOutput = {
  master: {
    format: 'prores',
    codec: 'ProRes 4444',
    resolution: '4K',
  },
  dcp: {
    enabled: true,
    encryption: false,
  },
  screening: {
    format: 'h264',
    resolution: '1080p',
    watermark: true,
  },
  press: {
    stills: 20,
    trailer: true,
    pressNotes: true,
  },
};
```

---

## Next Steps

- [Autonomous Mode Tutorial](./autonomous-mode.md)
- [Pipeline Configuration Guide](./pipeline-configuration.md)
- [Quality Gate Configuration](./quality-gates.md)
- [API Reference](../api/endpoints/README.md)
