Stay organized with collections Save and categorize content based on your preferences.
This page explains how to insert overlays into transcoded videos. An overlay consists of an image that is inserted on top of the output video, and can optionally be faded in or out over a specified time period. To insert an overlay, use the overlays
array in the JobConfig
template.
See the list of supported image file formats.
Upload an image to Cloud StorageTo get started, do the following to upload an overlay image to your Cloud Storage bucket:
You can create two types of overlays: static or animated. Both types of overlays use a static image. You can show or hide static overlays. Animated overlays support fade in and fade out animations of the image.
You can insert multiple overlays into a single output video.
Create a static overlayIn the image
object, use the uri
field to specify the overlay image in Cloud Storage. In the resolution
object, set the x and y values from 0 to 1.0. A value of 0 maintains the source image resolution for that dimension; a value of 1.0 will stretch the image to match the dimension of the output video. For example, use the values x: 1
and y: 0.5
to stretch the overlay image the full width and half of the height of the output video.
In the animations
array, create an animationStatic
object with x and y coordinates from 0 to 1.0. These coordinates are based on the output video resolution. Use the values x: 0
and y: 0
to position the top-left corner of the overlay in the top-left corner of the output video. Specify when the overlay should appear in the output video timeline using the startTimeOffset
field.
To remove the static animation, create an animationEnd
object. Specify when the animation should end (that is, the overlay should disappear) in the output video timeline using the startTimeOffset
field.
You can add this configuration to a job template or include it in an ad-hoc job configuration:
RESTBefore using any of the request data, make the following replacements:
PROJECT_ID
: Your Google Cloud project ID listed in the IAM Settings.LOCATION
: The location where your job will run. Use one of the supported regions.
Show locations
us-central1
us-west1
us-west2
us-east1
us-east4
southamerica-east1
northamerica-northeast1
asia-east1
asia-northeast1
asia-northeast3
asia-south1
asia-southeast1
australia-southeast1
europe-west1
europe-west2
europe-west4
me-west1
me-central1
me-central2
STORAGE_BUCKET_NAME
: The name of the Cloud Storage bucket you created.STORAGE_INPUT_VIDEO
: The name of the video in your Cloud Storage bucket that you are transcoding, such as my-vid.mp4
. This field should take into account any folders that you created in the bucket (for example, input/my-vid.mp4
).STORAGE_INPUT_OVERLAY
: The name of the image in your Cloud Storage bucket that you are using for the overlay, such as my-overlay.png
. This field should take into account any folders that you created in the bucket (for example, input/my-overlay.png
).STORAGE_OUTPUT_FOLDER
: The Cloud Storage folder name where you want to save the encoded video outputs. Note: You don't need to create the output folder object before creating the job. When processing the job, the Transcoder API automatically prepends the folder name you specify as part of the names of the objects saved to Cloud Storage.To send your request, expand one of these options:
curl (Linux, macOS, or Cloud Shell) Note: The following command assumes that you have logged in to thegcloud
CLI with your user account by running gcloud init
or gcloud auth login
, or by using Cloud Shell, which automatically logs you into the gcloud
CLI . You can check the currently active account by running gcloud auth list
.
Save the request body in a file named request.json
. Run the following command in the terminal to create or overwrite this file in the current directory:
cat > request.json << 'EOF' { "config": { "inputs": [ { "key": "input0", "uri": "gs://STORAGE_BUCKET_NAME/STORAGE_INPUT_VIDEO" } ], "elementaryStreams": [ { "key": "video-stream0", "videoStream": { "h264": { "heightPixels": 360, "widthPixels": 640, "bitrateBps": 550000, "frameRate": 60 } } }, { "key": "audio-stream0", "audioStream": { "codec": "aac", "bitrateBps": 64000 } } ], "muxStreams": [ { "key": "sd", "container": "mp4", "elementaryStreams": [ "video-stream0", "audio-stream0" ] } ], "output": { "uri": "gs://STORAGE_BUCKET_NAME/STORAGE_OUTPUT_FOLDER/" }, "overlays": [ { "image": { "uri": "gs://STORAGE_BUCKET_NAME/STORAGE_INPUT_OVERLAY", "resolution": { "x": 1, "y": 0.5 }, "alpha": 1 }, "animations": [ { "animationStatic": { "xy": { "x": 0, "y": 0 }, "startTimeOffset": "0s" } }, { "animationEnd": { "startTimeOffset": "10s" } } ] } ] } } EOF
Then execute the following command to send your REST request:
curl -X POST \PowerShell (Windows) Note: The following command assumes that you have logged in to the
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://transcoder.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/jobs"
gcloud
CLI with your user account by running gcloud init
or gcloud auth login
. You can check the currently active account by running gcloud auth list
.
Save the request body in a file named request.json
. Run the following command in the terminal to create or overwrite this file in the current directory:
@' { "config": { "inputs": [ { "key": "input0", "uri": "gs://STORAGE_BUCKET_NAME/STORAGE_INPUT_VIDEO" } ], "elementaryStreams": [ { "key": "video-stream0", "videoStream": { "h264": { "heightPixels": 360, "widthPixels": 640, "bitrateBps": 550000, "frameRate": 60 } } }, { "key": "audio-stream0", "audioStream": { "codec": "aac", "bitrateBps": 64000 } } ], "muxStreams": [ { "key": "sd", "container": "mp4", "elementaryStreams": [ "video-stream0", "audio-stream0" ] } ], "output": { "uri": "gs://STORAGE_BUCKET_NAME/STORAGE_OUTPUT_FOLDER/" }, "overlays": [ { "image": { "uri": "gs://STORAGE_BUCKET_NAME/STORAGE_INPUT_OVERLAY", "resolution": { "x": 1, "y": 0.5 }, "alpha": 1 }, "animations": [ { "animationStatic": { "xy": { "x": 0, "y": 0 }, "startTimeOffset": "0s" } }, { "animationEnd": { "startTimeOffset": "10s" } } ] } ] } } '@ | Out-File -FilePath request.json -Encoding utf8
Then execute the following command to send your REST request:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://transcoder.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/jobs" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION/jobs/JOB_ID", "config": { ... }, "state": "PENDING", "createTime": CREATE_TIME, "ttlAfterCompletionDays": 30 }gcloud
request.json
file that defines the job fields. Make the following replacements for the gcloud
command:
my-vid.mp4
. This field should take into account any folders that you created in the bucket (for example, input/my-vid.mp4
).my-overlay.png
. This field should take into account any folders that you created in the bucket (for example, input/my-overlay.png
).Show locations
us-central1
us-west1
us-west2
us-east1
us-east4
southamerica-east1
northamerica-northeast1
asia-east1
asia-northeast1
asia-northeast3
asia-south1
asia-southeast1
australia-southeast1
europe-west1
europe-west2
europe-west4
me-west1
me-central1
me-central2
{ "config": { "inputs": [ { "key": "input0", "uri": "gs://STORAGE_BUCKET_NAME/STORAGE_INPUT_VIDEO" } ], "elementaryStreams": [ { "key": "video-stream0", "videoStream": { "h264": { "heightPixels": 360, "widthPixels": 640, "bitrateBps": 550000, "frameRate": 60 } } }, { "key": "audio-stream0", "audioStream": { "codec": "aac", "bitrateBps": 64000 } } ], "muxStreams": [ { "key": "sd", "container": "mp4", "elementaryStreams": [ "video-stream0", "audio-stream0" ] } ], "output": { "uri": "gs://STORAGE_BUCKET_NAME/STORAGE_OUTPUT_FOLDER/" }, "overlays": [ { "image": { "uri": "gs://STORAGE_BUCKET_NAME/STORAGE_INPUT_OVERLAY", "resolution": { "x": 1, "y": 0.5 }, "alpha": 1 }, "animations": [ { "animationStatic": { "xy": { "x": 0, "y": 0 }, "startTimeOffset": "0s" } }, { "animationEnd": { "startTimeOffset": "10s" } } ] } ] } }
gcloud transcoder jobs create --location=LOCATION --file="request.json"You should see a response similar to the following:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION/jobs/JOB_ID", "config": { ... }, "state": "PENDING", "createTime": CREATE_TIME, "ttlAfterCompletionDays": 30 }
Before trying this sample, follow the C# setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API C# API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
GoBefore trying this sample, follow the Go setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Go API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
JavaBefore trying this sample, follow the Java setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Java API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Node.jsBefore trying this sample, follow the Node.js setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Node.js API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
PHPBefore trying this sample, follow the PHP setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API PHP API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
PythonBefore trying this sample, follow the Python setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Python API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
RubyBefore trying this sample, follow the Ruby setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Ruby API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
In the output video, the static overlay has the following characteristics:
See the sample output video for this configuration. This video uses a sample overlay image.
Create an animated overlayIn the image
object, use the uri
field to specify the overlay image in Cloud Storage. In the resolution
object, set the x and y values from 0 to 1.0. A value of 0 maintains the source image resolution for that dimension; a value of 1.0 will stretch the image to match the dimension of the output video. For example, use the values x: 0
and y: 0
to maintain the original resolution of the overlay image.
In the animations
array, create an animationFade
object with a fadeType
of FADE_IN
. Set the x and y coordinates from 0 to 1.0. These coordinates are based on the output video resolution. Use the values x: 0.5
and y: 0.5
to position the top-left corner of the overlay in the center of the output video. Specify when the overlay should start to appear in the output video timeline using the startTimeOffset
field. The overlay should be fully visible by the time set in the endTimeOffset
field.
To fade out the overlay, create another animationFade
object. This time, set the fadeType
to FADE_OUT
. Input the position coordinates and start and end times as before.
You can add this configuration to a job template or include it in an ad-hoc job configuration:
RESTBefore using any of the request data, make the following replacements:
PROJECT_ID
: Your Google Cloud project ID listed in the IAM Settings.LOCATION
: The location where your job will run. Use one of the supported regions.
Show locations
us-central1
us-west1
us-west2
us-east1
us-east4
southamerica-east1
northamerica-northeast1
asia-east1
asia-northeast1
asia-northeast3
asia-south1
asia-southeast1
australia-southeast1
europe-west1
europe-west2
europe-west4
me-west1
me-central1
me-central2
STORAGE_BUCKET_NAME
: The name of the Cloud Storage bucket you created.STORAGE_INPUT_VIDEO
: The name of the video in your Cloud Storage bucket that you are transcoding, such as my-vid.mp4
. This field should take into account any folders that you created in the bucket (for example, input/my-vid.mp4
).STORAGE_INPUT_OVERLAY
: The name of the image in your Cloud Storage bucket that you are using for the overlay, such as my-overlay.png
. This field should take into account any folders that you created in the bucket (for example, input/my-overlay.png
).STORAGE_OUTPUT_FOLDER
: The Cloud Storage folder name where you want to save the encoded video outputs. Note: You don't need to create the output folder object before creating the job. When processing the job, the Transcoder API automatically prepends the folder name you specify as part of the names of the objects saved to Cloud Storage.To send your request, expand one of these options:
curl (Linux, macOS, or Cloud Shell) Note: The following command assumes that you have logged in to thegcloud
CLI with your user account by running gcloud init
or gcloud auth login
, or by using Cloud Shell, which automatically logs you into the gcloud
CLI . You can check the currently active account by running gcloud auth list
.
Save the request body in a file named request.json
. Run the following command in the terminal to create or overwrite this file in the current directory:
cat > request.json << 'EOF' { "config": { "inputs": [ { "key": "input0", "uri": "gs://STORAGE_BUCKET_NAME/STORAGE_INPUT_VIDEO" } ], "elementaryStreams": [ { "key": "video-stream0", "videoStream": { "h264": { "heightPixels": 360, "widthPixels": 640, "bitrateBps": 550000, "frameRate": 60 } } }, { "key": "audio-stream0", "audioStream": { "codec": "aac", "bitrateBps": 64000 } } ], "muxStreams": [ { "key": "sd", "container": "mp4", "elementaryStreams": [ "video-stream0", "audio-stream0" ] } ], "output": { "uri": "gs://STORAGE_BUCKET_NAME/STORAGE_OUTPUT_FOLDER/" }, "overlays": [ { "image": { "uri": "gs://STORAGE_BUCKET_NAME/STORAGE_INPUT_OVERLAY", "resolution": { "x": 0, "y": 0 }, "alpha": 1 }, "animations": [ { "animationFade": { "fadeType": "FADE_IN", "xy": { "x": 0.5, "y": 0.5 }, "startTimeOffset": "5s", "endTimeOffset": "10s" } }, { "animationFade": { "fadeType": "FADE_OUT", "xy": { "x": 0.5, "y": 0.5 }, "startTimeOffset": "12s", "endTimeOffset": "15s" } } ] } ] } } EOF
Then execute the following command to send your REST request:
curl -X POST \PowerShell (Windows) Note: The following command assumes that you have logged in to the
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://transcoder.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/jobs"
gcloud
CLI with your user account by running gcloud init
or gcloud auth login
. You can check the currently active account by running gcloud auth list
.
Save the request body in a file named request.json
. Run the following command in the terminal to create or overwrite this file in the current directory:
@' { "config": { "inputs": [ { "key": "input0", "uri": "gs://STORAGE_BUCKET_NAME/STORAGE_INPUT_VIDEO" } ], "elementaryStreams": [ { "key": "video-stream0", "videoStream": { "h264": { "heightPixels": 360, "widthPixels": 640, "bitrateBps": 550000, "frameRate": 60 } } }, { "key": "audio-stream0", "audioStream": { "codec": "aac", "bitrateBps": 64000 } } ], "muxStreams": [ { "key": "sd", "container": "mp4", "elementaryStreams": [ "video-stream0", "audio-stream0" ] } ], "output": { "uri": "gs://STORAGE_BUCKET_NAME/STORAGE_OUTPUT_FOLDER/" }, "overlays": [ { "image": { "uri": "gs://STORAGE_BUCKET_NAME/STORAGE_INPUT_OVERLAY", "resolution": { "x": 0, "y": 0 }, "alpha": 1 }, "animations": [ { "animationFade": { "fadeType": "FADE_IN", "xy": { "x": 0.5, "y": 0.5 }, "startTimeOffset": "5s", "endTimeOffset": "10s" } }, { "animationFade": { "fadeType": "FADE_OUT", "xy": { "x": 0.5, "y": 0.5 }, "startTimeOffset": "12s", "endTimeOffset": "15s" } } ] } ] } } '@ | Out-File -FilePath request.json -Encoding utf8
Then execute the following command to send your REST request:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://transcoder.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/jobs" | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION/jobs/JOB_ID", "config": { ... }, "state": "PENDING", "createTime": CREATE_TIME, "ttlAfterCompletionDays": 30 }gcloud
request.json
file that defines the job fields. Make the following replacements for the gcloud
command:
my-vid.mp4
. This field should take into account any folders that you created in the bucket (for example, input/my-vid.mp4
).my-overlay.png
. This field should take into account any folders that you created in the bucket (for example, input/my-overlay.png
).Show locations
us-central1
us-west1
us-west2
us-east1
us-east4
southamerica-east1
northamerica-northeast1
asia-east1
asia-northeast1
asia-northeast3
asia-south1
asia-southeast1
australia-southeast1
europe-west1
europe-west2
europe-west4
me-west1
me-central1
me-central2
{ "config": { "inputs": [ { "key": "input0", "uri": "gs://STORAGE_BUCKET_NAME/STORAGE_INPUT_VIDEO" } ], "elementaryStreams": [ { "key": "video-stream0", "videoStream": { "h264": { "heightPixels": 360, "widthPixels": 640, "bitrateBps": 550000, "frameRate": 60 } } }, { "key": "audio-stream0", "audioStream": { "codec": "aac", "bitrateBps": 64000 } } ], "muxStreams": [ { "key": "sd", "container": "mp4", "elementaryStreams": [ "video-stream0", "audio-stream0" ] } ], "output": { "uri": "gs://STORAGE_BUCKET_NAME/STORAGE_OUTPUT_FOLDER/" }, "overlays": [ { "image": { "uri": "gs://STORAGE_BUCKET_NAME/STORAGE_INPUT_OVERLAY", "resolution": { "x": 0, "y": 0 }, "alpha": 1 }, "animations": [ { "animationFade": { "fadeType": "FADE_IN", "xy": { "x": 0.5, "y": 0.5 }, "startTimeOffset": "5s", "endTimeOffset": "10s" } }, { "animationFade": { "fadeType": "FADE_OUT", "xy": { "x": 0.5, "y": 0.5 }, "startTimeOffset": "12s", "endTimeOffset": "15s" } } ] } ] } }
gcloud transcoder jobs create --location=LOCATION --file="request.json"You should see a response similar to the following:
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION/jobs/JOB_ID", "config": { ... }, "state": "PENDING", "createTime": CREATE_TIME, "ttlAfterCompletionDays": 30 }
Before trying this sample, follow the C# setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API C# API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
GoBefore trying this sample, follow the Go setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Go API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
JavaBefore trying this sample, follow the Java setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Java API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Node.jsBefore trying this sample, follow the Node.js setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Node.js API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
PHPBefore trying this sample, follow the PHP setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API PHP API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
PythonBefore trying this sample, follow the Python setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Python API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
RubyBefore trying this sample, follow the Ruby setup instructions in the Transcoder API quickstart using client libraries. For more information, see the Transcoder API Ruby API reference documentation.
To authenticate to Transcoder API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
In the resulting video, the animated overlay has the following characteristics:
See the sample output video for this configuration. This video uses a sample overlay image.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4