How to Merge Videos using Python?

There are times when you need to programmatically stitch multiple videos. Perhaps you are developing a Python application where you would like to automatically join several video clips into a single video, such as adding an outro to a video recording. To accomplish this using Python, you will need an editing API to perform the video processing. Here's a simple and straightforward method to merge videos with just a few lines of code:

Input Code
import requests

json = {
 'source': {
  'output_format': 'mp4',
  'width': 1920,
  'height': 1080,
  'elements': [
    'type': 'video',
    'track': 1,
    'source': ''
    'type': 'video',
    'track': 1,
    'source': '',
    'animations': [
      'time': 'start',
      'duration': 1,
      'transition': True,
      'type': 'fade'

response =
  # Find your API key under 'Project Settings' in your account:
  'Authorization': 'Bearer Your-API-Key',
  'Content-Type': 'application/json',

# Wait a minute, then visit the URL provided in the response:

Output Video

How it works: As the API runs entirely in the cloud, there is no need to install any Python dependencies. The only package that is required is the standard "requests" package included with your Python installation.

For the video to play sequentially, we create a video composition with two video elements on the same track (track "1"). There is no need to specify the start and duration of each clip as the track adjusts automatically according to the total footage. Simply provide the URLs of the videos and the API takes care of everything else.

For a seamless transition between clips, use the "animations" property. This property accepts an array of animations to be applied to the element. In this case, we apply a 1-second fade animation to the second video element. By setting the "transition" property to "true", it smoothly overlaps with the first video clip. The fade animation is just one of many effects that can be used to combine multiple videos.

Creatomate's video editing API offers a wide range of video editing capabilities, including the ability to merge videos. With this REST API, based on JSON, you can automate any sort of editing task. As it comes with an online video editor, it provides developers with all the necessary tools to efficiently set up code-driven video editing workflows. See how you can create your own video scenarios ready for use in your Python applications below.

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 Python application to create any kind of video – completely through code.

Related Python Video Editing Questions

Start automating today

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