How-to Create an Image Overlay

Before you start

This guide assumes that you understand the basics of making a Transcode API request. We recommend completing the Getting Started with Transcoding Media guide first.

Overlays

Overlays are often used when editing video to add or "burn in" text/graphics to personalize a video, add a company logo, or a visual watermark. This can be a tedious manual process in non-linear editing software. The Transcode API makes it easy to apply graphics dynamically at the same time as converting a file. It is even possible to have different overlays applied to each individual output file. Optionally, you can specify the timing for an overlay to appear for only a portion of the video and specify a fade-in or fade-out transition. You can also adjust the position and opacity.

Image overlays

The Transcode API supports overlaying static images onto output files. Images, such as logos, can be positioned dynamically, which is useful for placing a logo into a particular position, such as a specific corner. Fullscreen images such as a title graphics or lower third graphic can be placed to precisely cover the output and scale down with your output size. This is useful if you want a lot of precision over exactly how the graphic covers your video. In the case where an image has transparency, such as a lower third graphic, the transparency is respected.

Insert a logo

You have an image such as a company logo that does not match the resolution or aspect ratio of the output video. You want to position it in a corner or in a specific portion of the screen. For more information, see How image overlay positioning and sizing works.

Insert a fullscreen image

You have an image such as a lower third graphic with transparency that matches the resolution and aspect ratio of your input file(s) and want the Transcode API to place the image to cover the output. This allows you to precisely position the graphic by generating an image with the same aspect ratio and resolution as your input file to make a pixel-perfect output. For more information, see How full-screen image overlay works.

Multiple input files

If you are using multiple input files, the overlay and the timing for the overlay apply across any stitched content. For example, you are using three input files, and you want to add an image overlay onto your output file. To see how to make adjustments to your image overlay, see the sections below: How image overlay positioning and sizing works, How start, duration, and transition works, How styling works, How full-screen image overlay works.

The processing block

The processing block is at the root of the "output" type where you can specify which kinds of processing you want to apply to each output. Here's a simple example of a processing block in an MP4 output:

{
    "kind": "mp4",
    "destination": "dlb://output/image_overlay_example.mp4"
    "video": {
        "height": 1080
    },
    "processing": [
        {
            "kind": "image_overlay",
            "image_file": "http://path/to/image.png",
        }
    ]
}

How image overlay positioning and sizing works

You can set the position of your overlay with the x_percent and y_percent parameters, using a percentage that is relative to the output size. Your image size is adjusted using the width_percent and height_percent parameters using a percentage relative to the output width and output height. If you do not specify the height_percent or width_percent of the overlay, your image is burned in at its native resolution and is not resized. It is recommended to provide the height_percent or width_percent and your image is scaled to maintain the aspect ratio based on a single dimension. This prevents the image overlay from getting stretched or squashed. If you specify both height and width, your image is scaled using both dimensions. In addition to controlling the specific image size and position, you can also use the justify parameter to align your image with a specific corner or center of your output.

See the following examples which demonstrate placing the logo file over each corner of the output. Code snippets are below for copy-and-paste , but we have complete code examples at the bottom of this document.

The parameters contained in the image overlay positioning and sizing processing block.

Parameter

Description

x_percent

The X location of the overlay in the output video's width percent value. 0 represents the left edge of the video.

If you do not provide an x_percent value, x_percent is set to 50.

y_percent

The Y location of the overlay in the output video's height percent value. 0 represents the top edge of the video.

If you do not provide an y_percent value, y_percent is set to 50.

width_percent

The width of the overlay in percent value relative to the output video's width.

height_percent

The height of the overlay in percent value relative to the output video's height.

justify

The corner of the overlay justified with top_right, top_left, bottom_left, bottom_right, center_center.

Example default centered logo overlay

This example shows you how to position a logo in the center of the video output.

{
    "kind": "mp4",
    "destination": "dlb://image_overlay_center_center.mp4",
    "video": {
        "height": 1080
    },
    "processing": [
        {
            "kind": "image_overlay",
            "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/logo.png",
            "x_percent": 50,
            "y_percent": 50,
            "justify": "center_center",
            "width_percent": 8
        }
    ]
}

Example top-right logo overlay

This example shows you how to position a logo in the top-right of the video output.

{
    "kind": "mp4",
    "destination": "dlb://image_overlay_top_right.mp4",
    "video": {
        "height": 1080
    },
    "processing": [
        {
            "kind": "image_overlay",
            "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/logo.png",
            "x_percent": 97,
            "y_percent": 5,
            "justify": "top_right",
            "width_percent": 8
        }
    ]
}

Example top-left logo overlay

This example shows you how to position a logo in the top-left of the video output.

{
    "kind": "mp4",
    "destination": "dlb://image_overlay_top_left.mp4",
    "video": {
        "height": 1080
    },
    "processing": [
        {
            "kind": "image_overlay",
            "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/logo.png",
            "x_percent": 3,
            "y_percent": 5,
            "justify": "top_left",
            "width_percent": 8
        }
    ]
}

Example bottom-right logo overlay

This example shows you how to position a logo in the bottom-right of the video output.

{
    "kind": "mp4",
    "destination": "dlb://image_overlay_bottom_right.mp4",
    "video": {
        "height": 1080
    },
    "processing": [
        {
            "kind": "image_overlay",
            "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/logo.png",
            "x_percent": 97,
            "y_percent": 95,
            "justify": "bottom_right",
            "width_percent": 8
        }
    ]
}

Example bottom-left logo overlay

This example shows you how to position a logo in the bottom-left of the video output.

{
    "kind": "mp4",
    "destination": "dlb://image_overlay_bottom_left.mp4",
    "video": {
        "height": 1080
    },
    "processing": [
        {
            "kind": "image_overlay",
            "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/logo.png",
            "x_percent": 3,
            "y_percent": 95,
            "justify": "bottom_left",
            "width_percent": 8
        }
    ]
}

How start, duration, and transition works

You can specify when you want your image overlay to appear in the output, in addition to how long you want the image overlay displayed using the start_sec and duration_sec parameters. If you do not provide the start_sec and duration_sec parameters, the overlay appears throughout the video.

Within the specified duration time, you can fade-in and fade-out your image overlay to provide a smooth transition in your output with the fade_in_duration_sec and fade_out_duration_sec parameters.

Example start, duration, and transition processing block

This example contains all of the parameters used for fading an image on and off the screen. The image.png fades onto the screen starting at 5 seconds and dissolves off-screen between 5 and 6 seconds. At the 29 second mark in the video, the image.png begins to dissolve off-screen and remains off-screen.

{
    "kind": "mp4",
    "destination": "dlb://output/image_overlay_example.mp4"
    "video": {
        "height": 1080
    },
    "processing": [
        {
            "kind": "image_overlay",
            "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/logo.png",
            "start_sec": 5,
            "duration_sec": 25,
            "fade_in_duration_sec": 1,
            "fade_out_duration_sec": 1
        }
    ]
}

The parameters contained in the image overlay start, duration, and transition processing block.

Parameter

Description

start_sec

Determines what start time (seconds) the overlay appears on screen.

If you do not provide start_sec, the overlay appears from the beginning. If you are stitching/concatenating multiple inputs, the start time is relative to the combined inputs.

duration_sec

Duration in seconds of the overlay, inclusive of fade_in_duration_sec and fade_out_duration_sec, if specified.

If you provide either start_sec and either fade_in_duration_sec or fade_out_duration_sec, you must also provide duration_sec. The duration_sec value must be bigger than fade_in_duration_sec + fade_out_duration_sec.

fade_in_duration_sec

Fade-in time (in seconds) of the overlay. Specifies a fade transition for the overlay to appear instead of a "cut" or "pop" on.

fade_out_duration_sec

Fade-out time (in seconds) of the overlay. Specifies a fade transition for the overlay to disappear.

How styling works

You can blend your image overlay with the background video using the opaque_percent parameter. When the percentage is set to below 100%, the video shows through the image overlay. The default value for the opaque parameter is 100% (fully opaque).

Example styling processing block

This example contains the opaque_percent parameter that is used to adjust the image overlay transparency.

{
    "kind": "mp4",
    "destination": "dlb://output/image_overlay_example.mp4"
    "video": {
        "height": 1080
    },
    "processing": [
        {
            "kind": "image_overlay",
            "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/logo.png",
            "opaque_percent": 50                   
        }
    ]
}

Parameter

Description

opaque_percent

The opacity percent value of the overlay. 0 is fully transparent (invisible) and 100 is fully opaque (not transparent).

If you do not provide an opacity percent value, opacity_percent is set to 100 (not transparent).

How full-screen image overlay works

You can use a custom full-screen image overlay that contains a set of graphic elements, such as a logo and a banner, that are arranged precisely like you want. Next, you can adjust your full-screen image overlay to cover the entire video and scale to different size outputs. To do this, position the image at the top left corner (0,0), set the justification to top_left, and set the height_percent or width_percent to 100.

{
    "kind": "mp4",
    "destination": "dlb://output/fullscreen_image_overlay_example.mp4"
    "video": {
        "height": 1080
    },
    "processing": [
        {
            "kind": "image_overlay",
            "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/logo.png",
            "x_percent": 0,
            "y_percent": 0,
            "justify": "top_left",
            "width_percent": 100
        }
    ]
}

Complete examples that show image overlay positions

The following examples contain processing blocks that cover the following image overlay positions:

  • Center
  • Top right
  • Top left
  • Bottom left
  • Bottom right
  • Full screen
  • Fade in/out

Try it out

If you're ready to try it out, see our complete code examples below. If you need some video assets to try with, here are some public links for the assets used in this guide:

Complete example using Dolby.io Media temporary cloud storage

If you want to try out the image overlay features quickly, these three examples have some public files for you to begin with. All outputs write to our Dolby Temporary Storage. These samples will work without modification:

import os

# The requests library must be installed before running this example.
import requests

# Call the Transcode API endpoint.
url = "https://api.dolby.com/media/transcode"

# Set your API Token in your request header.
headers = {
    "Authorization": "Bearer {0}".format(api_token),
    "Content-Type": "application/json",
    "Accept": "application/json"
}

# Before you run this example, update the paths and filenames to point to your media.
body = {
    "inputs": [
        {
            "id": "my-input-file",
            "source": "https://dolbyio-public.s3.amazonaws.com/overlay/bbb_short.mp4"
        }
    ],
    "outputs": [
        {
            "id": "mp4-out-cc",
            "kind": "mp4",
            "destination": "dlb://image_overlay_center_center.mp4",
            "video": {
                "height": 1080
            },
            "processing": [
                {
                    "kind": "image_overlay",
                    "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/logo.png",
                    "x_percent": 50,
                    "y_percent": 50,
                    "justify": "center_center",
                    "width_percent": 8
                }
            ]
        },
        {
            "id": "mp4-out-tr",
            "kind": "mp4",
            "destination": "dlb://image_overlay_top_right.mp4",
            "video": {
                "height": 1080
            },
            "processing": [
                {
                    "kind": "image_overlay",
                    "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/logo.png",
                    "x_percent": 97,
                    "y_percent": 5,
                    "justify": "top_right",
                    "width_percent": 8
                }
            ]
        },
        {
            "id": "mp4-out-tl",
            "kind": "mp4",
            "destination": "dlb://image_overlay_top_left.mp4",
            "video": {
                "height": 1080
            },
            "processing": [
                {
                    "kind": "image_overlay",
                    "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/logo.png",
                    "x_percent": 3,
                    "y_percent": 5,
                    "justify": "top_left",
                    "width_percent": 8
                }
            ]
        },
        {
            "id": "mp4-out-bl",
            "kind": "mp4",
            "destination": "dlb://image_overlay_bottom_left.mp4",
            "video": {
                "height": 1080
            },
            "processing": [
                {
                    "kind": "image_overlay",
                    "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/logo.png",
                    "x_percent": 3,
                    "y_percent": 95,
                    "justify": "bottom_left",
                    "width_percent": 8
                }
            ]
        },
        {
            "id": "mp4-out-br",
            "kind": "mp4",
            "destination": "dlb://image_overlay_bottom_right.mp4",
            "video": {
                "height": 1080
            },
            "processing": [
                {
                    "kind": "image_overlay",
                    "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/logo.png",
                    "x_percent": 97,
                    "y_percent": 95,
                    "justify": "bottom_right",
                    "width_percent": 8
                }
            ]
        },
        {
            "id": "mp4-out-fs",
            "kind": "mp4",
            "destination": "dlb://image_overlay_fullscreen_output.mp4",
            "video": {
                "height": 1080
            },
            "processing": [
                {
                    "kind": "image_overlay",
                    "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/lower_third.png",
                    "x_percent": 0,
                    "y_percent": 0,
                    "justify": "top_left",
                    "width_percent": 100
                }
            ]
        },
        {
            "id": "mp4-out-fade",
            "kind": "mp4",
            "destination": "dlb://image_overlay_fade_in-out.mp4",
            "video": {
                "height": 1080
            },
            "processing": [
                {
                    "kind": "image_overlay",
                    "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/lower_third.png",
                    "x_percent": 0,
                    "y_percent": 0,
                    "justify": "top_left",
                    "width_percent": 100,
                    "start_sec": 8,
                    "duration_sec": 26,
                    "fade_in_duration_sec": 1
                }
            ]
        }
    ]
}

try:
    # Submit the request to the API.
    response = requests.post(url, json=body, headers=headers)

    # Raise an error if an HTTPError occurred.
    response.raise_for_status()

# Exception handling.
except requests.exceptions.HTTPError as e:
    raise Exception(response.text)

# Request was successful.
print(response.json()["job_id"])
// The Axios library must be installed before running this example.
const axios = require("axios").default

// Set your API Token in your request header. 
// Before you run this example, update the paths and filenames to point to your media.
const config = {
    "method": "post",
    "url": "https://api.dolby.com/media/transcode",
    "headers": {
        "Authorization": `Bearer ${api_token}`,
        "Content-Type": "application/json",
        "Accept": "application/json"
    },
    "data": {
        "inputs": [
            {
                "id": "my-input-file",
                "source": "https://dolbyio-public.s3.amazonaws.com/overlay/bbb_short.mp4"
            }
        ],
        "outputs": [
            {
                "id": "mp4-out-cc",
                "kind": "mp4",
                "destination": "dlb://image_overlay_center_center.mp4",
                "video": {
                    "height": 1080
                },
                "processing": [
                    {
                        "kind": "image_overlay",
                        "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/logo.png",
                        "x_percent": 50,
                        "y_percent": 50,
                        "justify": "center_center",
                        "width_percent": 8
                    }
                ]
            },
            {
                "id": "mp4-out-tr",
                "kind": "mp4",
                "destination": "dlb://image_overlay_top_right.mp4",
                "video": {
                    "height": 1080
                },
                "processing": [
                    {
                        "kind": "image_overlay",
                        "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/logo.png",
                        "x_percent": 97,
                        "y_percent": 5,
                        "justify": "top_right",
                        "width_percent": 8
                    }
                ]
            },
            {
                "id": "mp4-out-tl",
                "kind": "mp4",
                "destination": "dlb://image_overlay_top_left.mp4",
                "video": {
                    "height": 1080
                },
                "processing": [
                    {
                        "kind": "image_overlay",
                        "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/logo.png",
                        "x_percent": 3,
                        "y_percent": 5,
                        "justify": "top_left",
                        "width_percent": 8
                    }
                ]
            },
            {
                "id": "mp4-out-bl",
                "kind": "mp4",
                "destination": "dlb://image_overlay_bottom_left.mp4",
                "video": {
                    "height": 1080
                },
                "processing": [
                    {
                        "kind": "image_overlay",
                        "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/logo.png",
                        "x_percent": 3,
                        "y_percent": 95,
                        "justify": "bottom_left",
                        "width_percent": 8
                    }
                ]
            },
            {
                "id": "mp4-out-br",
                "kind": "mp4",
                "destination": "dlb://image_overlay_bottom_right.mp4",
                "video": {
                    "height": 1080
                },
                "processing": [
                    {
                        "kind": "image_overlay",
                        "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/logo.png",
                        "x_percent": 97,
                        "y_percent": 95,
                        "justify": "bottom_right",
                        "width_percent": 8
                    }
                ]
            },
            {
                "id": "mp4-out-fs",
                "kind": "mp4",
                "destination": "dlb://image_overlay_fullscreen_output.mp4",
                "video": {
                    "height": 1080
                },
                "processing": [
                    {
                        "kind": "image_overlay",
                        "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/lower_third.png",
                        "x_percent": 0,
                        "y_percent": 0,
                        "justify": "top_left",
                        "width_percent": 100
                    }
                ]
            },
            {
                "id": "mp4-out-fade",
                "kind": "mp4",
                "destination": "dlb://image_overlay_fade_in-out.mp4",
                "video": {
                    "height": 1080
                },
                "processing": [
                    {
                        "kind": "image_overlay",
                        "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/lower_third.png",
                        "x_percent": 0,
                        "y_percent": 0,
                        "justify": "top_left",
                        "width_percent": 100,
                        "start_sec": 8,
                        "duration_sec": 26,
                        "fade_in_duration_sec": 1
                    }
                ]
            }
        ]
    }
}

// Submit the request.
axios(config)
    .then(function(response) {
        // Log the successful "job_id" returned from the API.
        console.log(response.data.job_id)
    })
    .catch(function(error) {
        // If there was an error, log the error.
        console.log(error)
    })
#!/bin/bash

# Set your API Token in your request header.
# Before you run this example, update the paths and filenames to point to your media.
curl -X POST "https://api.dolby.com/media/transcode" \
    --header "Authorization: Bearer $API_TOKEN" \
    --data '{
        "inputs": [
            {
                "id": "my-input-file",
                "source": "https://dolbyio-public.s3.amazonaws.com/overlay/bbb_short.mp4"
            }
        ],
        "outputs": [
            {
                "id": "mp4-out-cc",
                "kind": "mp4",
                "destination": "dlb://image_overlay_center_center.mp4",
                "video": {
                    "height": 1080
                },
                "processing": [
                    {
                        "kind": "image_overlay",
                        "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/logo.png",
                        "x_percent": 50,
                        "y_percent": 50,
                        "justify": "center_center",
                        "width_percent": 8
                    }
                ]
            },
            {
                "id": "mp4-out-tr",
                "kind": "mp4",
                "destination": "dlb://image_overlay_top_right.mp4",
                "video": {
                    "height": 1080
                },
                "processing": [
                    {
                        "kind": "image_overlay",
                        "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/logo.png",
                        "x_percent": 97,
                        "y_percent": 5,
                        "justify": "top_right",
                        "width_percent": 8
                    }
                ]
            },
            {
                "id": "mp4-out-tl",
                "kind": "mp4",
                "destination": "dlb://image_overlay_top_left.mp4",
                "video": {
                    "height": 1080
                },
                "processing": [
                    {
                        "kind": "image_overlay",
                        "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/logo.png",
                        "x_percent": 3,
                        "y_percent": 5,
                        "justify": "top_left",
                        "width_percent": 8
                    }
                ]
            },
            {
                "id": "mp4-out-bl",
                "kind": "mp4",
                "destination": "dlb://image_overlay_bottom_left.mp4",
                "video": {
                    "height": 1080
                },
                "processing": [
                    {
                        "kind": "image_overlay",
                        "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/logo.png",
                        "x_percent": 3,
                        "y_percent": 95,
                        "justify": "bottom_left",
                        "width_percent": 8
                    }
                ]
            },
            {
                "id": "mp4-out-br",
                "kind": "mp4",
                "destination": "dlb://image_overlay_bottom_right.mp4",
                "video": {
                    "height": 1080
                },
                "processing": [
                    {
                        "kind": "image_overlay",
                        "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/logo.png",
                        "x_percent": 97,
                        "y_percent": 95,
                        "justify": "bottom_right",
                        "width_percent": 8
                    }
                ]
            },
            {
                "id": "mp4-out-fs",
                "kind": "mp4",
                "destination": "dlb://image_overlay_fullscreen_output.mp4",
                "video": {
                    "height": 1080
                },
                "processing": [
                    {
                        "kind": "image_overlay",
                        "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/lower_third.png",
                        "x_percent": 0,
                        "y_percent": 0,
                        "justify": "top_left",
                        "width_percent": 100
                    }
                ]
            },
            {
                "id": "mp4-out-fade",
                "kind": "mp4",
                "destination": "dlb://image_overlay_fade_in-out.mp4",
                "video": {
                    "height": 1080
                },
                "processing": [
                    {
                        "kind": "image_overlay",
                        "image_file": "https://dolbyio-public.s3.amazonaws.com/overlay/lower_third.png",
                        "x_percent": 0,
                        "y_percent": 0,
                        "justify": "top_left",
                        "width_percent": 100,
                        "start_sec": 8,
                        "duration_sec": 26,
                        "fade_in_duration_sec": 1
                    }
                ]
            }
        ]
    }'

Complete example using cloud storage

These examples show how to use an image overlay when you are already using your own cloud storage. These examples require you to modify your storage locations, paths, and credentials before they will work.

import os

# The requests library must be installed before running this example.
import requests

# Call the Transcode API endpoint.
url = "https://api.dolby.com/media/transcode"

# Set your API Token in your request header. This example uses an environment variable, but you can also use a hard-coded variable.
headers = {
    "Authorization": "Bearer {0}".format(api_token),
    "Content-Type": "application/json",
    "Accept": "application/json"
}

# Before you run this example, update the paths and filenames to point to your media.
body = {
    "inputs": [
        {
            "id": "my-input-file",
            "source": {
                "ref": "s3_input",
                "filename": "input_media.mp4"
            }
        }
    ],
    "outputs": [
        {
            "id": "mp4-out-cc",
            "kind": "mp4",
            "destination": {
                "ref": "s3_output",
                "filename": "image_overlay_center_center.mp4"
            },
            "video": {
                "height": 1080
            },
            "processing": [
                {
                    "kind": "image_overlay",
                    "image_file": {
                        "ref": "s3_input",
                        "filename": "logo.png"
                    },
                    "x_percent": 50,
                    "y_percent": 50,
                    "justify": "center_center",
                    "width_percent": 8
                }
            ]
        },
        {
            "id": "mp4-out-tr",
            "kind": "mp4",
            "destination": {
                "ref": "s3_output",
                "filename": "image_overlay_top_right.mp4"
            },
            "video": {
                "height": 1080
            },
            "processing": [
                {
                    "kind": "image_overlay",
                    "image_file": {
                        "ref": "s3_input",
                        "filename": "logo.png"
                    },
                    "x_percent": 97,
                    "y_percent": 5,
                    "justify": "top_right",
                    "width_percent": 8
                }
            ]
        },
        {
            "id": "mp4-out-tl",
            "kind": "mp4",
            "destination": {
                "ref": "s3_output",
                "filename": "image_overlay_top_left.mp4"
            },
            "video": {
                "height": 1080
            },
            "processing": [
                { 
                    "kind": "image_overlay",
                    "image_file": {
                        "ref": "s3_input",
                        "filename": "logo.png"
                    },
                    "x_percent": 3,
                    "y_percent": 5,
                    "justify": "top_left",
                    "width_percent": 8
                }
            ]
        },
        {
            "id": "mp4-out-bl",
            "kind": "mp4",
            "destination": {
                "ref": "s3_output",
                "filename": "image_overlay_bottom_left.mp4"
            },
            "video": {
                "height": 1080
            },
            "processing": [
                {
                    "kind": "image_overlay",
                    "image_file": {
                        "ref": "s3_input",
                        "filename": "logo.png"
                    },
                    "x_percent": 3,
                    "y_percent": 95,
                    "justify": "bottom_left",
                    "width_percent": 8
                }
            ]
        },
        {
            "id": "mp4-out-br",
            "kind": "mp4",
            "destination": {
                "ref": "s3_output",
                "filename": "image_overlay_bottom_right.mp4"
            },
            "video": {
                "height": 1080
            },
            "processing": [
                {
                    "kind": "image_overlay",
                    "image_file": {
                        "ref": "s3_input",
                        "filename": "logo.png"
                    },
                    "x_percent": 97,
                    "y_percent": 95,
                    "justify": "bottom_right",
                    "width_percent": 8
                }
            ]
        },
        {
            "id": "mp4-out-fs",
            "kind": "mp4",
            "destination": {
                "ref": "s3_output",
                "filename": "image_overlay_fullscreen_output.mp4"
            },
            "video": {
                "height": 1080
            },
            "processing": [
                {
                    "kind": "image_overlay",
                    "image_file": {
                        "ref": "s3_input",
                        "filename": "lower_third.png"
                    },
                    "x_percent": 0,
                    "y_percent": 0,
                    "justify": "top_left",
                    "width_percent": 100
                }
            ]
        },
        {
            "id": "mp4-out-fade",
            "kind": "mp4",
            "destination": {
                "ref": "s3_output",
                "filename": "image_overlay_fade_in-out.mp4"
            },
            "video": {
                "height": 1080
            },
            "processing": [
                {
                    "kind": "image_overlay",
                    "image_file": {
                        "ref": "s3_input",
                        "filename": "lower_third.png"
                    },
                    "x_percent": 0,
                    "y_percent": 0,
                    "justify": "top_left",
                    "width_percent": 100,
                    "start_sec": 8,
                    "duration_sec": 26,
                    "fade_in_duration_sec": 1
                }
            ]
        }
    ],
    "storage": [
        {
            "id": "s3_input",
            "bucket": {
                "url": "s3://my-storage-bucket/input/",
                "auth": {
                    "key": "AKIASZXXXXXXXXYLWWUHQ",
                    "secret": "kjYK54XXXXXXXXXZtKFySioE+3"
                }
            }
        },
        {
            "id": "s3_output",
            "bucket": {
                "url": "s3://my-s3-storage-bucket/output/",
                "auth": {
                    "key": "AKIASZXXXXXXXXYLWWUHQ",
                    "secret": "kjYK54XXXXXXXXXZtKFySioE+3"
                }
            }
        }
    ]
}


try:
    # Submit the request to the API.
    response = requests.post(url, json=body, headers=headers)

    # Raise an error if an HTTPError occurred.
    response.raise_for_status()

# Exception handling.
except requests.exceptions.HTTPError as e:
    raise Exception(response.text)

# Request was successful.
print(response.json()["job_id"])
// The Axios library must be installed before running this example.
const axios = require("axios").default

// Set your API Token in your request header.
// Before you run this example, update the paths and filenames to point to your media.
const config = {
    "method": "post",
    "url": "https://api.dolby.com/media/transcode",
    "headers": {
         "Authorization": `Bearer ${api_token}`,
         "Content-Type": "application/json",
         "Accept": "application/json"
    },
    "data": {
        "inputs": [
            {
                "id": "my-input-file",
                "source": {
                    "ref": "s3_input",
                    "filename": "input_media.mp4"
                }
            }
        ],
        "outputs": [
            {
                "id": "mp4-out-cc",
                "kind": "mp4",
                "destination": {
                    "ref": "s3_output",
                    "filename": "image_overlay_center_center.mp4"
                },
                "video": {
                    "height": 1080
                },
                "processing": [
                    {
                        "kind": "image_overlay",
                        "image_file": {
                            "ref": "s3_input",
                            "filename": "logo.png"
                        },
                        "x_percent": 50,
                        "y_percent": 50,
                        "justify": "center_center",
                        "width_percent": 8
                    }
                ]
            },
            {
                "id": "mp4-out-tr",
                "kind": "mp4",
                "destination": {
                    "ref": "s3_output",
                    "filename": "image_overlay_top_right.mp4"
                },
                "video": {
                    "height": 1080
                },
                "processing": [
                    {
                        "kind": "image_overlay",
                        "image_file": {
                            "ref": "s3_input",
                            "filename": "logo.png"
                        },
                        "x_percent": 97,
                        "y_percent": 5,
                        "justify": "top_right",
                        "width_percent": 8
                    }
                ]
            },
            {
                "id": "mp4-out-tl",
                "kind": "mp4",
                "destination": {
                    "ref": "s3_output",
                    "filename": "image_overlay_top_left.mp4"
                },
                "video": {
                    "height": 1080
                },
                "processing": [
                    { 
                        "kind": "image_overlay",
                        "image_file": {
                            "ref": "s3_input",
                            "filename": "logo.png"
                        },
                        "x_percent": 3,
                        "y_percent": 5,
                        "justify": "top_left",
                        "width_percent": 8
                    }
                ]
            },
            {
                "id": "mp4-out-bl",
                "kind": "mp4",
                "destination": {
                    "ref": "s3_output",
                    "filename": "image_overlay_bottom_left.mp4"
                },
                "video": {
                    "height": 1080
                },
                "processing": [
                    {
                        "kind": "image_overlay",
                        "image_file": {
                            "ref": "s3_input",
                            "filename": "logo.png"
                        },
                        "x_percent": 3,
                        "y_percent": 95,
                        "justify": "bottom_left",
                        "width_percent": 8
                    }
                ]
            },
            {
                "id": "mp4-out-br",
                "kind": "mp4",
                "destination": {
                    "ref": "s3_output",
                    "filename": "image_overlay_bottom_right.mp4"
                },
                "video": {
                    "height": 1080
                },
                "processing": [
                    {
                        "kind": "image_overlay",
                        "image_file": {
                            "ref": "s3_input",
                            "filename": "logo.png"
                        },
                        "x_percent": 97,
                        "y_percent": 95,
                        "justify": "bottom_right",
                        "width_percent": 8
                    }
                ]
            },
            {
                "id": "mp4-out-fs",
                "kind": "mp4",
                "destination": {
                    "ref": "s3_output",
                    "filename": "image_overlay_fullscreen_output.mp4"
                },
                "video": {
                    "height": 1080
                },
                "processing": [
                    {
                        "kind": "image_overlay",
                        "image_file": {
                            "ref": "s3_input",
                            "filename": "lower_third.png"
                        },
                        "x_percent": 0,
                        "y_percent": 0,
                        "justify": "top_left",
                        "width_percent": 100
                    }
                ]
            },
            {
                "id": "mp4-out-fade",
                "kind": "mp4",
                "destination": {
                    "ref": "s3_output",
                    "filename": "image_overlay_fade_in-out.mp4"
                },
                "video": {
                    "height": 1080
                },
                "processing": [
                    {
                        "kind": "image_overlay",
                        "image_file": {
                            "ref": "s3_input",
                            "filename": "lower_third.png"
                        },
                        "x_percent": 0,
                        "y_percent": 0,
                        "justify": "top_left",
                        "width_percent": 100,
                        "start_sec": 8,
                        "duration_sec": 26,
                        "fade_in_duration_sec": 1
                    }
                ]
            }
        ],
        "storage": [
            {
                "id": "s3_input",
                "bucket": {
                    "url": "s3://my-storage-bucket/input/",
                    "auth": {
                        "key": "AKIASZXXXXXXXXYLWWUHQ",
                        "secret": "kjYK54XXXXXXXXXZtKFySioE+3"
                    }
                }
            },
            {
                "id": "s3_output",
                "bucket": {
                    "url": "s3://my-s3-storage-bucket/output/",
                    "auth": {
                        "key": "AKIASZXXXXXXXXYLWWUHQ",
                        "secret": "kjYK54XXXXXXXXXZtKFySioE+3"
                    }
                }
            }
        ]
    }
}

// Submit the request.
axios(config)
    .then(function(response) {
        // Log the successful "job_id" returned from the API.
        console.log(response.data.job_id)
    })
    .catch(function(error) {
        // If there was an error, log the error.
        console.log(error)
    })
#!/bin/bash

# Set your API Token in your request header.
# Before you run this example, update the paths and filenames to point to your media.
curl -X POST "https://api.dolby.com/media/transcode" \
    --header "Authorization: Bearer $API_TOKEN" \
    --data '{
        "inputs": [
            {
                "id": "my-input-file",
                "source": {
                    "ref": "s3_input",
                    "filename": "input_media.mp4"
                }
            }
        ],
        "outputs": [
            {
                "id": "mp4-out-cc",
                "kind": "mp4",
                "destination": {
                    "ref": "s3_output",
                    "filename": "image_overlay_center_center.mp4"
                },
                "video": {
                    "height": 1080
                },
                "processing": [
                    {
                        "kind": "image_overlay",
                        "image_file": {
                            "ref": "s3_input",
                            "filename": "logo.png"
                        },
                        "x_percent": 50,
                        "y_percent": 50,
                        "justify": "center_center",
                        "width_percent": 8
                    }
                ]
            },
            {
                "id": "mp4-out-tr",
                "kind": "mp4",
                "destination": {
                    "ref": "s3_output",
                    "filename": "image_overlay_top_right.mp4"
                },
                "video": {
                    "height": 1080
                },
                "processing": [
                    {
                        "kind": "image_overlay",
                        "image_file": {
                            "ref": "s3_input",
                            "filename": "logo.png"
                        },
                        "x_percent": 97,
                        "y_percent": 5,
                        "justify": "top_right",
                        "width_percent": 8
                    }
                ]
            },
            {
                "id": "mp4-out-tl",
                "kind": "mp4",
                "destination": {
                    "ref": "s3_output",
                    "filename": "image_overlay_top_left.mp4"
                },
                "video": {
                    "height": 1080
                },
                "processing": [
                    { 
                        "kind": "image_overlay",
                        "image_file": {
                            "ref": "s3_input",
                            "filename": "logo.png"
                        },
                        "x_percent": 3,
                        "y_percent": 5,
                        "justify": "top_left",
                        "width_percent": 8
                    }
                ]
            },
            {
                "id": "mp4-out-bl",
                "kind": "mp4",
                "destination": {
                    "ref": "s3_output",
                    "filename": "image_overlay_bottom_left.mp4"
                },
                "video": {
                    "height": 1080
                },
                "processing": [
                    {
                        "kind": "image_overlay",
                        "image_file": {
                            "ref": "s3_input",
                            "filename": "logo.png"
                        },
                        "x_percent": 3,
                        "y_percent": 95,
                        "justify": "bottom_left",
                        "width_percent": 8
                    }
                ]
            },
            {
                "id": "mp4-out-br",
                "kind": "mp4",
                "destination": {
                    "ref": "s3_output",
                    "filename": "image_overlay_bottom_right.mp4"
                },
                "video": {
                    "height": 1080
                },
                "processing": [
                    {
                        "kind": "image_overlay",
                        "image_file": {
                            "ref": "s3_input",
                            "filename": "logo.png"
                        },
                        "x_percent": 97,
                        "y_percent": 95,
                        "justify": "bottom_right",
                        "width_percent": 8
                    }
                ]
            },
            {
                "id": "mp4-out-fs",
                "kind": "mp4",
                "destination": {
                    "ref": "s3_output",
                    "filename": "image_overlay_fullscreen_output.mp4"
                },
                "video": {
                    "height": 1080
                },
                "processing": [
                    {
                        "kind": "image_overlay",
                        "image_file": {
                            "ref": "s3_input",
                            "filename": "lower_third.png"
                        },
                        "x_percent": 0,
                        "y_percent": 0,
                        "justify": "top_left",
                        "width_percent": 100
                    }
                ]
            },
            {
                "id": "mp4-out-fade",
                "kind": "mp4",
                "destination": {
                    "ref": "s3_output",
                    "filename": "image_overlay_fade_in-out.mp4"
                },
                "video": {
                    "height": 1080
                },
                "processing": [
                    {
                        "kind": "image_overlay",
                        "image_file": {
                            "ref": "s3_input",
                            "filename": "lower_third.png"
                        },
                        "x_percent": 0,
                        "y_percent": 0,
                        "justify": "top_left",
                        "width_percent": 100,
                        "start_sec": 8,
                        "duration_sec": 26,
                        "fade_in_duration_sec": 1
                    }
                ]
            }
        ],
        "storage": [
            {
                "id": "s3_input",
                "bucket": {
                    "url": "s3://my-storage-bucket/input/",
                    "auth": {
                        "key": "AKIASZXXXXXXXXYLWWUHQ",
                        "secret": "kjYK54XXXXXXXXXZtKFySioE+3"
                    }
                }
            },
            {
                "id": "s3_output",
                "bucket": {
                    "url": "s3://my-s3-storage-bucket/output/",
                    "auth": {
                        "key": "AKIASZXXXXXXXXYLWWUHQ",
                        "secret": "kjYK54XXXXXXXXXZtKFySioE+3"
                    }
                }
            }
        ]
    }'

Did this page help you?