To create video with Node.js, you need an API capable of rendering dynamic video. The following example shows how to do that with Creatomate's NPM library. Perhaps you're developing a web application for generating videos based on dynamic data or user input. Here's how using just a few lines of JavaScript:
const Creatomate = require('creatomate');
const client = new Creatomate.Client('Your API Key');
client.render({
// The ID of the template that you created in the online editor.
templateId: '58c1163e-f250-49df-b98d-e8c4aad01a2d',
// Inserting several images into the video template.
modifications: {
'Text': 'Your Text And Video Here',
'Video': 'https://cdn.creatomate.com/demo/drone.mp4',
},
}).then((renders) => {
console.log(renders);
});
How it works: In this example, we'll be using the Creatomate video library from NPM. By using this package, you will be able to generate a video entirely with JavaScript without the need for any other libraries or specialized hardware - all straight from your Node.js application. The above example shows how to create a video from a template, but you can also create videos by performing specific video editing tasks, like stitching, merging, cropping, and many more. Be sure to also check out the other examples further down this page.
The easiest approach of creating a video using Node.js is to use a video template. This video template is created using the online video editor. With this tool, you can design your own template quickly and conveniently in a drag-and-drop environment.
Having created a template, you can reference it in your Node.js application by its ID. The "modifications" parameter allows you to insert dynamic content into the video template to produce a unique video MP4. This parameter lets you edit the template in its entirety, whether it's inserting text, changing the background video, or adding new scenes. After the "render" function returns, the MP4 file has completed processing and can be used by your Node.js application.
To get started, follow this quick tutorial or check out the API documentation.