The /video/merge Robot

Transloadit offers a variety of features to reduce video size while maintaining quality, as well as add effects like watermarks.

The /video/merge Robot composes a new video by adding an audio track to existing still image(s) or video.

Parameters

Name Type Default Description
preset String "flash" Generates the video according to pre-configured video presets. If you specify your own FFmpeg parameters using the Robot's ffmpeg parameter and you have not specified a preset, then the default "flash" preset is not applied. This is to prevent you from having to override each of the flash preset's values manually.
width Integer(1-1920) Width of the input image Width of the generated video, in pixels.
height Integer(1-1080) Height of the input image Height of the generated video, in pixels.
resize_strategy String "pad" If the given width/height parameters are bigger than the input image's dimensions, then the resize_strategy determines how the image will be resized to match the provided width/height. See the available resize strategies.
background String "00000000" The background color of the resulting video the "rrggbbaa" format (red, green, blue, alpha) when used with the "pad" resize strategy. The default color is black.
framerate String "1/5" When merging images to generate a video this is the input framerate. A value of "1/5" means each image is given 5 seconds before the next frame appears (the inverse of a framerate of "5"). Likewise for "1/10", "1/20", etc. A value of "5" means there are 5 frames per second.
duration Float 5.0 When merging images to generate a video this is the desired target duration in seconds. The float value can take one decimal digit. If you want all images to be displayed exactly once, then you can set the duration according to this formula: duration = numberOfImages / framerate. This also works for the inverse framerate values like 1/5.

Example use cases

Our /video/merge Robot can be used in combination with other Robots, to create powerful workflows unique to your use case.
Here are a few example scenarios, and the required the Assembly Instructions to implement them.
You can also try demos of these examples right here, live on our website.

Convert any video to animated GIF

{
  "steps": {
    "extracted_thumbs": {
      "use": ":original",
      "robot": "/video/thumbs",
      "result": false,
      "count": 50
    },
    "anigif": {
      "robot": "/video/merge",
      "use": {
        "steps": [
          {
            "name": "extracted_thumbs",
            "as": "image"
          }
        ]
      },
      "result": true,
      "duration": 7.8,
      "framerate": "10",
      "ffmpeg_stack": "v2.2.3",
      "ffmpeg": {
        "f": "gif",
        "pix_fmt": "rgb24"
      },
      "resize_strategy": "pad"
    },
    "exported": {
      "use": [
        ":original",
        "anigif"
      ],
      "robot": "/s3/store",
      "key": "YOUR_AWS_KEY",
      "secret": "YOUR_AWS_SECRET",
      "bucket": "YOUR_S3_BUCKET"
    }
  }
}

Generate a video from an image sequence

{
  "steps": {
    "imported_video_encode": {
      "robot": "/http/import",
      "url": "https://transloadit.com/assets/images/robots/video-encode.jpg"
    },
    "imported_image_resize": {
      "robot": "/http/import",
      "url": "https://transloadit.com/assets/images/robots/image-resize.jpg"
    },
    "imported_audio_encode": {
      "robot": "/http/import",
      "url": "https://transloadit.com/assets/images/robots/audio-encode.jpg"
    },
    "merger": {
      "robot": "/video/merge",
      "use": {
        "steps": [
          {
            "name": ":original",
            "as": "audio"
          },
          {
            "name": "imported_video_encode",
            "as": "image"
          },
          {
            "name": "imported_image_resize",
            "as": "image"
          },
          {
            "name": "imported_audio_encode",
            "as": "image"
          }
        ]
      },
      "result": true,
      "framerate": "1/3",
      "duration": 9,
      "ffmpeg_stack": "v2.2.3",
      "preset": "ipad-high",
      "resize_strategy": "pad"
    }
  }
}

Merge an audio and a video file

{
  "steps": {
    "audio_import": {
      "robot": "/http/import",
      "url": "http://static.transloadit.com/crm_demos/buddha_machine.wav"
    },
    "image_import": {
      "robot": "/http/import",
      "url": "https://transloadit.com/assets/images/robots/170x170/html-convert.jpg"
    },
    "merged_video": {
      "robot": "/video/merge",
      "ffmpeg_stack": "v2.2.3",
      "use": [
        {
          "name": "audio_import",
          "as": "audio"
        },
        {
          "name": "image_import",
          "as": "image"
        }
      ],
      "width": 170,
      "height": 170,
      "preset": "iphone-high",
      "result": true
    },
    "replaced_audio_track": {
      "robot": "/video/merge",
      "use": [
        {
          "name": ":original",
          "as": "audio"
        },
        {
          "name": "merged_video",
          "as": "video"
        }
      ],
      "result": true,
      "ffmpeg_stack": "v2.2.3",
      "width": 170,
      "height": 170,
      "preset": "iphone-high"
    }
  }
}

Merge an audio file and an image to generate a video

{
  "steps": {
    "imported_image": {
      "robot": "/http/import",
      "url": "https://transloadit.com/assets/images/video-merge-demo/mountain.jpg"
    },
    "merger": {
      "robot": "/video/merge",
      "use": {
        "steps": [
          {
            "name": ":original",
            "as": "audio"
          },
          {
            "name": "imported_image",
            "as": "image"
          }
        ]
      },
      "result": true,
      "ffmpeg_stack": "v2.2.3",
      "preset": "ipad-high",
      "resize_strategy": "pad"
    }
  }
}

Related blog posts

Over the years we wrote the following posts about Our /video/merge robot on our blog:

Did you know?

You can easily combine Robots to create powerful workflows, unique to your business.
This is the power of Transloadit.