Cloudinary Blog

Automated Generation of Intelligent Video Previews on Cloudinary’s Dynamic Video Platform

Automated Generation of Intelligent Video Previews

It’s human nature for most to want a sneak peek at upcoming content whenever possible. Think movie trailers or the “on next week’s episode” part of your favorite show. For video producers, an essential goal is to attract more views and clickthroughs.

Time is precious, however, so viewers invariably want to ensure that a video is relevant for them before watching it. A simple thumbnail is often not adequate to convey enough details of a video; this is where a short video preview could prove to be much more effective.

Cloudinary offers intelligent automatic generation of video previews to give viewers a preliminary look at the most interesting content. A powerful feature well worth adopting. All you need to do is add the preview effect (e_preview in URLs), like this:

Ruby:
Copy to clipboard
cl_image_tag("baking_pastries", :effect=>"preview", :resource_type=>"video")
PHP:
Copy to clipboard
cl_image_tag("baking_pastries", array("effect"=>"preview", "resource_type"=>"video"))
Python:
Copy to clipboard
CloudinaryVideo("baking_pastries").image(effect="preview")
Node.js:
Copy to clipboard
cloudinary.image("baking_pastries", {effect: "preview", resource_type: "video"})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation().effect("preview")).resourceType("video").imageTag("baking_pastries");
JS:
Copy to clipboard
cloudinary.videoTag('baking_pastries', {effect: "preview"}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("baking_pastries", {effect: "preview", resource_type: "video"})
React:
Copy to clipboard
<Video publicId="baking_pastries" resourceType="video">
  <Transformation effect="preview" />
</Video>
Vue.js:
Copy to clipboard
<cld-video publicId="baking_pastries" resourceType="video">
  <cld-transformation effect="preview" />
</cld-video>
Angular:
Copy to clipboard
<cl-video public-id="baking_pastries" resource-type="video">
  <cl-transformation effect="preview">
  </cl-transformation>
</cl-video>
.Net:
Copy to clipboard
cloudinary.Api.UrlVideoUp.Transform(new Transformation().Effect("preview")).BuildImageTag("baking_pastries")
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation().effect("preview")).resourceType("video").generate("baking_pastries");
iOS:
Copy to clipboard
cloudinary.createUrl().setResourceType("video").setTransformation(CLDTransformation().setEffect("preview")).generate("baking_pastries")


Delivering Compelling Video Experiences at Scale


Why Static Thumbnails Just Aren’t Enough

As a rule, developers spotlight videos on web and mobile apps with thumbnails. The simplest way to do this is with the video poster, which is often the first frame of the video—an image that could show nothing or be completely irrelevant to the video content, however. Not great for garnering more views!

Why not extract a relevant poster image from the video or create a completely different but eye-catching image instead? Many YouTube videos use the latter to try and grab your attention. Both options are time-consuming, manual jobs, though. In the case of managing a multitude of videos, especially if they are created by third parties, automation is the answer.

Below are some examples of the various approaches to creating poster images:


First frame

First frame

Middle frame

Middle frame

Manually selected frame

Manually selected frame

Custom thumbnail

Custom thumbnail


Bringing Thumbnails to Life

For a richer user experience with thumbnails, the best solution is to make them move. You could play a short preview of the video content on thumbnail hover. That setup has proven to be extremely effective in increasing engagement, leading to more views of the full video.

Similar to creating thumbnails, generating short video previews is often a manual, time-consuming process. The following are two common options:

  1. Take a few seconds from the video, either at the beginning or the middle. That’s a formulaic, but by far not ideal solution.
  2. Pick the most engrossing moments that last a few seconds from the video. In many cases, you must extract those moments from several scenes, necessitating more time and effort.

The case for a more efficient solution for spotlighting videos is obvious.

First three seconds

Middle three seconds

Custom selected three seconds

Custom edited preview

Getting Smart With Video Previews

We’ve already established that video previews showing the most important content in a video provides the best experience for users. It’s just the question of how to generate these previews automatically. Cloudinary’s capability for automatically generating video previews solves this question and allows you to customize it to match your needs. Through advanced AI and machine-learning techniques, Cloudinary analyzes each video frame, assigns it an importance score, and creates a preview. To trigger that process, simply add the preview effect (e_preview in URLs).

Here's how this looks for our rocket launch video:

Ruby:
Copy to clipboard
cl_image_tag("rocket_launch", :effect=>"preview", :resource_type=>"video")
PHP:
Copy to clipboard
cl_image_tag("rocket_launch", array("effect"=>"preview", "resource_type"=>"video"))
Python:
Copy to clipboard
CloudinaryVideo("rocket_launch").image(effect="preview")
Node.js:
Copy to clipboard
cloudinary.image("rocket_launch", {effect: "preview", resource_type: "video"})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation().effect("preview")).resourceType("video").imageTag("rocket_launch");
JS:
Copy to clipboard
cloudinary.videoTag('rocket_launch', {effect: "preview"}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("rocket_launch", {effect: "preview", resource_type: "video"})
React:
Copy to clipboard
<Video publicId="rocket_launch" resourceType="video">
  <Transformation effect="preview" />
</Video>
Vue.js:
Copy to clipboard
<cld-video publicId="rocket_launch" resourceType="video">
  <cld-transformation effect="preview" />
</cld-video>
Angular:
Copy to clipboard
<cl-video public-id="rocket_launch" resource-type="video">
  <cl-transformation effect="preview">
  </cl-transformation>
</cl-video>
.Net:
Copy to clipboard
cloudinary.Api.UrlVideoUp.Transform(new Transformation().Effect("preview")).BuildImageTag("rocket_launch")
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation().effect("preview")).resourceType("video").generate("rocket_launch");
iOS:
Copy to clipboard
cloudinary.createUrl().setResourceType("video").setTransformation(CLDTransformation().setEffect("preview")).generate("rocket_launch")

Note
We recommend adding the preview effect on upload as an eager transformation to ensure that Cloudinary completes the analysis before delivery (or alternatively use the explicit method before delivery on a video already in your account).

Cloudinary’s initial smart preview functionality created a preview using a single segment from the video, which works well for short and simple videos, such as stock or social ones. The feature has now been enhanced to select multiple segments from the most relevant parts of the original video before generating the preview.

For long videos, e.g., lectures, sports matches, and training classes, consider overriding the default number of segments and their minimum duration by setting the max_seg and min_seg_dur parameters. Below is a video preview from Cloudinary CEO Itai Lahan's 2019 ImageCon talk, with five segments, each three seconds long:

Ruby:
Copy to clipboard
cl_image_tag("2019_imagecon_itai", :effect=>"preview:duration_15:max_seg_5:min_seg_dur_3", :resource_type=>"video")
PHP:
Copy to clipboard
cl_image_tag("2019_imagecon_itai", array("effect"=>"preview:duration_15:max_seg_5:min_seg_dur_3", "resource_type"=>"video"))
Python:
Copy to clipboard
CloudinaryVideo("2019_imagecon_itai").image(effect="preview:duration_15:max_seg_5:min_seg_dur_3")
Node.js:
Copy to clipboard
cloudinary.image("2019_imagecon_itai", {effect: "preview:duration_15:max_seg_5:min_seg_dur_3", resource_type: "video"})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation().effect("preview:duration_15:max_seg_5:min_seg_dur_3")).resourceType("video").imageTag("2019_imagecon_itai");
JS:
Copy to clipboard
cloudinary.videoTag('2019_imagecon_itai', {effect: "preview:duration_15:max_seg_5:min_seg_dur_3"}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.image("2019_imagecon_itai", {effect: "preview:duration_15:max_seg_5:min_seg_dur_3", resource_type: "video"})
React:
Copy to clipboard
<Video publicId="2019_imagecon_itai" resourceType="video">
  <Transformation effect="preview:duration_15:max_seg_5:min_seg_dur_3" />
</Video>
Vue.js:
Copy to clipboard
<cld-video publicId="2019_imagecon_itai" resourceType="video">
  <cld-transformation effect="preview:duration_15:max_seg_5:min_seg_dur_3" />
</cld-video>
Angular:
Copy to clipboard
<cl-video public-id="2019_imagecon_itai" resource-type="video">
  <cl-transformation effect="preview:duration_15:max_seg_5:min_seg_dur_3">
  </cl-transformation>
</cl-video>
.Net:
Copy to clipboard
cloudinary.Api.UrlVideoUp.Transform(new Transformation().Effect("preview:duration_15:max_seg_5:min_seg_dur_3")).BuildImageTag("2019_imagecon_itai")
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation().effect("preview:duration_15:max_seg_5:min_seg_dur_3")).resourceType("video").generate("2019_imagecon_itai");
iOS:
Copy to clipboard
cloudinary.createUrl().setResourceType("video").setTransformation(CLDTransformation().setEffect("preview:duration_15:max_seg_5:min_seg_dur_3")).generate("2019_imagecon_itai")

Note
The default number of segments and durations adjusts according to the length of the original video. For details, see the related documentation.

Video Previews In Action

Now that we know how to easily generate intelligent video previews, let’s see them in action. The most common way to start a video preview is to play it when a viewer hovers over its thumbnail. The codepen below shows an example of this:

See the Pen Intelligent Video Previews Demo by Cloudinary (@Cloudinary) on CodePen.

The above example uses multiple Cloudinary Video Player instances for both the small previews and the full videos. The preview players’ controls are hidden, with each video looping continuously, giving the impression that it’s an animated GIF. Because they are smaller than GIFs, those videos load faster, delivering a more optimized experience.

Try it Out for Yourself

Generating intelligent video previews through automation with Cloudinary is as simple as adding the preview effect (e_preview in URLs) to your videos. You can then easily configure the duration and number of segments. Do give it a try. Increase your video engagement by providing more compelling video listings that feature intelligent video previews.

For more information and examples, see the documentation.


Want to Learn More About Video Optimization?

Recent Blog Posts

Transitioning JPEG-Based to JPEG XL-Based Images for Web Platforms

When the JPEG codec was being developed in the late 1980s, no standardized, lossy image-compression formats existed. JPEG became ready at exactly the right time in 1992, when the World Wide Web and digital cameras were about to become a thing. The introduction of HTML’s <img> tag in 1995 ensured the recognition of JPEG as the web format—at least for photographs. During the 1990s, digital cameras replaced analog ones and, given the limited memory capacities of that era, JPEG became the standard format for photography, especially for consumer-grade cameras.

Read more

Amplify Your Jamstack With Video

By Alex Patterson
Amplify Your Jamstack With Cloudinary Video

As defined by Amazon Web Services (AWS), Amplify is a set of products and tools with which mobile and front-end web developers can build and deploy AWS-powered, secure, and scalable full-stack apps. Also, you can efficiently configure their back ends, connect them to your app with just a few lines of code, and deploy static web apps in only three steps. Historically, because of their performance issues, managing images and videos is a daunting challenge for developers. Even though you can easily load media to an S3 bucket with AWS Amplify, transforming, compressing, and responsively delivering them is labor intensive and time consuming.

Read more
Cloudinary Helps Move James Hardie’s Experience Online

While COVID has affected most businesses, it has been particularly hard on those that sell products for the physical ‘brick and mortar’ world. One company that literally fits that bill is our Australian customer James Hardie, the largest global manufacturer of fibre cement products used in both domestic and commercial construction. These are materials that its buyers ideally want to see up close, in detail. When customers have questions, they expect personal service.

Read more
How to Build an Enhanced Gravatar Service, Part 2

Part 1 of this post defines the capabilities of an enhanced Gravatar service, which I named Clavatar, and describes the following initial steps for building it:

This post, part 2 of the series, explains how to make Clavatar work like Gravatar and to develop Clavatar’s capabilities of enabling requests for various versions of the images related to user accounts.

Read more