Skip to content

RESOURCES / BLOG

How to Trigger Video Optimizations Automatically During Upload

Why It Matters

Manual video optimization is inefficient, leading to slower load times, inconsistent video quality, and higher operational costs. Automate the process using Cloudinary’s upload presets and MediaFlows:

  • Free up creative and development teams from tedious, repetitive tasks.
  • Ensure every video is delivered in the optimal format and quality for every device, leading to faster load times and better user experience.
  • Maintain video quality and branding across all platforms.
  • Streamline workflows by automatically applying transformations and enriching assets with metadata and AI-generated tags.

If you’re still manually converting MOV to MP4, compressing videos with desktop tools, or hardcoding delivery formats, you’re introducing avoidable delays and bloated files into your digital media pipeline.

For teams running media-rich websites or e-commerce storefronts, this adds up quickly to slower load times, uneven quality across devices, and more manual work to get videos production-ready.

This guide walks you through the process of automating video optimization at the point of upload using Cloudinary. You’ll define upload presets, set transformation rules, and trigger post-upload workflows so that every video is automatically compressed, resized, reformatted, and enriched with metadata or AI-generated tags.

Cloudinary’s upload presets allow you to define the transformation rules that are automatically applied every time a video is uploaded via the API/SDK or through the Media Library.

To create an upload preset, follow these steps:

  1. Log in to your Cloudinary account, go to the Console Settings Upload Presets page, and click the Add Upload Preset button.
Cloudinary Upload Presets Page. There's a red box drawn around the "Add Upload Preset" button at the top-right corner.
Cloudinary Upload Presets page
  1. Under the General section:
    1. Give a name to the upload preset.
    2. Select a preferred signing mode based on your use cases.
    3. Suggest a folder, optionally, where the transformed video will be stored.
The Cloudinary Upload Presets page. There's a red box drawn around the General tab on the left nav panel.
Cloudinary Upload Presets page
  1. Under the Transform section, you’ll define the video transformations that are applied automatically when a video is uploaded. There are two main ways to do this:
    1. Use Incoming transformations to apply the transformation when the file is uploaded. These are ideal for applying consistent quality and format rules across all uploaded assets, and the result becomes the “original” asset stored in Cloudinary.
    2. Use Eager transformations to apply the transformation after the upload completes, generating alternate video versions in the background or immediately if applied synchronously. You can ask Cloudinary to apply transformations asynchronously, but you will need to provide a webhook URL so that Cloudinary can notify you once the transformation is complete.
The Cloudinary Upload Presets page. There's a red box drawn around Transform on the left nav panel. The popular eager transformations includes: f_auto/q_auto and sp_auto/e_volume:auto. Apply eager transformations asynchronously is toggled on.
Cloudinary Upload Presets page

As shown in the image above, the transformation parameters are applied asynchronously, and a webhook notification URL is set to receive the transformation result response. Here’s a breakdown of the transformation:

  • q_auto. Automatically adjusts quality for best visual performance and file size
  • f_auto. Delivers WebM, MP4, or other formats based on browser/device support
  • w_1080,c_limit. Scales video down to 1080px max width while keeping aspect ratio
  • vc_auto. Uses an efficient video codec, e.g., h264, vp9, or h265.
  1. To generate captions and chapters for the video, toggle the Auto transcription and Auto chaptering buttons under the Manage and Analyze section.
The Cloudinary Upload Presets page. There's a red box drawn around Manage and Analyze tab on the left nav panel. Auto chaptering and Auto transcription are both toggled on.
Cloudinary Upload Presets page
  1. After modifying your preset settings to fit your needs, click the Save button in the top right corner of the screen to save the upload preset. Your newly created preset will appear on the Upload Presets page.
The Cloudinary Upload Presets page. The new preset is at the top of the list.
Cloudinary Upload Presets page
  1. To set the default preset for your uploads for any asset, click the Manage Defaults button. Select theUpload Preset you wish to apply by default. For example, select an Unsigned Upload Preset to automatically apply transformations to manual uploads via the Media Library, which applies to all asset types, including images, videos, and raw files. This will ensure the transformations are consistent without requiring any additional code.
Default Upload Presets
Cloudinary Upload Presets page

Now that your upload preset is ready, let’s explore the various ways to upload your video assets to Cloudinary.

Uploading your video to Cloudinary makes applying Cloudinary’s transformations easy and delivers an optimized version directly to your website. There are two simple ways to upload your video.

You use the Media Library when you want to upload manually. To do this:

  1. Log in to your Cloudinary console.
  2. Go to the Media Library tab.
  3. Click Upload, select your video file, and wait for the upload to complete.
Cloudinary Media Library
Cloudinary Media Library page

If you want to upload from your app or project, Cloudinary’s SDK makes it easy. First, install your platform’s SDK and then upload your video directly to Cloudinary.

For example, here’s how to do it in Node.js:

  1. Install the SDK:

npm install cloudinary

  1. Configure Cloudinary:
// cloudinary-config.js

const cloudinary = require('cloudinary').v2;

cloudinary.config({

  cloud_name: 'your-cloud-name',

  api_key: 'your-api-key',

  api_secret: 'your-api-secret'

});

module.exports = cloudinary;Code language: JavaScript (javascript)

You can get your Cloudinary API key and API secret from the settings page in your console.

  1. Upload the video:
// upload-video.js

const cloudinary = require('./cloudinary-config');

cloudinary.uploader.upload('path/to/video.mp4', {

  resource_type: 'video'

})

.then(result => {

  console.log('Upload successful!');

  console.log('Video URL:', result.secure_url);

})

.catch(error => {

  console.error('Upload failed:', error);

});Code language: JavaScript (javascript)

After the upload is complete and the preset transformations are applied, Cloudinary will send an upload response to the webhook URL you configured. This response contains metadata about the uploaded video, including its public ID, secure delivery URL, width, height, duration, format, and other relevant details, which you can use to trigger additional processing or notify other services in your pipeline.

This is what the webhook response looks like:

// upload-video.js

const cloudinary = require('./cloudinary-config');

cloudinary.uploader.upload('path/to/video.mp4', {

  resource_type: 'video'

})

.then(result => {

  console.log('Upload successful!');

  console.log('Video URL:', result.secure_url);

})

.catch(error => {

  console.error('Upload failed:', error);

});Code language: JavaScript (javascript)

To see the video, transcription, and chapter files, navigate to the Media Library in your Cloudinary console and click on the Assets tab. The respective files will be there.

Cloudinary Media Library. Three assets are highlighted.
Cloudinary Media Library

In the next section, you’ll use the webhook response to trigger additional post-upload processing on your video asset, such as Google AI tagging, using MediaFlows.

Cloudinary’s MediaFlows allows users to build and automate media workflows with a low-code or no-code approach. It has a drag-and-drop interface, integrations with platforms like Shopify, and pre-built templates for managing media at scale. MediaFlows has two development options: EasyFlows for no-code automation and PowerFlows for full customization. 

EasyFlows is a no-code, natural language tool that enables non-developers to automate asset management using triggers and actions. It simplifies tasks such as branding control, asset expiration, and auto-tagging through an intuitive workflow builder. PowerFlows offers more advanced customization, allowing users to create workflows from functional blocks that each perform specific actions, providing more trigger options and greater flexibility for managing media assets compared to EasyFlows.

Let’s walk through how to use PowerFlows for the post-upload optimization.To create a new PowerFlow from the MediaFlows page, click on the New PowerFlow tab.

A red box is drawn around the New PowerFlow button.
Cloudinary MediaFlows page

Clicking the button takes you to the PowerFlows page, where you can start building your workflow. 

Next, click on the + icon in the left sidebar to see the list of Blocks you can use to build your workflow.

A red 1 is next to the plus icon on the left sidebar. A red 2 is next to the list of Blocks: Triggers, Flow Logic, Developer tools, Cloudinary APIs, Cloudinary add-ons, Integrations, Notifications, and Transformations.
Cloudinary PowerFlows page

Under each category, a set of blocks is available for you to choose from, allowing you to build the workflow to the level of complexity you require.

To build the post-upload optimization workflow, follow these steps:

  1. Clear the canvas to start fresh, and under the Triggers category, drag the Catch Webhook block and link it to the Add To Logs block.
  2. Open the Catch Webhook block and set the Exposed payload fields option to public_id. This sets the public ID of the video asset to a variable. Click the + icon and save your changes to the block.
Cloudinary PowerFlow page. There's a red box drawn around Catch Webhook, where you can find the Webhook URL, Exposed payload fields, and public_id.
Cloudinary PowerFlow page

Before proceeding, copy the Webhook URL from the catch webhook block and replace it in the upload preset you created earlier. This allows PowerFlow to listen to the webhook notification from the optimization and utilize the data.

  1. Next, under the Cloudinary add-ons block, drag the Google Video Tagging block to the canvas and link it to the Catch Webhook block. Open the Google Video Tagging block and set these fields:
    1. Set Public ID to the public_id variable from the Catch Webhook block by clicking the + icon at the far right and selecting the variable.
    2. Set Delivery type to upload.
    3. Set Resource type to video.
    4. Click Done to save your changes to the block.
The Cloudinary PowerFlow page. A red box is drawn around Google Video Tagging. You can find your Public ID, Delivery type, Resource type, Confidence level, and Webhook URL (optional).
Cloudinary PowerFlow page

Google Video Tagging is an add-on by Cloudinary that uses the Google Cloud Video Intelligence API to automatically analyze video content and generate relevant tags based on detected objects, activities, and scenes. It processes the video frame by frame, identifying elements such as people, animals, vehicles, text, and actions. It assigns descriptive tags to the video, making it easier to search, categorize, and manage within your Cloudinary Media Library.

  1. Click the Save Changes button at the top right of the page to save your workflow.
  2. To test your workflow, follow these steps:
    1. Click the wheel icon beside the Test button at the top right of the page, and set the Action profile to “upload” and the Media URL to any of your Cloudinary video asset URLs.
    2. Save the changes and click on the Test button. This runs your workflow using a test asset, allowing you to view the results in real time.
A red box is drawn around the Live Logs. Catch Webhook and Google Video Tagging have a green Success symbol next to them.
Cloudinary PowerFlow page

From the result, you can see that the Google Video Tagging status is pending, indicating that the video is still being processed. Once the tagging is complete, the status will update, and the response will include a list of relevant tags automatically generated from the video content. 

Relevant tags automatically generated from the video: media, orator, person, presentation, public speaking.
Cloudinary Asset Viewer

With this, you’ve completed an automated video optimization workflow. Every time a video is uploaded to your Cloudinary Media Library, the asset will automatically go through this end-to-end process. The video is optimized for format and quality, resized as needed, and populated with metadata or AI-generated tags, eliminating the need for manual steps. This approach reduces human error, like forgetting to compress or convert a large video file, and ensures your video asset is optimized and production-ready.

Sign up on Cloudinary to automate video optimization with upload presets and MediaFlows.

Resources:

Start Using Cloudinary

Sign up for our free plan and start creating stunning visual experiences in minutes.

Sign Up for Free