OGraf Renderer

OGraf Renderer (serviceId markusnygard-ograf-renderer, license Apache-2.0) is a headless renderer for EBU OGraf graphics. Give it a graphic, its data, a format and a length, and it returns a frame-accurate, transparent PNG sequence, and optionally a ProRes 4444 or VP9 WebM file with alpha. In Eyevinn Open Source Cloud (OSC) it is a long-running service instance with an HTTP render API, a web editor that applications can embed, and 20 GiB of storage per instance for the graphics library and the renders.

What it can do

  • Render OGraf graphics to PNG sequences with straight alpha, in 1080p25/50, 1080i50, 2160p25/50 and, for graphics that declare them, vertical and square formats.
  • Encode the result to ProRes 4444 with alpha (graphic.mov) or VP9 WebM with alpha (graphic.webm).
  • Render both non-realtime graphics and realtime-only graphics (for example SPX templates), the latter on a virtual clock so every run gives the same frames.
  • Keep a graphics library that you fill by uploading zip files over the API.
  • Give your application an "Import OGraf" flow: the web editor lets a user pick a graphic, fill it in and preview it, the render runs in the background, and a signed webhook tells your application when it is done.

Creating an instance

The service has no dependencies. It needs one value from you: an API token, a long random string of your own choice (for example from openssl rand -hex 32). Every /api call must send it, and the instance does not start without it.

Store the token as a service secret with create-service-secret (serviceId markusnygard-ograf-renderer), for example ografapitoken. Then call create-service-instance with serviceId: "markusnygard-ograf-renderer":

{
  "name": "myrenderer",
  "ApiToken": "{{secrets.ografapitoken}}"
}

Wait with wait-for-service-ready or get-instance-status, then read the instance URL with describe-service-instance. GET /health on the instance URL answers { "ok": true, ... } without a token when the service is up. The root path / has no page and answers 404; that is expected.

Options

Option Required Type Meaning
name Yes string Name of the instance. Letters, digits and underscore (^\w+$); OSC limits names to 20 characters.
ApiToken Yes string, sensitive Bearer token that every /api call must send as Authorization: Bearer <token>. Use a long random string. The instance does not start without it.
EditorOrigins No string Comma-separated origins of the applications that may embed the web editor, receive its messages and be returned to, for example https://app.example.com.
WebhookAllow No string Comma-separated list of where render webhooks may be sent: origins, or wildcard hosts such as *.example.com (https only). Webhooks are off when empty.
WebhookSecret No string, sensitive Secret used to sign webhooks (X-Ograf-Signature header). Use a long random string.
CorsOrigin No string Browser origin allowed to call the API directly, for example https://app.example.com.
RetentionHours No string Hours a finished render is kept before it is deleted. Default 24; 0 keeps renders.

Pass ApiToken and WebhookSecret as {{secrets.NAME}}, which must be the entire field value.

Using the instance

All examples use the instance URL and your API token:

export OGRAF=https://<your-instance-url>
export TOKEN=<your-api-token>

Upload a graphic

A graphic is a zip file with its *.ograf.json manifest at the top or in one folder. The name in the URL is how you refer to it afterwards (letters, digits, ., _ and -).

curl -X PUT -H "Authorization: Bearer $TOKEN" --data-binary @lower-third.zip \
  $OGRAF/api/graphics/lower-third

curl -H "Authorization: Bearer $TOKEN" $OGRAF/api/graphics

The list shows each graphic's data schema, which tells you what to send as data. Add ?replace=true to overwrite an existing graphic. Sample graphics are in the upstream repository.

Render

curl -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
  $OGRAF/api/renders -d '{
    "graphic": "lower-third",
    "format": "1080p25",
    "duration": 3,
    "data": { "name": "Jane Doe", "title": "Reporter" },
    "encodes": ["prores", "webm"]
  }'

The answer is 202 with an id and "state": "queued". Poll the render until its state is done, then download the files:

curl -H "Authorization: Bearer $TOKEN" $OGRAF/api/renders/<id>
curl -H "Authorization: Bearer $TOKEN" -o graphic.mov $OGRAF/api/renders/<id>/files/graphic.mov
curl -H "Authorization: Bearer $TOKEN" -o frames.tar $OGRAF/api/renders/<id>/frames.tar

A three-second 1080p25 lower third with both encodes takes roughly 45 seconds.

The web editor

To let users make graphics from your own application, set EditorOrigins to your application's origin and, for the "render done" notification, WebhookAllow and WebhookSecret. Your server then opens an editor session with POST /api/editor-sessions and hands the returned editorUrl to the browser. The editor never sees the API token. The full flow is in the upstream editor guide.

Limitations

  • The instance URL is reachable from the internet without an OSC login, so the API token is its only protection. Graphics are third-party code that the service runs in a browser: only give the token to systems you trust, and only upload graphics you trust.
  • Graphics cannot load anything from the network (web fonts, remote images). Put fonts and images inside the graphic's zip. The image includes Liberation, DejaVu and Noto fonts (including CJK and emoji).
  • One render runs at a time; further renders wait in the queue. The instance has 2 GiB of memory, and UHD renders need considerably more than HD, so they may fail or be slow.
  • Finished renders are deleted after RetentionHours (24 by default). Download what you need to keep. The graphics library stays until you delete it.
  • Tested on OSC: upload, a 1080p25 render to PNG, ProRes and WebM, downloads, creating an editor session, and that the library survives a restart. Not tested on OSC: the editor in a browser, webhooks, interlaced, UHD, vertical and square formats, and long renders.

Resources