Rendering
When you're done adding layers to a composition, it's time to render the composition. This sends a request to our servers to begin encode the video.
There are two encode modes: and asynchronous and synchronous.
Asynchronous encoding
Asynchronous encoding means that once the reqeuest is recieved, our servers will start the encoding process, then immediately return a status response.
Asynchronous encoding allows your code to execute faster because it only tells Editframe to start encoding the video, but doesn't wait for encoding to complete.
The tradeoff is that you will need to set up a webhook endpoint (or manually implement your own system) to determine when encoding has completed and you can access the video.
Encode request
const response = await composition.encode();
Response
{
"id": "yKOqd7QnJZ",
"timestamp": 1651671897,
"status": "processing"
}
Synchronous encoding
Synchronous encoding means that editframe-js will wait for encoding to finish, then return the video object.
Synchronous encoding is simpler than asynchronous encoding because it allows encoding and retrieval of the completed video with one line of code. The tradeoff is that the call to encode
will take considerably longer to execute than calling it asynchronously.
Encode request
const video = await composition.encodeSync();
Response
{
"id": "PgQQX3hrtZ",
"is_ready": true,
"download_url": "https://api.editframe.com/v2/videos/PgQQX3hrtZ/download",
"stream_url": "https://api.editframe.com/v2/videos/PgQQX3hrtZ/stream",
"metadata": { ... },
"timestamp": 692233200,
},