Skip to content

Latest commit

 

History

History
81 lines (57 loc) · 2.35 KB

File metadata and controls

81 lines (57 loc) · 2.35 KB

cloudmotion npm version

TypeScript client and CLI for Cloudmotion. Upload Remotion bundles and start renders from scripts and CI.

API docs: cloudmotion.dev/docs.

Install

npm i cloudmotion

CLI

export CLOUDMOTION_TOKEN=cm_...

Upload a Remotion bundle directory (after npx remotion bundle), then start a render:

npx cloudmotion bundles upload dist/bundle --bundle-id my-project

npx cloudmotion render \
  --bundle-id my-project \
  --composition-id MyComp

Re-uploading under the same bundle ID replaces the latest bundle used for renders. The render command prints progress to stderr and the output URL on stdout when finished.

SDK

Pass token in the client constructor (the SDK does not read environment variables).

import { createClient } from 'cloudmotion'
import { uploadBundle } from 'cloudmotion/node'

const client = createClient({ token: 'cm_...' })

const bundle = await uploadBundle(client, {
  bundleDir: 'dist/bundle',
  bundleId: 'my-project',
})

const { renderId } = await client.renderMedia({
  bundleId: bundle.bundleId,
  compositionId: 'MyComp',
  inputProps: { title: 'Hello' },
})

let status = await client.getRenderProgress(renderId)
while (status.status !== 'completed' && status.status !== 'failed') {
  await new Promise(r => setTimeout(r, 2000))
  status = await client.getRenderProgress(renderId)
}

console.log(status.outputUrl)

API surface

  • createClient({ token, fetch? }): optional custom fetch (e.g. for timeouts or logging)
  • uploadBundle(client, { bundleDir, bundleId, onUploadProgress? }) from cloudmotion/node: returns { bundleId, uploadId, remotionVersion, runtimeReady }
  • client.renderMedia(input) / client.renderStill(input): returns { renderId }
  • client.getRenderProgress(renderId): poll { status, progress, error?, outputUrl? }

curl (no SDK)

See cloudmotion.dev/docs.

# Start render
curl "https://api.cloudmotion.dev/v1/renders" \
  -H "Authorization: Bearer cm_..." \
  --json '{"bundleId":"my-project","compositionId":"MyComp","kind":"media"}'

# Poll status
curl "https://api.cloudmotion.dev/v1/renders/$RENDER_ID" \
  -H "Authorization: Bearer cm_..."