witySceneRender — Render Gateway
witySceneRender is the single public entry point for all wity-scene rendering. Send a scene XML document and an optional output format — the gateway parses the scene, selects the correct internal pipeline, and returns the rendered output URL. Callers never invoke the downstream Lambdas directly.
Location: services/scene-render/gateway/
Input
{
"sceneXml": "<wity-scene>...</wity-scene>",
"outputFormat": "mp4",
"options": {}
}| Field | Type | Default | Description |
|---|---|---|---|
sceneXml | string | required | The <wity-scene> XML document |
outputFormat | string | "mp4" | Output format: "mp4", "pdf", "pptx" |
"mp4" options:
| Option | Type | Default | Description |
|---|---|---|---|
options.fps | number | 30 | Output frame rate |
options.sceneWidth | number | 1280 | Canvas width px |
options.sceneHeight | number | 720 | Canvas height px |
options.fontManifest | object | {} | Custom fonts: { "FontName": "https://url/font.ttf" } |
"pdf" options:
| Option | Type | Default | Description |
|---|---|---|---|
options.ts | number | 0 | Scene time (seconds) to snapshot |
options.timestamps | number[] | — | One page per timestamp; overrides ts |
options.variant | "standard" | "print" | "standard" | Screen (96 DPI) or print-ready (300 DPI) |
options.dpi | number | 96 / 300 | Override render DPI |
options.fontManifest | object | {} | Custom fonts |
"pptx" options:
| Option | Type | Default | Description |
|---|---|---|---|
options.ts | number | 0 | Scene time (seconds) to snapshot |
options.timestamps | number[] | — | One slide per timestamp; overrides ts |
options.fontManifest | object | {} | Custom fonts |
Output
{ "url": "https://...", "fileSize": 9876543, "pipeline": ["witySceneToVideo", "witySceneCompose"] }| Field | Type | Description |
|---|---|---|
url | string | Public S3 URL of the rendered output |
fileSize | number | Output file size in bytes |
pipeline | string[] | Which internal Lambdas were invoked (observability / cost attribution) |
pages | number | Number of pages — "pdf" only |
slides | number | Number of slides — "pptx" only |
Routing
"mp4" — content-aware routing
The gateway parses the scene and inspects element tags across all layers:
| Scene content | Route | pipeline value |
|---|---|---|
Only ws-rect / ws-text / ws-image | witySceneToVideo only | ["witySceneToVideo"] |
Graphics + ws-video / ws-audio | witySceneToVideo → witySceneCompose | ["witySceneToVideo", "witySceneCompose"] |
Only ws-video / ws-audio | witySceneCompose only (graphicsMp4Url: null) | ["witySceneCompose"] |
caller → witySceneRender
│ parse + detect content
├─ hasGraphics? → witySceneToVideo → graphicsMp4Url
└─ hasMedia? → witySceneCompose(graphicsMp4Url) → final URL → caller"pdf" and "pptx" — single downstream call
No content inspection. ws-video and ws-audio are silently skipped by the snapshot renderer.
caller → witySceneRender
├─ "pdf" → witySceneToPdf → S3 URL → caller
└─ "pptx" → witySceneToPptx → S3 URL → callerLambda config
| Setting | Value |
|---|---|
| Function name | witySceneRender |
| Runtime | Node.js 20 |
| Memory | 512 MB |
| Timeout | 660 s (11 min — accommodates two sequential 300 s downstream calls for mp4) |
| Ephemeral storage | 512 MB |
| FFmpeg layer | Not required — this Lambda only parses and routes |
Environment variables
| Variable | Default | Description |
|---|---|---|
SCENE_TO_VIDEO_FUNCTION | witySceneToVideo | Graphics compiler Lambda |
SCENE_COMPOSE_FUNCTION | witySceneCompose | Full compositor Lambda |
SCENE_TO_PDF_FUNCTION | witySceneToPdf | PDF renderer Lambda |
SCENE_TO_PPTX_FUNCTION | witySceneToPptx | PPTX renderer Lambda |
AWS_REGION | ap-south-1 | AWS region for Lambda invocations |
IAM note: The execution role must have
lambda:InvokeFunctionon all four downstream Lambdas.
Error responses
| Status | Condition |
|---|---|
400 | sceneXml missing |
400 | Invalid JSON body |
400 | Malformed XML (parse error) |
400 | Unknown outputFormat |
400 | Scene has no renderable elements (mp4 only) |
500 | Downstream Lambda failed |
Downstream Lambdas (internal — do not invoke directly)
witySceneToVideo — graphics compiler
Renders ws-rect, ws-text, ws-image → PNG frame sequence → silent MP4. ws-video and ws-audio are silently ignored.
Package: @wity/scene-to-video
| Setting | Value |
|---|---|
| Memory | 3008 MB · Timeout 300 s · Ephemeral 4096 MB |
| FFmpeg layer | arn:aws:lambda:ap-south-1:175033217214:layer:ffmpeg:1 |
witySceneCompose — full compositor
Blends ws-video clips + ws-audio tracks + optional graphics overlay via FFmpeg filter_complex.
Package: @wity/scene-compose
| Setting | Value |
|---|---|
| Memory | 2048 MB · Timeout 300 s · Ephemeral 4096 MB |
| FFmpeg layer | arn:aws:lambda:ap-south-1:175033217214:layer:ffmpeg:1 |
witySceneToPdf — PDF renderer
Snapshots scene at one or more timestamps via node-canvas → pdf-lib → PDF file.
Package: @wity/scene-to-pdf
| Setting | Value |
|---|---|
| Memory | 2048 MB · Timeout 120 s · Ephemeral 1024 MB |
| FFmpeg layer | Not required |
witySceneToPptx — PPTX renderer
Snapshots scene at one or more timestamps via node-canvas → pptxgenjs → PowerPoint file.
Package: @wity/scene-to-pptx
| Setting | Value |
|---|---|
| Memory | 1024 MB · Timeout 120 s · Ephemeral 1024 MB |
| FFmpeg layer | Not required |
S3 output
The gateway does not write to S3. Downstream Lambdas write to the wity-user-generated-content bucket:
| Lambda | Prefix |
|---|---|
witySceneToVideo | scene-compiled/ |
witySceneCompose | scene-composed/ |
witySceneToPdf | scene-pdf/ |
witySceneToPptx | scene-pptx/ |
Extensibility
The gateway uses a PIPELINE_REGISTRY keyed by outputFormat. Adding a new format:
- Deploy a new specialized Lambda.
- Add one entry to
PIPELINE_REGISTRYinhandler.js. - Add the corresponding env var to the gateway config.
No changes to any existing Lambda.
Related
- Deployment guide — full server-side pipeline walkthrough
@wity/scene-to-video— graphics compiler package@wity/scene-compose— full compositor package@wity/scene-to-pdf— PDF renderer package@wity/scene-to-pptx— PPTX renderer package
