Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Environment:0xsline OpenChatCut FFmpeg

From Leeroopedia
Knowledge Sources
Domains Infrastructure, Media_Processing
Last Updated 2026-10-22 14:00 GMT

Overview

FFmpeg binary required for H.264 video encoding, media normalization, audio extraction, and server-side rendering on all platforms.

Description

FFmpeg is the core media processing engine for OpenChatCut. It is used for import normalization (H.264/AAC transcode), audio extraction (16kHz mono Opus for ASR), export rendering (H.264 encode via Remotion), hardware-accelerated encoding (NVENC/VideoToolbox/VAAPI/QSV/AMF), and format probing. The binary is resolved through a priority chain: explicit env override, `ffmpeg-static` npm package (with asar unpacking for desktop), then system PATH. Hardware encoder probing validates that the FFmpeg build actually supports the encoder before use.

Usage

Use this environment for media import normalization, export rendering, audio extraction for transcription, and transparent MOV proxy creation. Any implementation that transcodes, encodes, or remuxes video/audio requires this environment.

System Requirements

Category Requirement Notes
OS macOS, Windows, Linux Hardware encoders vary by platform
Hardware Any (GPU optional) Hardware encoders: NVENC (NVIDIA), VideoToolbox (Apple), QSV (Intel), AMF (AMD), VAAPI (Linux)
Disk Temp space for transcoding Proportional to media size

Dependencies

System Packages

  • `ffmpeg` (via `ffmpeg-static` >= 5.3.0, system PATH, or env override)

Environment Variables

  • `OPENCHATCUT_FFMPEG` — Override FFmpeg binary path (highest priority)
  • `FFMPEG_PATH` — Fallback override path
  • `OPENCHATCUT_H264_ENCODER` — Force specific encoder (h264_videotoolbox, h264_nvenc, h264_qsv, h264_amf, h264_vaapi, libx264)
  • `OPENCHATCUT_DISABLE_HARDWARE_ENCODING` — Set to `1`/`true`/`yes` to force software encoding
  • `OPENCHATCUT_VAAPI_DEVICE` — Override VAAPI device (default: `/dev/dri/renderD128`)

Quick Install

# FFmpeg is installed automatically via npm:
npm install ffmpeg-static

# Or install system FFmpeg:
# macOS: brew install ffmpeg
# Ubuntu: sudo apt install ffmpeg
# Windows: choco install ffmpeg

# Override path if needed:
export OPENCHATCUT_FFMPEG=/usr/local/bin/ffmpeg

Code Evidence

Binary resolution chain from `server/media-binaries.ts:33-38`:

export function ffmpegBin(): string {
  return process.env.OPENCHATCUT_FFMPEG
    ?? process.env.FFMPEG_PATH
    ?? (ffmpegStatic ? unpackedPath(ffmpegStatic) : null)
    ?? 'ffmpeg';
}

Hardware encoder probing from `server/media-acceleration.ts:296-327`:

export function resolveH264Encoder(
  ffmpeg: string,
  platform: NodeJS.Platform = process.platform,
): Promise<H264Encoder> {
  const forcedValue = process.env.OPENCHATCUT_H264_ENCODER?.trim();
  const forced = forcedValue && Object.hasOwn(KNOWN_ENCODERS, forcedValue)
    ? forcedValue as H264Encoder
    : undefined;
  const disabled = disabledByEnvironment();
  const candidates = disabled
    ? ['libx264'] as const
    : forced ? [forced] : h264HardwareCandidates(platform);
  const resolving = selectWorkingH264Encoder(
    candidates,
    (encoder) => probeEncoder(ffmpeg, encoder, vaapiDevice),
  ).then((encoder) => {
    if (encoder === 'libx264' && candidates.some((c) => c !== 'libx264')) {
      console.warn('[media-acceleration] no working hardware H.264 encoder; using libx264');
    }
    return encoder;
  });
  encoderCache.set(key, resolving);
  return resolving;
}

Common Errors

Error Message Cause Solution
`no working hardware H.264 encoder` GPU drivers missing or encoder not compiled in FFmpeg build Install GPU drivers or use `OPENCHATCUT_DISABLE_HARDWARE_ENCODING=1`
`ffmpeg exited 1` during normalization Source codec unsupported or corrupt media Check FFprobe output for source format details
`could not open encoder` Hardware encoder present but device unavailable Check GPU is not in use by another process
`Binary not found` in packaged app asar unpacking failed Verify `electron-builder` asarUnpack config includes ffmpeg-static

Compatibility Notes

  • NVIDIA Blackwell (RTX 50): NVENC rejects frames below 160x160. The probe uses 160x160 test frames to avoid false fallbacks.
  • Linux VAAPI: Default device is `/dev/dri/renderD128`; override with `OPENCHATCUT_VAAPI_DEVICE`. Requires `format=nv12,hwupload` filter chain.
  • Packaged desktop: The static FFmpeg build has no `libfdk_aac`, so Remotion's AAC encode fails there. A separate hardware binaries directory (`CC_REMOTION_HARDWARE_BINARIES_DIR`) is used for hardware encoder attempts.
  • Windows: Hardware encoder candidates are NVENC, QSV, then AMF. Software fallback is always `libx264`.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment