Convert a Video to WEBM in JavaScript

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": "",
"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?

--

--

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
Cloudmersive

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