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.
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.
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:
- Log in to Cloudinary and, on the Dashboard, click the Media Library icon (second left at the top).
- 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:
- 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.
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.
injectTransparentVideoElement method, which can add transparent videos that work everywhere. Here’s an example of the code on a simple webpage:
As expected, you can see the HTML elements behind the video because of its transparent parts.
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.
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.
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.