How to Create a Video from Images using Node.js?

A great way to share a collection of images on social media is by converting them into short videos. This is commonly used for showcasing real estate listings, e-commerce products, and news videos, in which several photos are compiled into engaging slideshows. To convert images into video content with Node.js, you'll need a video API. Here's how it's done with JavaScript:

Input Code
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: {
    'Image-1': 'https://cdn.creatomate.com/demo/living-room.jpg',
    'Image-2': 'https://cdn.creatomate.com/demo/bathroom.jpg',
    'Image-3': 'https://cdn.creatomate.com/demo/kitchen.jpg',
  },

}).then((renders) => {
  console.log(renders);
});
Output Video

How it works: For this example, we'll be using the Creatomate library from NPM. With this package, we can generate videos based on a template and a series of image URLs. The video creation process is handled by Creatomate's infrastructure, so there is no need to host a video infrastructure yourself.

The first step in making a video from images is to create a template in your account. This can be done using the video editor. With this online tool, it is easy to design any type of image-based video that suits your needs. For example, in the example above, we have used a real estate template that includes multiple pictures and text captions.

For simplicity, we only replace three images (Image-1, Image-2, and Image-3) through the "modifications" parameter, however, it is possible to change any element within the template using dynamic data, such as text captions, video footage, colors, or logos. This gives you full control over how the video slideshow is generated through the use of JavaScript.

After the video rendering has been completed, you receive an URL that links to the generated MP4 file. The generated video can now be used in your Node.js application, for example, to post it automatically to social media or to host it on your own site.

To get started, follow this quick tutorial or check out the API documentation.

Edit this Code Example in the Video Editor

Easily design your own video templates using the online editor. Then, export your templates as JSON and integrate them into your Node.js application to create any kind of video – completely through code.

Related Node.js Video Editing Questions

Start automating today

Start with a full-featured trial with 50 credits, no credit card required.
Get started for free