In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Most people do not understand the knowledge of this article "how to resize the video in the java project", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to resize the video in the java project" article.
Optimizing your brand image can be a daunting task when your audience is scattered across current and emerging online media platforms. One way to achieve your goals and build brand awareness is to share video content. This can be a fascinating way to share visual effects, exchange information, and reach different audiences. Unfortunately, managing video formats can be a bit difficult due to different size requirements for different platforms.
If you need to resize the video, it is important to determine whether you want to maintain the current aspect ratio or customize it to accommodate the new parameters. To be clear, the aspect ratio is the ratio of the width to height of the image, which affects the appearance of the resized video compared to the original vision. If you want to change the size of the video, but do not want to change the way you watch it, it is necessary to keep the aspect ratio. On the other hand, you may want to resize slightly to fit the new format.
The following API will provide you with two automatic options for resizing video in Java; one will maintain your original aspect ratio, and the other will allow you to enter a new customizable size. Both functions support a variety of input video formats, including AVI, FLV, MP4, MOV, and so on. They use 1 API call for every 10 MB file size and 1 API call for every additional minute of processing time within 5 minutes, with a total processing time of up to 25 minutes. The maximum output file size is 50GB.
First, we will install Maven SDK by adding a reference to the jitpack repository in pom.xml:
Java:
Jitpack.io https://jitpack.io
Then we will add a reference to the dependency:
Java:
Com.github.Cloudmersive Cloudmersive.APIClient.Java v3.90
After the installation is complete, we can discuss our first API. The following features will resize the video while maintaining the original aspect ratio and encoding, which will allow you to retain the original vision and convey the content in the style of your choice. To perform the operation, we need to add the import to the top of the controller and call the function:
Java:
/ / 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;ApiClient defaultClient = Configuration.getDefaultApiClient (); / / Configure API key authorization: ApikeyApiKeyAuth Apikey = (ApiKeyAuth) defaultClient.getAuthentication ("Apikey"); Apikey.setApiKey ("YOUR API KEY"); / / Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) / / Apikey.setApiKeyPrefix ("Token"); VideoApi apiInstance = new VideoApi (); File inputFile = new File ("/ path/to/inputfile"); / / File | Input file to perform the operation on.String fileUrl = "fileUrl_example"; / / String | Optional; URL of a video file being used for conversion. Use this option for files larger than 2GB.Integer maxWidth = 56; / / Integer | Optional; Maximum width of the output video, up to the original video width. Defaults to original video width.Integer maxHeight = 56; / / Integer | Optional; Maximum height of the output video, up to the original video width. Defaults to original video height.Integer frameRate = 56; / / Integer | Optional; Specify the frame rate of the output video. Defaults to original video frame rate.Integer quality = 56; / / Integer | Optional; Specify the quality of the output video, where 100is lossless and 1 is the lowest possible quality with highest compression. Default is 50.String extension = "extension_example"; / / String | Optional; Specify the file extension of the input video. This is recommended when inputting a file directly, without a file name. If no file name is available and no extension is provided, the extension will be inferred from the file data, which may cause a different extension to be used in the output.try {byte [] result = apiInstance.videoResizeVideo (inputFile, fileUrl, maxWidth, maxHeight, frameRate, quality, extension); System.out.println (result);} catch (ApiException e) {System.err.println ("Exception when calling VideoApi#videoResizeVideo"); e.printStackTrace ();}
Now, if you prefer a customizable editing experience, you can use the following features to resize the video without retaining the original aspect ratio; this will allow you to adapt to any video format with minor changes. However, when choosing this method, keep in mind that it does increase the likelihood of image tilting.
Java:
/ / 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;ApiClient defaultClient = Configuration.getDefaultApiClient (); / / Configure API key authorization: ApikeyApiKeyAuth Apikey = (ApiKeyAuth) defaultClient.getAuthentication ("Apikey"); Apikey.setApiKey ("YOUR API KEY"); / / Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) / / Apikey.setApiKeyPrefix ("Token"); VideoApi apiInstance = new VideoApi (); File inputFile = new File ("/ path/to/inputfile"); / / File | Input file to perform the operation on.String fileUrl = "fileUrl_example"; / / String | Optional; URL of a video file being used for conversion. Use this option for files larger than 2GB.Integer maxWidth = 56; / / Integer | Optional; Maximum width of the output video, up to the original video width. Defaults to original video width.Integer maxHeight = 56; / / Integer | Optional; Maximum height of the output video, up to the original video width. Defaults to original video height.Integer frameRate = 56; / / Integer | Optional; Specify the frame rate of the output video. Defaults to original video frame rate.Integer quality = 56; / / Integer | Optional; Specify the quality of the output video, where 100is lossless and 1 is the lowest possible quality with highest compression. Default is 50.String extension = "extension_example"; / / String | Optional; Specify the file extension of the input video. This is recommended when inputting a file directly, without a file name. If no file name is available and no extension is provided, the extension will be inferred from the file data, which may cause a different extension to be used in the output.try {byte [] result = apiInstance.videoResizeVideoSimple (inputFile, fileUrl, maxWidth, maxHeight, frameRate, quality, extension); System.out.println (result);} catch (ApiException e) {System.err.println ("Exception when calling VideoApi#videoResizeVideoSimple"); e.printStackTrace ();}
To ensure that the two resizing features run smoothly, you need to meet several required parameters, and you can choose to enter some other parameters:
Input file (required): the specific video file on which you want to perform an operation.
API Key (required): your personal API key; if you don't already have it, you can retrieve it by signing up for a free account on the Cloudmersive website.
File URL (optional): the URL; of the file you want to operate on is recommended for any file that exceeds 2GB.
Max Width (optional): the maximum width of the output video, up to the original video width; the default is the original video width.
Max Height (optional): the maximum height of the output video, up to the original video width; the default is the original video height.
Frame Rate (optional): the frame rate of the output video; the default is the original video frame rate.
Quality (optional): the quality of the output video, where 100 is lossless and 1 is the lowest quality with the highest compression ratio; the default is 50.
Extension (optional): enter a file extension for the video; this option is recommended when entering a file directly, without the need for a file name. If no file name is available and no extension is provided, the extension is inferred from the file data, which may result in a different extension being used in the output.
Whether you choose to maintain or adjust the aspect ratio, we hope this tutorial suits your video resizing needs.
The above is about the content of this article on "how to resize the video in the java project". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.