Convert a Video to WEBM in JavaScript

Cloudmersive
1 min readAug 24, 2021

Several online media platforms, including YouTube, utilize WEBM videos as their preferred format. If you plan to utilize these platforms, converting your videos to WEBM will ensure compatibility and the best possible quality for viewers. This API will allow you to automatically incorporate WEBM conversion capabilities to your applications and websites.

We will start the process by running this command to install jQuery:

bower install jquery

Once the installation is complete, we can add the video file, API key, and any optional parameters you wish to specify to the following code:

var form = new FormData();
form.append("inputFile", fileInput.files[0], "file");
var settings = {
"url": "https://api.cloudmersive.com/video/convert/to/webm",
"method": "POST",
"timeout": 0,
"headers": {
"fileUrl": "<string>",
"maxWidth": "<integer>",
"maxHeight": "<integer>",
"preserveAspectRatio": "<boolean>",
"frameRate": "<integer>",
"quality": "<integer>",
"Content-Type": "multipart/form-data",
"Apikey": "YOUR-API-KEY-HERE"
},
"processData": false,
"mimeType": "multipart/form-data",
"contentType": false,
"data": form
};
$.ajax(settings).done(function (response) {
console.log(response);
});

For larger files, the process may take several minutes, but your new WEBM video will be delivered by the end of it! Much easier than an a manual conversion, don’t you think?

--

--

Cloudmersive

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