Cloudinary Blog

Building Display Ads With Transparent Video

Build Web Ads With Transparent Video to Attract User Engagement

Billions of views on the Internet every day drive one of the biggest industries on the planet: advertising. The sheer size of that market and the competitive nature of vying for consumer attention results in a constant need for innovation. Readers are jaded, and display ads are blind spots.

To break through this veil of antipathy, advertisers must impress, entertain, and delight prospective customers. Reality is, click-through rates for static banners are continuing to drop, and even animated images or script-based animations are limited in effectiveness. Motion captures readers’ eye, but a story holds the audience, hence why more advertisers are moving toward video-based advertising.

However, if placed outside the main field of view, video and video APIs are still subject to the "blind spot" issue. Overlaying a video that contains transparency enables the video and, therefore, the message to become part of the content.

Placing a video overlay on top of your site’s viewport, changing content, or helping visitors navigate the site promotes understanding of your product, encouraging engagement by potential customers. Transparent video feels like it’s part of your site, not just embedded there. Since all other webpage elements are visible, you can, with regular web-development expertise, build a captivating experience behind and around videos.

With the power of today’s 5G bandwidth, streaming video on websites is no longer a challenge, so you need not limit yourself to the old-fashioned, text-based ways of implementing interactions. With Cloudinary and a little JavaScript, creating compelling video ads is now easier—and more fun—than you might think.

Preparing the Video

Transparent video ads originate from videos with a transparent channel, such as WebM videos, and a transparent background set. You can purchase videos in that format online or create your own green-screen videos and remove the background. That’s what we did for this demo: we downloaded a video from Camtasia and then used that tool to eliminate the background. The video is available for free for those who want to process videos with Camtasia.

Note
Cloudinary is working on an experimental feature to “automagically” remove video backgrounds.

Once you have a WebM-formatted video with a transparent background, upload the video to Cloudinary:

  1. Log in to Cloudinary and, on the Dashboard, click the Media Library icon (second left at the top).
  2. Click Upload in the top-right corner to specify the video you wish to upload. Either drag and drop it on to the portal or select it after navigating to the folder that houses the video. Once upload succeeds, Cloudinary displays it in your Media Library:
  3. Copy the video URL and embed it on your website with the built-in HTML5 <video/> element. Before doing that, feel free to apply more transformations to the video, such as resizing, cropping, and adding a background.

Your video is now available on your site. Read on to learn how to stream video content to visitors.

Embedding the Video on a Website

Cloudinary offers an SDK that delivers transparent videos directly within HTML content. With that JavaScript SDK, you can deliver content across all browsers. The rest of this section describes the controls for delivering transparent video to all browsers.

Normally, you would add video to webpages with the HTML5 <video> element or through the Cloudinary Video Player. However, transparent video is an exception. Native HTML5 and the Cloudinary Video Player can handle transparent video everywhere except Safari on iOS and pre-Big Sur MacOS versions. That’s a problem given the ubiquity of Macs and iPhones.

Fortunately, the Cloudinary JavaScript SDK can help with its injectTransparentVideoElement method, which can add transparent videos that work everywhere. Here’s an example of the code on a simple webpage:

Copy to clipboard
<html lang="en">
    <head>
       <title>Transparent Video</title>
       <style>
            #video-overlay {
                position: absolute;
                top: 90;
                left: 65;
                width: 900px;
            }
       </style>
       <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
       <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css">
       <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
       <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
          <script src="https://unpkg.com/cloudinary-core@latest/cloudinary-core-shrinkwrap.min.js" type="text/javascript"></script>
    </head>
    <body>
       <div class="container">
            <h1>Video overlays</h1>
            <p>Video overlays are a great way to engage users without interfering with the content on the website.</p>
            <input type="submit" value="Click me!" class="overlay-control" style="z-index: 6; position: relative;" />
            <p>Hi, here is some text behind the video...</p>
            <p class="mt-100">Here is more text content.</p>
            <div id="video-overlay" style="z-index: 5;"></video>
       </div>
          <script>
              $(function() {
                $(".overlay-control").click(function() {
                    var cld = cloudinary.Cloudinary.new({ cloud_name: 'afzaalahmadzeeshan' });
                    cld.injectTransparentVideoElement(document.getElementById("video-overlay"), 'v1610035527/samples/elephants.mp4', {
                        loop: true,
                        playsinline: true,
                        width: 600,
                    }).catch(error => {
                        console.log(error);
                    });
                });
              });
          </script>
    </body>
</html>

As expected, you can see the HTML elements behind the video because of its transparent parts.

Furthermore, you can create fun experiences with transparent video, for example, set up the content with JavaScript to play or pause on a user interaction, hence opening up more possibilities for content and advertising. A transparent-display ad can become part of the content the audience was looking at, intriguing them and capturing their attention. On your website, transparent video can also entice audience engagement with content, directing them to navigate to product pages or interact with demos.

Applications abound for transparent video in other industries. For instance, those in academia can display videos that require students to perform certain tasks on the website before the instructor proceeds with the course material.

Keep in mind that you can further customize the above script to transform videos. Plus, it’d be prudent to add a fallback value that the script can render in case the browser does not support all the features required to play the video.

For details on all those options, see Cloudinary’s documentation on its Video Player and on video transformations.

Taking the Next Steps

Beside describing the benefits of embellishing web advertisements with compelling, transparent video content, this article also explains why interactive content is useful and why old, static ads are less so. You’ve also learned how to collect, purchase, or prepare your own interactive video for display on your site, and then embed that video with Cloudinary and JavaScript.

Cloudinary’s upcoming video-editing feature will build on the existing technologies, enabling you to create riveting, interactive videos with artificial intelligence (AI). You can then easily remove video backgrounds and create transparent overlays for embedding in your website, further promoting user engagement.

For more insight, check out the Google Chrome Developer’s post on alpha transparency in videos and the Google Web Team’s article on autoplay policy changes.

Are you ready to boost engagement with transparent video ads? Start with signing up for a free Cloudinary account with enough credits to create your first sleek ad.

About the Author

Afzaal Ahmad Zeeshan, who hails from the Netherlands, is a developer advocate at Adyen with a preference for .NET Core and Node.js for everyday software programming. As an expert on cloud, mobile, and APIs, Afzaal is adept with the Azure platform and enjoys building cross-platform libraries and software with .NET Core. He’s also an author with Pluralsight with a focus on producing courses on mobile development and programming languages.

Additionally, Afzaal is an Alibaba Cloud MVP. He’s been named Microsoft MVP twice for community leadership in software development, CodeProject MVP six times for technical writing and mentoring, and C# Corner MVP four times in the same field. Beyond that, Afzaal is an active open-source contributor (user name afzaal-ahmad-zeeshan) on GitHub and GitLab.

Recent Blog Posts

Auto-Tag Videos With Cloudinary: A Tutorial

Video is one of the best ways for capturing audience attention. Product demonstrations, property tours, tutorials, and keynotes all make great content—provided that they’re readily searchable by your team and visitors alike. Even though tagging and categorization help organize videos and make them easy to find, the labeling process is labor intensive, taking time away from key tasks like creating new videos.

Read more
Video Uploads With Cloudinary

Setting up the infrastructure for video uploads can go from straightforward to complex real fast. Why? Because many challenges are involved in building a foolproof service for an efficient and smooth process.

Read more
Optimize Media to Get Ready for Google’s Core Web Vitals

For years, Google has been updating its search algorithm to prioritize end-user experience, displaying the most relevant and helpful content at the top of search results. The latest—and maybe the most significant—update so far is Core Web Vitals (CWVs), which are new metrics announced a year ago that will, starting in June, begin determining search rankings. With this update, Google is being abundantly clear that visual experience of webpages is paramount.

Read more
Compressing, Resizing, and Optimizing Videos in Laravel

Videos are large media files—in most cases, at least four times larger than images—and are often created for ads, marketing campaigns, and instructional content to convey as much information as possible in a short time. Ensuring that videos do not buffer all the time and that the user’s data is protected from rapid consumption due to heavy page weight must be the modus operandi for all website builders and e-business owners.

Read more
Five Ways to Effectively Manage Online Media

The digital economy is driven by highly visual experiences. After all, viewers process images 60,000 times faster than text. Therefore, it’s no surprise that top-notch visual media has been an essential component of a captivating e-commerce experience for years. Nor is it surprising that visual media’s importance only rose during the COVID-19 pandemic, a reality for all retailers, including our client Levi’s.

Read more
Creating an API With Python Flask to Upload Files to Cloudinary

Code

Cloudinary offers SDKs for many programming languages and frameworks. Even though it also offers an Upload API endpoint for both back-end and front-end code, most developers find the SDKs very helpful. If you're working with a powerful back-end framework like Python Flask, you'll be happy to hear that a Python SDK is now available.
This tutorial walks you through the process of building an API to upload images to Cloudinary. You can also upload other file types, including video and even nonmedia files, with the API.

Read more