Cloudinary Blog

Video Manipulations and Delivery for Angular Video Apps

Video Manipulations and Delivery for Angular Video Apps

On social media, videos posted by users constitute a significant amount of the content appeal on those platforms. From upload to manipulation to delivery, a smooth, efficient, and effective pipeline for the posting process is mandatory to ensure consistent user sessions and their steadily increasing volume. However, building such an infrastructure is a complex, labor-intensive, and problem-prone undertaking.

Enter Cloudinary, whose capabilities impressively form such an infrastructure. This article shows you how to manipulate, transform, and deliver videos in Angular apps with Cloudinary’s robust drop-in components.

Webinar
Delivering Compelling Video Experiences at Scale

Installing the Angular SDK

To manipulate and transform videos while on Cloudinary, leverage the parameters in its Angular video component.

First, install the Cloudinary SDK for your Angular version. Type this NPM command:

Copy to clipboard
npm install cloudinary-core @cloudinary/angular-5.x --save

Afterwards, import from the SDK the <cl-video> component, which places in your app an HTML 5 video player. That player plays videos—whether in webm, ogv, or mp4 format—without a glitch on all major web browsers.

Note
AngularJS 1.x developers: You can obtain the <cl-video> component by typing this Bower command line:

Copy to clipboard
bower install cloudinary_ng#1.x --save

You can now transform and manipulate videos with no need for a dedicated server. Read on for the specific tasks and their related procedures.

Transcoding Video Formats

The format parameter takes one of these three values: webm, ogv, and mp4.

For example, to transcode the existing format of an Angular video called cat to the webm format, code as follows:

Copy to clipboard
<cl-video public-id="cat" format="webm">

</cl-video>

Concatenating Angular Videos

To concatenate multiple Angular videos by overlaying one on top of another, specify the related values for the overlay parameter for the <cl-video> and <cl-transformation> components. For example:

Copy to clipboard
<cl-video public-id="footballer" >
  <cl-transformation width="400" height="250" crop="fill">
  </cl-transformation>
  <cl-transformation overlay="video:ball" flags="splice" width="300" height="200" crop="fill">
  </cl-transformation>
</cl-video>

Adjusting Video Quality

The quality parameter takes any value between 0 and 100. The lower the value, the smaller the video size. By specifying a value for quality, you set the level of quality you desire for the video size at delivery.

For example:

Copy to clipboard
<cl-video public-id="drink" >
  <cl-transformation quality="60">
  </cl-transformation>
</cl-video>

Controlling the Playback Speed

While playing videos, users often accelerate or reduce the playback speed to accommodate various scenarios. For example, to watch as many course videos offered by a time-limited subscription as possible, a user might choose to skim through some of them.

To enable control of playback speed, specify a value of between -50 and 100 for the accelerate attribute in the effect parameter.

Note
That value applies to both acceleration and deceleration. For example:

Copy to clipboard
<cl-video public-id="dog" >
  <cl-transformation width="300" effect="accelerate:100" crop="scale">
  </cl-transformation>
</cl-video>

Generating Video Previews With AI

AI automatically identifies the appealing excerpts of a video and generates a preview version of the duration that you specify. Code as follows:

Copy to clipboard
<cl-video public-id="afcon" >
  <cl-transformation effect="preview:duration_10">
  </cl-transformation>
</cl-video>

The value 10 above denotes 10 minutes. You can specify any value between [?] and [?].

Note
This feature, currently in Beta, truly rocks! Do take a spin with it. You’ll be awed.

Adding Captions and Subtitles

To add a caption to a video, specify the caption’s font type, font size, wording, and such for the text attribute in the overlay parameter. Here is a self-explanatory code example:

Copy to clipboard
<cl-video public-id="dog" >
  <cl-transformation overlay="text:arial_60:Angular%20Video" gravity="south" y="80" start-offset="2" end-offset="5">
  </cl-transformation>
</cl-video>

As soon as that video called dog starts playing, its text caption, Angular Video, is displayed.

To add subtitles to a video as an overlay, specify in the overlay parameter the font type and size that you desire along with the name of the related SRT file. For example:

Copy to clipboard
<cl-video public-id="cat" >
  <cl-transformation overlay="subtitles:arial_20:sample_sub_en.srt">
  </cl-transformation>
</cl-video>

Reminder: Be sure to upload the SRT.srt file to Cloudinary first.

For other transformations you can apply to Angular videos, see the related documentation.

Browsing Other References

The following Cloudinary documentation contains many nuances that are worth a look:

You might also be interested in this three-part series I wrote in 2016 on building your own YouTube platform on Cloudinary and AngularJS.

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


Further Reading on Video Manipulation

Recent Blog Posts

Laravel File Upload to a Local Server Or to the Cloud

Currently, Laravel is the most renowned PHP framework, boasting of a large developer community; several open-source packages, such as Cashier, Sanctum, Scout, and Telescope; and a host of paid platforms, e.g., Laravel Forge, Envoyer, and Vapor. Laravel Forge & Envoyer ably supports deployment and use of Laravel production-based apps.

Read more
TedsVintageArt.com Automates Generation of Captivating Product Images on Cloudinary

At TedsVintageArt.com, we digitally restore historic maps and sell their art prints on multiple platforms, such as Amazon, Etsy, eBay, and Houzz. As our operations ramped up years ago, it took an inordinately long time to generate custom images for our products. Plus, since we sell art, it behooves us to produce multiple high-quality images for each print, which was another time-consuming task.

Read more
lastminute.com Takes a Vacation From Media-Management Headaches With Cloudinary

As a 20-year online leader in travel and leisure retail, Europe-based public company lastminute.com along with its 1,200 employees are committed to enriching the lives of vacationers through comprehensive and enticing products and services. Beyond flight deals and tours, it's the images and videos, whether of that luxury villa in Greece, romantic Parisian street, or exotic stroll through the Marrakech markets, that attract audiences and boost bookings.

Read more