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.

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:

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:

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:

<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:

<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:

<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:

<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:

<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:

<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:

<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.


Further Reading on Video Manipulation

Recent Blog Posts

Converting Videos to GIFs in Kotlin-Based Android Apps

Among the image formats available today, Graphics Interchange Format (GIF) works for both static and animated images. A popular use of GIF images—commonly called GIFs—is to repeatedly loop motions, which you cannot in real life. Many people have turned themselves into online celebrities through effective application of GIFs.

Read more
Simple Steps to Make Your Site Accessible With Cloudinary

Web accessibility (a11y) is about gaining an insight into—

It’s a blurry line between accessibility and usability (or user experience) and one might argue that they are actually the same thing. Nonetheless, if your audience can't use your app with ease and confidence, then it’s not accessible enough and the user experience is not good enough.

Read more
Learn three ways in which to tell appealing stories on video.

Video storytelling is one of the most effective means of conveying messages to your audience. It’s also a popular marketing tool because most people are automatically drawn to video. In eCommerce, if accompanied by attractive images and a compelling narrative, video storytelling uniquely connect with potential customers without fail.

Read more