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:
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.
<cl-video>
component by typing this Bower command line: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:
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.
<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 [?].
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:
- A complete reference on video manipulation and transformation with Cloudinary.
- SDKs and libraries: server side, client side, and mobile
Further Reading on Video Manipulation
- Video Transcoding and Manipulation
- Top 10 Mistakes in Handling Website Videos and How to Solve Them
- How to Compress Video Size Automatically With One Line of Code
- ExoPlayer Android Tutorial: Easy Video Delivery and Editing
- Ultimate HTML5 Video Player Showdown: 10 Players Compared
- How to Generate Waveform Images From Audio Files
- Auto Generate Subtitles Based on Video Transcript
- Auto-Generate Video Previews with Great Results Every Time
- Adaptive HLS Streaming Using the HTML5 Video Tag
- Video Optimization With the HTML5 <\video> Player
- Converting Android Videos to Animated GIF Images With Cloudinary: A Tutorial