How to Split a Video into Shorter Clips in Node.JS

Long-form video is a great tool to share large quantities of information and entertainment with clients and associates. However, when taking a targeted approach to those objectives, the user-friendly option would be cutting your video into shorter length clips. This makes your information easier to find and allows the viewer to pick and choose the video they find more pertinent. As shown below, this Cloudmersive API will allow you to split a video into two shorter videos for ease of use

Image for post
Image for post

First, run install for our client software:

npm install cloudmersive-video-api-client --save

Or, add this snippet to your package.json:

"dependencies": {
"cloudmersive-video-api-client": "^2.0.1"

Then, you can call our function, VideoSplitVideo:

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 splitTime = new Date("2013-10-20T19:20:30+01:00"); // Date | Specify the desired time at which to split the video in TimeSpan format.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.
'timeSpan': new Date("2013-10-20T19:20:30+01:00") // Date | Optional; Specify the desired length of the second video in TimeSpan format. Leave blank to include the rest of the video. Maximum time is 4 hours.
var callback = function(error, data, response) {
if (error) {
} else {
console.log('API called successfully. Returned data: ' + data);
apiInstance.videoSplitVideo(splitTime, opts, callback);

Your API Key can be retrieved from the Cloudmersive website and will allow you to perform up to 800 calls across any of our APIs. With this API, you can ensure that you are providing your clients and associates with everything they need in a user-friendly way!

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