Skip to main content
The RenderOrchestrator class enables distributed rendering by splitting a composition into multiple chunks that can be rendered in parallel. This dramatically reduces rendering time for long videos on multi-core systems.

How it works

  1. Plan: Divides the composition into frame ranges based on concurrency
  2. Render: Executes chunks in parallel using worker renderers
  3. Concatenate: Stitches chunk videos into a single file
  4. Mix: Applies final audio mixing and encoding

Static methods

plan

Creates a render plan without executing it. Useful for previewing the distribution strategy.
string
required
URL of the HTML composition to render.
string
required
Final output file path for the rendered video.
DistributedRenderOptions
required
Configuration object extending RendererOptions with distributed rendering settings.

Returns

A RenderPlan object containing:
number
Total number of frames in the composition.
RenderChunk[]
Array of chunk specifications, each containing:
  • id: Chunk identifier
  • startFrame: First frame in this chunk
  • frameCount: Number of frames to render
  • outputFile: Temporary file path for chunk output
  • options: RendererOptions for this specific chunk
string[]
List of chunk file paths to concatenate.
string
Temporary file path for the concatenated video (before final audio mix).
string
Final output path (same as the outputPath parameter).
RendererOptions
Options for the final audio mixing pass.
string[]
List of temporary files to delete after successful rendering.

Example

render

Executes a distributed render job.
string
required
URL of the HTML composition to render.
string
required
Final output file path for the rendered video.
DistributedRenderOptions
required
Configuration object extending RendererOptions with distributed rendering settings.
RenderJobOptions
Optional job configuration including progress callbacks and abort signals.

Example

Distributed render options

number
Number of parallel render workers. Defaults to os.cpus().length - 1.
RenderExecutor
Custom executor for running render chunks. Defaults to LocalExecutor which runs chunks as parallel processes on the local machine. Implement custom executors for cloud-based or distributed execution.

Concurrency behavior

Automatic concurrency

Single worker fallback

When concurrency: 1, the orchestrator skips chunking and uses a standard Renderer directly:

Custom concurrency

Audio handling in distributed mode

The orchestrator uses a multi-stage audio pipeline:

Chunk rendering

  1. Each chunk renders with PCM audio (pcm_s16le codec)
  2. Audio tracks are not mixed during chunk rendering
  3. Chunks output to .mov container format to preserve PCM audio

Concatenation

  1. Chunk videos are concatenated without re-encoding
  2. PCM audio streams are preserved in the concatenated file

Final mix

  1. Concatenated video is processed with final audio options
  2. Audio tracks from audioFilePath and audioTracks are mixed
  3. Output is encoded with specified audioCodec (default: aac)
  4. Final video uses the container format from outputPath extension

Example with audio

Progress tracking

The orchestrator aggregates progress from all workers:
Each worker’s progress is weighted by its frame count, ensuring accurate overall progress reporting.

Error handling and cancellation

Abort signal

Worker failure propagation

If any worker fails, all other workers are immediately aborted:

Temporary file cleanup

The orchestrator automatically cleans up temporary files:
  • Chunk video files (e.g., temp_123_part_0.mov)
  • Concatenated intermediate file (e.g., temp_concat_123.mov)
Cleanup occurs in the finally block, ensuring files are removed even if rendering fails.

Custom executors

Implement the RenderExecutor interface to run chunks on cloud infrastructure:

Performance considerations

Optimal concurrency

  • CPU-bound: Set concurrency to CPU core count minus 1
  • Memory-bound: Reduce concurrency if renders are memory-intensive
  • Cloud: Scale concurrency based on available cloud workers

Chunk size

Chunk size is automatically calculated as totalFrames / concurrency. For very short videos, some workers may receive no frames:

When to use distributed rendering

Use distributed rendering when:
  • Videos are longer than 30 seconds
  • You have multiple CPU cores available
  • Rendering time is critical
Use standard Renderer when:
  • Videos are very short (< 10 seconds)
  • Single-core environment
  • Simplicity is preferred over speed

Console output

Distributed rendering produces detailed logs: