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

Implementation:0xsline OpenChatCut RenderExportPlan

From Leeroopedia
Knowledge Sources
Domains Video_Rendering, Video_Export, Encoding
Last Updated 2026-10-22 14:00 GMT

Overview

Concrete function that renders an `ExportPlan` to a video/audio file using Remotion's headless browser rendering pipeline, with H.264 hardware acceleration, optional frame-rate retiming, and structured error recovery.

Description

The renderExportPlan function orchestrates the full rendering stage:

  • Progress reporting: Sends phase updates (`preparing`, `rendering`, `finalizing`) and frame counts to the generation job.
  • H.264 encoder selection: Resolves the best available H.264 encoder (NVENC, VAAPI, or software) and passes encoder options to `renderTimeline`.
  • Rendering: Delegates to renderTimeline which drives Remotion's `renderMedia` in a headless Chromium.
  • Frame-rate retiming: If `plan.retimeFps` is set, re-encodes the output at the target FPS using FFmpeg's frame filter (drop/duplicate to preserve duration).
  • Error classification: Catches and classifies failures as cancel, timeout, render, or encode errors; detects OOM patterns; cleans up partial outputs.
  • Abort support: Honors `signal` at every stage.
  • Encoder outcome: Returns `H264EncoderOutcome` with the encoder profile used and any fallback reason.

Usage

  • Export job rendering: Called by the export rendering plugin during the render stage.
  • Export recovery: Re-renders from a stored plan when resuming an interrupted export.

Code Reference

Source Location

  • Repository: OpenChatCut
  • File:*** server/plugins/export-rendering.ts

Signature

export async function renderExportPlan(
  plan: ExportPlan,
  filepath: string,
  update: UpdateGenerationJob,
  signal?: AbortSignal,
): Promise<H264EncoderOutcome | undefined>;

export async function cleanupExportOutputs(paths: Array<string | null>): Promise<ExportCleanupStatus>;
export async function h264RenderOptions(codec: string): Promise<Record<string, unknown>>;
export async function exportCapabilities(): Promise<{ h264: string; renderConcurrency: number }>;

Import

import { renderExportPlan, exportCapabilities } from '../server/plugins/export-rendering.ts';

I/O Contract

Inputs

Name Type Required Description
plan ExportPlan Yes Fully resolved and materialized export plan
filepath string Yes Absolute output file path
update UpdateGenerationJob Yes Progress callback for job lifecycle
signal AbortSignal No Cancellation signal

Outputs

Name Type Description
renderExportPlan() returns undefined Encoder profile and fallback reason
Side effect File Rendered video/audio at `filepath`

Usage Examples

Render an Export Plan

import { renderExportPlan } from '../server/plugins/export-rendering.ts';

const outcome = await renderExportPlan(
  accepted.plan,
  '/tmp/exports/output.mp4',
  (update) => console.log(`Phase: ${update.phase}, Progress: ${update.progress}%`),
  controller.signal,
);

if (outcome?.encoder) {
  console.log(`Encoder: ${outcome.encoder}`);
  if (outcome.encoderFallbackReason) {
    console.log(`Fallback reason: ${outcome.encoderFallbackReason}`);
  }
}

Check Render Capabilities

import { exportCapabilities } from '../server/plugins/export-rendering.ts';

const caps = await exportCapabilities();
console.log(`H.264 profile: ${caps.h264}`);
console.log(`Render concurrency: ${caps.renderConcurrency}`);

Related Pages

Implements Principle

Requires Environment

Uses Heuristic

Page Connections

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