How to Convert a Video to MP4 in Node.JS

npm install cloudmersive-video-api-client --save
"dependencies": {
"cloudmersive-video-api-client": "^2.0.1"
}
var CloudmersiveVideoApiClient = require('cloudmersive-video-api-client');
var defaultClient = CloudmersiveVideoApiClient.ApiClient.instance;
// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';
var apiInstance = new CloudmersiveVideoApiClient.VideoApi();var opts = {
'inputFile': Buffer.from(fs.readFileSync("C:\\temp\\inputfile").buffer), // File | Input file to perform the operation on.
'fileUrl': "fileUrl_example", // String | Optional; URL of a video file being used for conversion. Use this option for files larger than 2GB.
'maxWidth': 56, // Number | Optional; Maximum width of the output video, up to the original video width. Defaults to original video width.
'maxHeight': 56, // Number | Optional; Maximum height of the output video, up to the original video width. Defaults to original video height.
'preserveAspectRatio': true, // Boolean | Optional; If false, the original video's aspect ratio will not be preserved, allowing customization of the aspect ratio using maxWidth and maxHeight, potentially skewing the video. Default is true.
'frameRate': 56, // Number | Optional; Specify the frame rate of the output video. Defaults to original video frame rate.
'quality': 56 // Number | Optional; Specify the quality of the output video, where 100 is lossless and 1 is the lowest possible quality with highest compression. Default is 50.
};
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.videoConvertToMp4(opts, callback);

--

--

--

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

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Node.js for Beginners: How to Get Started

🚀 How to bootstrap a Next.js + Tailwind CSS + TypeScript project

Automatically Organize Imports in Visual Studio Code

Switch to Ant.Design

Service workers in Depth.

What is react Profiler API

JavaScript, Tricks with Reduce

Find the repeated number in array size of n and all elements are from 1 to n with one element…

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

Cloudmersive

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

More from Medium

Introduction to Node.js, Koa.js and REST Services

How to Install KeyCloak 17 on Windows Machine

OCR Preprocessing API: Detect and Unskew a Photo of a Document with JavaScript

Basic “ Hello World ” Node.js and Express app