@motiojs/distributed
Chunked rendering for Motio: it splits a video into contiguous frame ranges, renders the chunks in parallel and joins them without re-encoding, while the audio is rendered once for the whole timeline. motio render --chunks=<n> (or --frames-per-chunk=<n>) does the same from the CLI.
pnpm add @motiojs/distributed @motiojs/bundler @motiojs/rendererimport { bundle } from "@motiojs/bundler";import { renderDistributed } from "@motiojs/distributed";import { selectComposition } from "@motiojs/renderer";
const serveUrl = await bundle({ entryPoint: "src/index.ts" });const composition = await selectComposition({ serveUrl, id: "Intro" });
// Four chunks rendered in parallel child processes, joined without re-encoding.const { outputLocation, chunks, timings } = await renderDistributed({ serveUrl, composition, codec: "h264", outputLocation: "out/intro.mp4", chunks: 4, onProgress: ({ stage, progress }) => console.log(stage, Math.round(progress * 100)),});console.log(outputLocation, chunks.length, timings.renderMs, timings.assembleMs);renderDistributed() takes the options of a single-node render (codec, quality, image and audio options, frameRange) plus exactly one of chunks and framesPerChunk, concurrency (chunks rendering at once, default half the CPU threads, at most 8), concurrencyPerChunk (pages per chunk, default 1) and worker. Options are validated before any chunk renders.
- Workers. The default
LocalChunkWorkerrenders each chunk in its own Node child process. AChunkJobis plain JSON, so anotherChunkWorkercan render chunks elsewhere by running the renderer’srenderChunk()where the bundle is reachable; none ships with the package. - Containers. Chunks are MPEG-TS for H.264 and H.265, WebM for VP8, VP9 and AV1, MOV for ProRes. Every worker of an AV1 render needs the same AV1 encoder. GIF, audio-only codecs and
everyNthFramecannot be rendered in chunks. - Building blocks.
planChunks()andassembleChunks()are exported for custom pipelines.
Compatibility
Section titled “Compatibility”There is no Remotion package of the same name: Motio offers this package as its alternative to @remotion/lambda and @remotion/cloudrun, rendering on your own machines. No cloud adapter is implemented yet.
Documentation: motio.esse.dev/reference/packages/distributed · Guide: Rendering from Node, Rendering from the CLI · Source: packages/distributed