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

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