How to Resize a Video and Preserve Aspect Ratio in Java

Aspect ratio dictates how your video looks in comparison with your original vision while also informing the viewer on what kind of video content they are watching. When resizing a video, but not changing the way that you wish it to be viewed, it is necessary to preserve that aspect ratio. This API will help you do exactly that using Java.

Image for post
Image for post

We first need to add a reference to the repository in pom.xml:


Then, we can add a reference to the dependency:


Now, we can call our function, VideoResizeVideo:

// Import classes:
//import com.cloudmersive.client.invoker.ApiClient;
//import com.cloudmersive.client.invoker.ApiException;
//import com.cloudmersive.client.invoker.Configuration;
//import com.cloudmersive.client.invoker.auth.*;
//import com.cloudmersive.client.VideoApi;

With this, you can ensure your videos always mirror your desired product. You can retrieve your free API Key from the Cloudmersive website. This will give you access to 800 monthly calls across our library of APIs.

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store