Miraiclip SDK

Overview

What to deploy when you self-host Miraiclip, and where it can run.

Miraiclip runs in the browser. Preview and browser export happen on the user's machine, so an editor built on the SDK is a static site: no render servers and no per-render cost.

You deploy servers only for exports that have to happen without a browser tab:

You needDeploy
An editor in your productStatic files only: your app's build on any static host or CDN
Exports from your backend (an API, a queue, scheduled jobs)One render worker container
Long videos rendered fastSeveral render workers, driven by renderDistributed
Many videos from one templateRender workers, or batch rendering on one machine

The render worker

The render worker is a small Node server around createRenderJobHandler from @miraiclip/server-export. It runs headless Google Chrome and renders with the same exportProject the browser uses, so server output matches the preview.

PropertyDetails
InputPOST / with a JSON render job: a project document plus export options
OutputThe encoded MP4 or WebM file in the response body
Health checkGET /healthz answers ok
StateNone. The job carries the whole document, so instances can scale to zero
AuthA bearer token from RENDER_TOKEN
ConcurrencyOne job at a time per container. Add containers to render more at once

Assets must be reachable from the worker: put media in object storage (S3, Cloud Storage) and use https: URLs in the document. Signed URLs work.

Where to run it

The same Docker image runs everywhere:

PlatformScales to zeroLongest jobGood for
Cloud RunYes60 minutesThe simplest setup. One job per instance, built in
ECS on FargateNo (scale to a minimum of 1)No limit (set the load balancer timeout)Steady traffic, full control of networking
AWS LambdaYes15 minutesBursts of short distributed chunks
A VM (EC2, Compute Engine)NoNo limitGPUs, fixed cost, long single-pass exports

Sizing

Rendering is CPU-bound. On a 2-vCPU Xeon with software rendering, 1080p30 costs about 930 CPU-seconds per minute of output, and 4K about 4,400 (see Render cost). Start with:

OutputvCPUMemory
Up to 1080p24 GB
4K48 GB

Measure on your own hardware with bench:cost before sizing a fleet. A GPU or a hardware encoder changes these numbers a lot.

Security

  • Set RENDER_TOKEN on every deployment with a public URL. Without it, anyone who finds the URL can render on your bill.
  • The worker fetches the https: URLs in the documents it receives. Only send it documents your own backend built or checked.
  • Server export never runs a document's plugins unless you allow them in the handler's plugins option.

On this page