Cloudinary Blog
Automatic Video Transcoding

Delivering video files to users can be a much more complex undertaking than many people stop to consider. There are a large variety of video formats and codecs to choose between, and various optimization parameters for encoding the videos. Parameters such as bitrate, key-frame-interval, and frame-rate will have an effect on the visual quality and bandwidth requirements when delivering the video file. To make matters worse, there are so many potential viewing devices out there (desktops, laptops, tablets, mobiles, wearables, etc). Each of these devices have different browsers or apps, and they all support different formats and codecs!

Unfortunately, there is no single format or codec that is ideal for all end users. Selecting a format and codec that is supported by all browsers and devices will actually affect quality and user-experience. Since some formats are better than others at compression and reducing the file size without impairing visual quality, the best solution to save bandwidth and optimize delivery time would be to deliver the best format according to the browser used by each of your visitors.

globalstats

(Image courtesy of https://www.w3counter.com/globalstats.php)

Webinar
Delivering Compelling Video Experiences at Scale

Introducing Automatic Video Transcoding

Let Cloudinary do the job of automatically selecting the best codec and format for you. The automatic format selection feature for images has now been extended to offer the same functionality for videos as part of our Dynamic Video Platform solution. Cloudinary identifies the end-user device and browser and then delivers the best video format and codec for that particular user. The feature currently supports selecting between the H.264, HEVC and VP9 codecs and is future-proofed for adding next-generation codecs such as AV1.

So take the complexity out of managing videos because adding this functionality is as simple as adding the fetch_format parameter set to auto (f_auto in URLs). This tells Cloudinary to perform automatic format and codec selection based on the requesting browser. For example, with the automatic video format feature, in most cases Chrome users would receive a VP9-encoded WebM file, while Safari users would receive an HEVC-encoded MP4 file. If a requesting browser does not support either of these formats, then the video would be delivered as an H-264 encoded MP4 file, which is supported by almost every browser.

For example, the kitten_playing video is scaled down to a width of 500 pixels and delivered as:

  • WebM (VP9) to Chrome browsers (1412 KB),
  • MP4 (HEVC) to Safari browsers (1411 KB),
  • MP4 (H.264) to browsers that support neither format (3172 KB)

Ruby:
Copy to clipboard
cl_video_tag("kitten_play", :fetch_format=>:auto)
PHP:
Copy to clipboard
cl_video_tag("kitten_play", array("fetch_format"=>"auto"))
Python:
Copy to clipboard
CloudinaryVideo("kitten_play").video(fetch_format="auto")
Node.js:
Copy to clipboard
cloudinary.video("kitten_play", {fetch_format: "auto"})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation().fetchFormat("auto")).videoTag("kitten_play");
JS:
Copy to clipboard
cloudinary.videoTag('kitten_play', {fetchFormat: "auto"}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.video("kitten_play", {fetch_format: "auto"})
React:
Copy to clipboard
<Video publicId="kitten_play" >
  <Transformation fetchFormat="auto" />
</Video>
Vue.js:
Copy to clipboard
<cld-video publicId="kitten_play" >
  <cld-transformation fetchFormat="auto" />
</cld-video>
Angular:
Copy to clipboard
<cl-video public-id="kitten_play" >
  <cl-transformation fetch-format="auto">
  </cl-transformation>
</cl-video>
.Net:
Copy to clipboard
cloudinary.Api.UrlVideoUp.Transform(new Transformation().FetchFormat("auto")).BuildVideoTag("kitten_play")
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation().fetchFormat("auto")).resourceType("video").generate("kitten_play.mp4");
iOS:
Copy to clipboard
cloudinary.createUrl().setResourceType("video").setTransformation(CLDTransformation().setFetchFormat("auto")).generate("kitten_play.mp4")

Combine with Content-Aware Video Compression

Even better, you can combine the automatic format selection feature (f_auto) with Cloudinary's automatic quality feature (q_auto) for even better results. Cloudinary's intelligent quality and encoding algorithm analyzes a video to find the best quality compression level and optimal encoding settings based on the video content. The result is a video with good visual quality while minimizing the file size. For example, the same kitten_playing video delivered with f_auto alone in the example above, now delivered with f_auto and q_auto together would produce a more optimized result:

Format (and codec) f_auto f_auto, q_auto
WebM (VP9) 1412 KB 1271 KB
MP4 (HEVC) 1411 KB 1355 KB
MP4 (H.264) 3172 KB 2876 KB

Ruby:
Copy to clipboard
cl_video_tag("kitten_play", :quality=>"auto", :fetch_format=>:auto)
PHP:
Copy to clipboard
cl_video_tag("kitten_play", array("quality"=>"auto", "fetch_format"=>"auto"))
Python:
Copy to clipboard
CloudinaryVideo("kitten_play").video(quality="auto", fetch_format="auto")
Node.js:
Copy to clipboard
cloudinary.video("kitten_play", {quality: "auto", fetch_format: "auto"})
Java:
Copy to clipboard
cloudinary.url().transformation(new Transformation().quality("auto").fetchFormat("auto")).videoTag("kitten_play");
JS:
Copy to clipboard
cloudinary.videoTag('kitten_play', {quality: "auto", fetchFormat: "auto"}).toHtml();
jQuery:
Copy to clipboard
$.cloudinary.video("kitten_play", {quality: "auto", fetch_format: "auto"})
React:
Copy to clipboard
<Video publicId="kitten_play" >
  <Transformation quality="auto" fetchFormat="auto" />
</Video>
Vue.js:
Copy to clipboard
<cld-video publicId="kitten_play" >
  <cld-transformation quality="auto" fetchFormat="auto" />
</cld-video>
Angular:
Copy to clipboard
<cl-video public-id="kitten_play" >
  <cl-transformation quality="auto" fetch-format="auto">
  </cl-transformation>
</cl-video>
.Net:
Copy to clipboard
cloudinary.Api.UrlVideoUp.Transform(new Transformation().Quality("auto").FetchFormat("auto")).BuildVideoTag("kitten_play")
Android:
Copy to clipboard
MediaManager.get().url().transformation(new Transformation().quality("auto").fetchFormat("auto")).resourceType("video").generate("kitten_play.mp4");
iOS:
Copy to clipboard
cloudinary.createUrl().setResourceType("video").setTransformation(CLDTransformation().setQuality("auto").setFetchFormat("auto")).generate("kitten_play.mp4")

Try it out

Check out the Cloudinary demo page for video format optimization if you would like to see the file size difference between videos delivered in different formats. You can select one of the videos on the page or upload your own video to encode in various formats. Of course, the Cloudinary automatic format feature will do all the work for you and also decide which format your user should get based on their browser.

video format optimization

Tip
You can also visit our video comparison page to compare the visual quality between any two videos, or in this case, any two video formats.

Summing up

Delivering a video in the best format can be easily automated with Cloudinary's format selection feature. The functionality can also be combined with automatic quality selection for a powerful and dynamic solution that delivers all your videos using minimal bandwidth and maximum visual quality. For more details, see the automatic format selection documentation.

All video manipulation and delivery features discussed here are available with no extra charge for all Cloudinary's plans, including the free plan.

Note
The automatic video transcoding feature is enabled by default for all new accounts, and is currently being rolled out for existing accounts. If you are an existing customer and want access to this feature before it is rolled out to you, please contact support.

About Cloudinary

Cloudinary provides easy-to-use, cloud-based media management solutions for the world’s top brands. With offices in the US, UK and Israel, Cloudinary has quickly become the de facto solution used by developers and marketers at major companies around the world to streamline rich media management and deliver optimal end-user experiences.

For more information, visit www.cloudinary.com or follow us on Twitter.

Recent Blog Posts

Automation Frees Up PetRescue’s Staff to Help Pets Find Their Forever Homes

As we spend more time at home, many of us are adopting pets for the joy, companionship and a surprising range of health benefits. In Australia, where our nonprofit customer PetRescue is located, there’s a shortage of pets to adopt. Last August, the Guardian reported that dog shelters in Australia emptied and adoption fees for puppies were running as high as $AUS1800.

Read more
Cloudinary and Contentful Make Modern Content Management Easier

I am pleased to share that Cloudinary and Contentful have joined forces to further streamline the creation, processing, and delivery of online content through Cloudinary’s digital asset management (DAM) solution and advanced transformation and delivery capabilities for images and video. What’s more, the partnership delivers a headless approach to DAM. By leveraging APIs for media management tasks, marketers and developers alike benefit from an integrated stack of optimized assets for optimization and automation. As a result, page loads are fast and beautiful, and at scale—with less overhead and effort.

Read more
Introducing Cloudinary's Nuxt Module

Since its initial release in October 2016 by the Chopin brothers as a server-side framework that runs on top of Vue.js, Nuxt (aka Nuxt.js) has gained prominence in both intuitiveness and performance. The framework offers numerous built-in features based on a modular architecture, bringing ease and simplicity to web development. Not surprisingly, Nuxt.js has seen remarkable growth in adoption by the developer community along with accolades galore. At this writing, Nuxt has earned over 30K stars on GitHub and 96 active modules with over a million downloads per month. And the upward trend is ongoing.

Read more
How Quality and Quantity can go Hand in Hand

When it comes to quality versus quantity, you’ll often hear people say, “It’s the quality that counts, not the quantity”. While that’s true in many situations, there are also cases where you want both quality and quantity. You may have thousands of images on your website and you want them all to look great. This is especially important if your website allows users to upload their own content, for example, to sell their own products or services. You don't want their poor quality images to reflect badly on your brand.

Read more
Product Videos 101: What Makes Them Great?

A product’s benefits and usage, including its value proposition, features, and instructive details, are best demonstrated through video. Product-video types vary, depending on the funnel, channel, and audience, the most popular ones being demos, reviews, installation, and how-tos.

Read more