Programmable Media

Android video transformations

Last updated: Oct-31-2023

Overview

After uploading videos to Cloudinary, they can be transformed in many ways.

The syntax for transforming and delivering videos is generally similar to that for images, and you can apply the majority of available image transformations to video as well. For example, you can resize, crop, rotate, set video quality and format or use auto quality and/or auto format, add text or image overlays to your videos, and more.

There are also a number of special options you can use for transforming and delivering video content. For example, you can adjust their size, shape, speed, duration, quality, and appearance. There are also some features that are specific to audio.

This section introduces you to the basics of Android video streaming and transformation. For complete details on all video transformation functionality, see Video transformations and the Transformation URL API Reference.

Video transformation functionality

In addition to transformation features that are equally relevant for images and video, such as resizing, cropping, rotating, adding text or image overlays, and setting video quality or format, there are a variety of special transformations you can use for video. For example, you can:

You can optionally specify all of the above transformations to videos using methods that generate image tags or via direct URL-building directives.

Deliver videos

Use the url method of the MediaManager class to generate a video URL.

The code above returns the following string:

https://res.cloudinary.com/demo/video/upload/dog.mp4

You can also include transformation parameters in the request, for example, to return the URL for a video padded to a width of 400 pixels:

The code above returns the following string:

https://res.cloudinary.com/demo/video/upload/c_pad,w_400/dog.mp4

Help us improve our SDK
We'd love to hear your thoughts on using our Android SDK. Please take a moment to complete this short survey.
Thanks for your time!

Cloudinary native video player

The Android SDK also includes a Cloudinary native video player based on ExoPlayer. This makes it easier to use the various Cloudinary video capabilities and deliver your videos using the native player.

To create a player, use the CldVideoPlayer class to initialize it, providing either the public ID for the video or the full Cloudinary URL:

Once you have the player instance, you can add that into a view.

Here's an example:

Note
As the CldVideoPlayer is a container for the actual ExoPlayer instance, you need to call the getPlayer() method (as shown in the example) to include it in the view.

Transformations

You can include video transformations as part of your CLDVideoPlayer instance in the same way as when using the url method. The transformations are defined when initializing the player. For example:

Note

Automatic streaming profile selection is enabled by default. This currently has a limited set of transformations that you can combine with it, therefore when using any transformations, automatic streaming profile selection will be disabled. If you want to include both, check that your transformations are supported and set the streaming profile transformation to auto when initializing your player, for example:

Video transformation examples

This section provides examples of using Android code to apply some of the video transformation features mentioned in the previous section.

Example 1:

The following example resizes the dog video to 40% of it's original size and rotates it by 20 degrees. It also adds a semi-transparent cloudinary logo in the bottom right corner, using a southeast gravity with adjusted x and y coordinates to reach the corner of the rotated video.

Example 2:

The following example appends a copy of this video in reverse to the original video, and then appends another forward playing copy, but in slow motion. This new video is muted, adjusted for brightness, and set to the max radius in order to give a telescope-like effect.

Example 3:

The following example returns the first 10 seconds of the dog video. The video is also cropped to 360X480 using the pad cropping method, and it is generated at 70% quality to control file size.

The code above returns the following url:

✔️ Feedback sent!

Rate this page: