Programmable Media

Trim videos in Node.js (video tutorial)

Last updated: Sep-12-2024

Overview

This video tutorial teaches you how to trim videos on the fly using the Cloudinary Node.js SDK.

Video tutorial


View the code
You can find the code from this tutorial in GitHub.

Tutorial contents

This tutorial presents the following topics. Click a timestamp to jump to that part of the video.

Introduction

Jump to this spot in the video  0:00 If you want to remove the start or end of a video, you can use Cloudinary's video transformation capabilities to do this on the fly.

Define the length of your video

Jump to this spot in the video  0:23 Having installed and configured the Cloudinary Node.js SDK in your Node.js app, define the start offset and either the end offset or duration of the video that you want to deliver. Ensure you use the variable names start_offset, end_offset and duration as these are the object key names that you need in the next step, which uses object property shorthand notation.

Create the URL to trim the video

Jump to this spot in the video  0:38 Use the cloudinary.url method to create the URL to deliver the trimmed video according to the set parameters. Specify the public ID of the video that you've previously uploaded to your Cloudinary product environment, the resource type and transformation parameters. For example, to trim the samples/elephants video to make it start at 6.5 seconds and end at 20 seconds:

See the full code example in GitHub.

Check the resulting URL

Jump to this spot in the video  1:27 Open the resulting URL in a browser to see the trimmed elephants video.

Keep learning

Related topics

If you like this, you might also like...

Upload Videos in Node.js
Upload videos to Cloudinary using the Node.js SDK
Video Transformations
Build an e-commerce video showcasing products, in Node.js
Splice Videos in Node.js
Splice two videos together using the Node.js SDK

 

Cloudinary Academy

 

Check out the Cloudinary Academy for free self-paced Cloudinary courses on a variety of developer or DAM topics, or register for formal instructor-led courses, either virtual or on-site.

 

✔️ Feedback sent!

Rate this page: