How to Merge Videos using Node.js?

There are instances in which you have to concatenate two or more videos. Consider a situation where you have several video fragments that need to be stitched into a single video. For example, you may want to add an outro to a user-recorded video. To accomplish this task using JavaScript, you'll need a video editing API. Here's how to do that using Node.js in just a few lines of code:

Input Code
const Creatomate = require('creatomate');
const client = new Creatomate.Client('Your API Key');

  source: new Creatomate.Source({
    outputFormat: 'mp4',
    width: 1920,
    height: 1080,
    elements: [

      new Creatomate.Video({
        track: 1,
        source: '',

      new Creatomate.Video({
        track: 1,
        source: '',
        animations: [
          new Creatomate.Fade({
            time: 'start',
            duration: 1,
            transition: true,

}).then((renders) => {
Output Video

How it works: Start by installing the Creatomate library from NPM. In order to sequentially play each video element, they have to be placed on the same track (in this example, track 1). You don't have to specify the start and duration of each clip because the track automatically adjusts its length to accommodate the elements. So to combine two videos, you can just provide the URLs where they're hosted, and the API will take care of the rest.

If you want to include a transition between the two clips, you can utilize the "animations" property. This property accepts an array of animations that are applied to the element. In this scenario, we apply a fade animation lasting for 1 second to the second video element. By setting the "transition" property to "true", it overlaps with the first video clip.

Merging two videos together is just one of the many powerful features offered by the video editing API. The best part is that you can fully automate each video editing task using Node.js. The online video editor provides a user-friendly drag-and-drop interface where you can create and design your video. Then, you can export the video as Node.js code to perform any kind of video-related tasks fully automated.

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.