Skip to content

Render a montage ​

The Aive API allows you to render (export) a montage into a video file, using an existing preset or the encoding settings of your choice.

Rendering uses the montage's latest saved content. If you have just generated or reframed a montage, make sure you have saved it with updateMontage first. See Generate a montage and Reframe a montage.

Rendering is asynchronous: the mutation starts a background job and immediately returns the ID of the rendition being produced. You then poll that rendition until it has succeeded, and download the rendered file.

Two ways to render ​

There are two rendering mutations, depending on whether you want to provide encoding settings inline or reuse an existing preset:

  • renderMontageFromSettings renders a single montage using the encoding settings you pass in.
  • renderMontages renders one or more montages, each to one or more existing presets, in a single call. Use this to re-render, or to render several montages to the same preset(s) at once.

A rendition preset is a saved set of encoding settings. Presets are created through the app; renderMontages then references them by ID through presetIds. Currently, it is not possible to create rendition presets from API.

Prerequisites ​

Before rendering a montage:

  • You know the ID of the montage (or montages) to render.
  • The montage content you want to render has been saved.
  • You know the IDs of the presets you want to render to, or the encoding settings you want (container, video codec, and optionally an audio codec).
  • Your workspace has enough credits to render the montage.

Render one or more montages to presets ​

Use the renderMontages mutation to render one or more montages to one or more existing presets in a single call. It renders every montage to every preset, producing one rendition per montage-and-preset combination.

The presetIds you pass are the IDs of presets already configured in your workspace, such as presets previously created through the app.

RenderMontages mutation ​

graphql
mutation RenderMontages($input: RenderMontagesInput!) {
  renderMontages(input: $input) {
    ... on RenderMontagesResult {
      renditionIds
    }
    ... on RenderMontageError {
      code
      message
    }
  }
}

RenderMontages variables ​

json
{
  "input": {
    "montages": [
      { "id": "<montage_id_a>", "burnSubtitlesIndex": 0 },
      { "id": "<montage_id_b>" }
    ],
    "presetIds": ["<preset_id_1>", "<preset_id_2>"]
  }
}

RenderMontages response ​

The two montages and two presets above produce four renditions. The returned renditionIds follow the input order, montage-major then preset-minor, so here they are [a×1, a×2, b×1, b×2]:

json
{
  "data": {
    "renderMontages": {
      "renditionIds": [
        "<rendition_a_1>",
        "<rendition_a_2>",
        "<rendition_b_1>",
        "<rendition_b_2>"
      ]
    }
  }
}

RenderMontages parameters ​

ParameterTypeDescription
montages[RenderMontageInput!]The montages to render, each rendered to every preset in presetIds. Each entry is a RenderMontageInput with an id (the montage ID) and an optional burnSubtitlesIndex (Int) that burns that subtitle track into this montage's renders. See Burning subtitles.
presetIds[ID!]The IDs of the presets to render each montage to.

renderMontages is all-or-nothing: if any preset is not available for one of the montages, or its settings are not valid for a montage's content, the whole call fails with a RenderMontageError and nothing is created or charged.

Render with your own settings ​

Use the renderMontageFromSettings mutation to render a single montage with the encoding settings of your choice.

RenderMontageFromSettings mutation ​

graphql
mutation RenderMontageFromSettings($input: RenderMontageFromSettingsInput!) {
  renderMontageFromSettings(input: $input) {
    ... on RenderMontageFromSettingsResult {
      renditionId
    }
    ... on RenderMontageError {
      code
      message
    }
  }
}

RenderMontageFromSettings variables ​

json
{
  "input": {
    "montageId": "<montage_id>",
    "burnSubtitlesIndex": 0,
    "settings": {
      "container": "mp4",
      "videoParams": {
        "codec": {
          "h264": {
            "crf": 23,
            "pixelFormat": "yuv420p"
          }
        },
        "fps": 30,
        "colorspace": "bt709"
      },
      "audioParams": {
        "codec": {
          "aac": {
            "enable": true,
            "sampleRate": 48000
          }
        },
        "integratedLoudnessTarget": -14,
        "truePeak": -1
      }
    }
  }
}

The values above are an example of a common H.264 / AAC mp4 export; adjust them to your needs.

RenderMontageFromSettings response ​

json
{
  "data": {
    "renderMontageFromSettings": {
      "renditionId": "<rendition_id>"
    }
  }
}

RenderMontageFromSettings parameters ​

ParameterTypeDescription
montageIdIDThe ID of the montage to render.
settingsRenditionSettingsInputThe encoding settings of the rendered file. See Encoding settings.
burnSubtitlesIndexIntOptional. Burns the subtitle track at this index into the rendered video. Chosen per render, not part of the reusable encoding settings. See Burning subtitles.

Encoding settings ​

FieldTypeDescription
containerEnumThe file container: avi, mkv, mov, mp4, mxf or webm.
videoParams.codecVideoCodecParamsInputThe video codec and its parameters. Set the codec you want among h264, h265, vp9, mpeg4, mpeg2 and prores.
videoParams.fpsFloatThe frame rate of the rendered video.
videoParams.colorspaceEnumThe colorspace of the rendered video: bt709 or bt601.
audioParamsAudioParamsInputThe audio codec and loudness settings.
audioParams.codecAudioCodecParamsInputThe audio codec and its parameters. Set the codec you want among aac, vorbis, opus, flac, mp3, alac, eac3 and pcm.
audioParams.integratedLoudnessTargetIntThe integrated loudness target of the audio.
audioParams.truePeakIntThe true peak limit of the audio.

Not every combination of container and codec is valid, and invalid settings are rejected with a validation error. See the RenditionSettingsInput reference for the full list of codec parameters and accepted values.

Burning subtitles ​

If a montage has subtitle tracks, you can burn one of them directly into the rendered video with burnSubtitlesIndex, the zero-based index of the track to burn (0 is the first track). Leave it out or set it to null to render without burning any subtitles.

This choice is made per render, not stored on the preset, so the same preset can be reused with or without burned subtitles, and different montages in the same call can burn different tracks:

  • renderMontageFromSettings takes a single top-level burnSubtitlesIndex.
  • renderMontages takes it per montage, as montages[].burnSubtitlesIndex.

An index that is out of range for a montage's subtitle tracks, including any index on a montage without subtitle tracks, is rejected with a RenderMontageError whose code is invalidRenditionParams.

Note that burning the subtitles is the only way to guarantee they have the same appearance as in your montage. If you don't burn them they will be exported as an SRT file and their style will depend on the software that render them not us.

Wait for the rendition and download it ​

Both mutations return as soon as the render job is queued. renderMontageFromSettings returns a single renditionId, while renderMontages returns one per montage-and-preset combination. Each ID identifies a rendition being produced.

Poll the rendition with the rendition query until its state is succeeded, then read its downloadUrl.

Rendition query ​

graphql
query Rendition($id: ID!) {
  rendition(id: $id) {
    id
    state
  }
}
json
{
  "id": "<rendition_id>"
}

Rendition states ​

StateDescription
pendingWaiting in the processing queue.
processingThe render is currently in progress.
succeededThe render completed successfully. The file can be downloaded.
failedThe render failed.

succeeded and failed are terminal. There is no webhook event for renditions, so polling is the only way to follow their progress. Poll at a reasonable interval (for example every few seconds) rather than in a tight loop.

Download the rendered file ​

Once state is succeeded, query downloadUrl to get a signed URL to download the file.

graphql
query RenditionDownload($id: ID!) {
  rendition(id: $id) {
    state
    downloadUrl
  }
}
json
{
  "data": {
    "rendition": {
      "state": "succeeded",
      "downloadUrl": "https://..."
    }
  }
}

The file is delivered as a .zip archive named after the montage. The signed URL is temporary: request a fresh one with the same query if it has expired.

Only request downloadUrl once the state is succeeded: the file doesn't exist before that, and the query will return an INTERNAL_SERVER_ERROR.

You can also list the renditions of a montage through its renditions field.

Errors ​

Both mutations return typed errors through RenderMontageError:

Error codeDescription
presetNotAvailableA preset is not available for the montage you are rendering.
invalidRenditionParamsA preset's settings are not valid for the montage's content.

Other failures are returned as standard errors, notably:

  • MISSING_PERMISSION if you cannot render this montage;
  • INSUFFICIENT_CREDITS if the workspace does not have enough credits;
  • GRAPHQL_VALIDATION_FAILED if the encoding settings are invalid for the montage.

See Error handling for how these errors are returned.

Best practices ​

  • Save your montage with updateMontage before rendering, since the render uses the montage's latest saved content.
  • Use renderMontageFromSettings when you want to render with specific encoding settings; use renderMontages to re-render or to render several montages to the same preset(s) in one call.
  • Start from the example settings and change one thing at a time, since invalid codec and container combinations are rejected.
  • Make sure the workspace has enough credits before rendering. renderMontages is all-or-nothing, so a batch that exceeds your credits creates nothing.
  • Poll rendition until state is succeeded or failed, and only then request downloadUrl.