How to Blur the Background of a Video using an API?

A common way to resize vertical videos into landscape format is by adding a background blur. Using this technique, a blurred copy is placed in the background to fill in the borders of the video. You can create these videos programmatically using a video editing API. Here's how, using a single API request:

API Request
curl -s -X POST \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  --data-binary @- << EOF
  "source": {
    "output_format": "mp4",
    "width": 1920,
    "height": 1080,
    "elements": [
        "type": "video",
        "clip": true,
        "color_overlay": "rgba(0,0,0,0.15)",
        "blur_radius": 57,
        "source": "",
        "volume": "0%"
        "type": "video",
        "source": "",
        "fit": "contain"
Output Video

How it works: This example shows how to use CURL to invoke the REST API. However, you can use any language or tool to make this API request. Because the composition is defined in JSON, we can create any MP4 simply by specifying how the video should be composed programmatically. The API takes care of everything.

Start by deciding on the desired output resolution, like 1080p (1920 x 1080). Next, define two video elements. The first element is the blurred background video. Using the "blur_radius" property, you can customize the amount of blur. And by using the "color_overlay" property, you can darken the background a bit. Make sure to mute the background video element using the "volume" property.

The second element is the foreground video. Set the "fit" property to "contain" to ensure that it fits perfectly within the edges of the final video. It is worth noting that neither element is specified with a duration, that's because the output video length is calculated automatically.

If you prefer a more visual editing experience, be sure to check out the video editor below. It lets you drag and drop video clips into place, so you can easily create your own video templates. You can then export these designs as JSON to use in your automated workflows.

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

Related API Video Editing Questions

Start automating today

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