Create a reframed version of a video
The Aive API allows you to turn a video into reframed versions of itself — for example, to get vertical and square versions of a landscape video — without building a montage by hand.
Creating a reframed version of a video is a four-step process:
Upload & analyse the video
↓
Create a montage from the container
↓
Reframe the montage (update it, or create a reframed copy)
↓
Render the montage(s)This guide walks through the whole flow and links to the dedicated guides for the details of each step.
Prerequisites
Before you start:
- You know your workspace ID. Retrieving a workspace ID works exactly the same way as for scoring — follow step 1 of Score a container if you haven't done so yet.
- You know the ID of the folder you want to upload the video and create the montages in. See Upload a container for how to retrieve a folder ID.
- You know the target format(s) (width and height) you want to reframe the video to.
- Your workspace has enough credits to analyse, reframe and render the video.
Step 1 - Upload and analyse the video
Upload the video file as a container, then analyse it:
- Follow Upload a container to upload the file and wait for its extraction to succeed. Keep the ID of the created container.
- Follow Analyse a container to start its analysis, unless your workspace analyses containers automatically.
- Wait for the analysis of every stream of the container to complete, with an
analysisStatusofsucceeded. See Monitor analysis status.
The montage can not be created until the analysis is complete: the next step is rejected with containerNotAnalyzed while any stream of the container is still being analysed, or has failed its analysis.
Any manifestLevel lets you create the montage. The reframe uses the analysis results, though: with scaleMode: auto (see Step 3), it avoids cropping out on-screen text and logos, which are only detected from manifestLevel: M and XL respectively. See Analysis levels.
Step 2 - Create a montage from the container
Use the createMontageFromContainer mutation to create a montage that plays the whole video, in its original format:
- the montage has the format of the container's video stream;
- it has a single video lane playing the video stream from start to end;
- if the container also has an audio stream, it has an audio lane playing the video's audio, synchronized with the video lane.
CreateMontageFromContainer mutation
mutation CreateMontageFromContainer($input: CreateMontageFromContainerInput!) {
createMontageFromContainer(input: $input) {
... on CreateMontageFromContainerResult {
id
}
... on CreateMontageFromContainerError {
code
message
}
}
}CreateMontageFromContainer variables
{
"input": {
"name": "<montage_name>",
"folderId": "<folder_id>",
"containerId": "<container_id>"
}
}CreateMontageFromContainer input parameters
| Parameter | Type | Description |
|---|---|---|
name | String | The name of the montage. |
folderId | ID | The destination folder for the new montage. |
containerId | ID | The container to create the montage from. It must have a video stream, and be fully analysed. |
CreateMontageFromContainer response
{
"data": {
"createMontageFromContainer": {
"id": "<montage_id>"
}
}
}createMontageFromContainer is synchronous — the montage exists, with its content, as soon as the mutation returns. Keep its id for the next steps.
Step 3 - Reframe the montage
The montage created in Step 2 still has the original format of the video. Reframing it to a new format works exactly as described in Reframe a montage:
- Read the montage's
contentwith themontagequery. - Set the target format in
settings.formaton a copy of that content, and optionally adjustsettings.reframeParams. - Call
reframeMontageContentwith the edited content. It returns the reframed content, without saving it.
Montage query
query MontageContent($id: ID!) {
montage(id: $id) {
content
}
}ReframeMontageContent mutation
mutation ReframeMontageContent($input: ReframeMontageContentInput!) {
reframeMontageContent(input: $input) {
... on ReframeMontageContentResult {
content
}
}
}ReframeMontageContent variables
{
"input": {
"workspaceId": "<workspace_id>",
"content": "<content_with_updated_settings_format>",
"args": {}
}
}content is the MontageContent JSON object itself, not a string: replace the placeholder, quotes included, with the edited object. The same goes for the content of updateMontage and createMontage below. See Reframe a montage for the other reframeMontageContent parameters.
You then have two ways to save the reframed content.
Option A - Update the montage
If you only need the reframed version, replace the montage's content with the reframed content using updateMontage. The montage then has the new format, and the original format is no longer kept.
mutation UpdateMontage($input: UpdateMontageInput!) {
updateMontage(input: $input) {
... on UpdateMontageResult {
ack
}
... on UpdateMontageError {
code
message
}
}
}{
"input": {
"id": "<montage_id>",
"content": "<reframed_montage_content>"
}
}Option B - Create a reframed copy
If you want to keep the montage in the original format, or need several formats, save the reframed content as a new montage with createMontage instead. Repeat the reframe and createMontage for each target format, always starting from the content of the original montage: you get one montage per format, next to the original one.
mutation CreateMontage($input: CreateMontageInput!) {
createMontage(input: $input) {
... on CreateMontageResult {
id
}
}
}{
"input": {
"folderId": "<folder_id>",
"name": "<montage_name>",
"content": "<reframed_montage_content>"
}
}Keep the id of each montage you create, for the next step.
Step 4 - Render the montage(s)
Render each reframed montage into a video file with renderMontageFromSettings, as described in Render a montage. Rendering uses each montage's saved content, so render the montage updated with Option A, or each copy created with Option B.
RenderMontageFromSettings mutation
mutation RenderMontageFromSettings($input: RenderMontageFromSettingsInput!) {
renderMontageFromSettings(input: $input) {
... on RenderMontageFromSettingsResult {
renditionId
}
... on RenderMontageError {
code
message
}
}
}RenderMontageFromSettings variables
{
"input": {
"montageId": "<montage_id>",
"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
}
}
}
}Rendering is asynchronous: the mutation returns a renditionId as soon as the render job is queued. Poll the rendition until its state is succeeded, then download the file from its downloadUrl. See Wait for the rendition and download it.
Errors
createMontageFromContainer returns a typed error through its output union:
| Error code | Description |
|---|---|
containerNotAnalyzed | At least one stream of the container has not been successfully analysed. Wait for the analysis to complete, then try again. |
missingVideoStream | The container has no video stream, e.g. it is an audio-only file. Only a container with a video stream can be turned into a montage. |
Other failures, such as a missing permission on the folder or the container, are returned as standard errors.
For the errors of the other steps, see the Errors section of Analyse a container, Reframe a montage and Render a montage.
Best practices
- Wait for the analysis of every stream of the container to succeed before calling
createMontageFromContainer, rather than retrying oncontainerNotAnalyzed. - Prefer subscribing to the
analysisCompletedwebhook event over polling the streams'analysisStatus. - To get several formats of the same video, create one reframed copy per format from the original montage, rather than reframing an already reframed montage: each reframe then starts from the full original frame.
- Always save the reframed content with
updateMontageorcreateMontagebefore rendering —reframeMontageContentdoes not save anything, and rendering uses the montage's saved content. - Poll each rendition until its
stateissucceededorfailed, and only then request itsdownloadUrl.

