> ## Documentation Index
> Fetch the complete documentation index at: https://cloudinary.com/documentation/llms.txt
> Use this file to discover all available pages before exploring further.

# Video trimming


Use Cloudinary's video trimming options to keep a specific part of a video or audio clip. To join assets after trimming, see [Video concatenation](video_concatenation).

## Trimming videos

Trim a video (and discard the rest) by using a combination of the following 3 parameters to specify the section of video to keep after trimming:

* `start_offset` (`so` in URLs) specifies the start.
* `end_offset` (`eo` in URLs) specifies the end.
* `duration` (`du` in URLs) specifies the duration.

Possible values:

* A float representing the time in seconds e.g. `5.44` (5 seconds and 440 milliseconds).
* A string representing the percentage of the video length. This string consists of a number with a `p` appended e.g. `35p` (0p is the first frame and 100p is the last frame). The client libraries also support appending a `%` instead of a `p`.

**Examples**:

  1. Trimming the video to the section that starts at 6.5 seconds and ends at 10 seconds:

    ![Trimming to the section of 6.5s - 10s](https://res.cloudinary.com/demo/video/upload/eo_10,so_6.5/paradise_location.mp4 "thumb: w_500")

```nodejs
cloudinary.video("paradise_location", {end_offset: "10", start_offset: "6.5"})
```

```react
import { trim } from "@cloudinary/url-gen/actions/videoEdit";

new CloudinaryVideo("paradise_location.mp4").videoEdit(
  trim().startOffset(6.5).endOffset("10.0")
);
```

```vue
import { trim } from "@cloudinary/url-gen/actions/videoEdit";

new CloudinaryVideo("paradise_location.mp4").videoEdit(
  trim().startOffset(6.5).endOffset("10.0")
);
```

```angular
import { trim } from "@cloudinary/url-gen/actions/videoEdit";

new CloudinaryVideo("paradise_location.mp4").videoEdit(
  trim().startOffset(6.5).endOffset("10.0")
);
```

```js
import { trim } from "@cloudinary/url-gen/actions/videoEdit";

new CloudinaryVideo("paradise_location.mp4").videoEdit(
  trim().startOffset(6.5).endOffset("10.0")
);
```

```python
CloudinaryVideo("paradise_location").video(end_offset="10", start_offset="6.5")
```

```php
use Cloudinary\Transformation\VideoEdit;

(new VideoTag('paradise_location.mp4'))
	->videoEdit(VideoEdit::trim()->startOffset(6.5)
->endOffset(10.0));
```

```java
cloudinary.url().transformation(new Transformation().endOffset("10").startOffset("6.5")).videoTag("paradise_location");
```

```ruby
cl_video_tag("paradise_location", end_offset: "10", start_offset: "6.5")
```

```csharp
cloudinary.Api.UrlVideoUp.Transform(new Transformation().EndOffset("10").StartOffset("6.5")).BuildVideoTag("paradise_location")
```

```dart
cloudinary.video('paradise_location.mp4').transformation(Transformation()
	.videoEdit(VideoEdit.trim().startOffset(6.5)
.endOffset('10.0')));
```

```swift
cloudinary.createUrl().setResourceType("video").setTransformation(CLDTransformation().setEndOffset("10").setStartOffset("6.5")).generate("paradise_location.mp4")
```

```android
MediaManager.get().url().transformation(new Transformation().endOffset("10").startOffset("6.5")).resourceType("video").generate("paradise_location.mp4");
```

```flutter
cloudinary.video('paradise_location.mp4').transformation(Transformation()
	.videoEdit(VideoEdit.trim().startOffset(6.5)
.endOffset('10.0')));
```

```kotlin
cloudinary.video {
	publicId("paradise_location.mp4")
	 videoEdit(VideoEdit.trim() { startOffset(6.5F)
 endOffset(10.0F) }) 
}.generate()
```

```jquery
$.cloudinary.video("paradise_location", {end_offset: "10", start_offset: "6.5"})
```

```react_native
import { trim } from "@cloudinary/url-gen/actions/videoEdit";

new CloudinaryVideo("paradise_location.mp4").videoEdit(
  trim().startOffset(6.5).endOffset("10.0")
);
```

  2. Trimming the video to the section that starts 10 percent into the original video and then lasts a duration of 30 percent (effectively from the 10 percent mark to the 40 percent mark):

    ![Trimming to the section starting at 10% with 30% duration](https://res.cloudinary.com/demo/video/upload/du_30p,so_10p/paradise_location.mp4 "thumb: w_500")

```nodejs
cloudinary.video("paradise_location", {duration: "30p", start_offset: "10p"})
```

```react
import { trim } from "@cloudinary/url-gen/actions/videoEdit";

new CloudinaryVideo("paradise_location.mp4").videoEdit(
  trim().startOffset("10%").duration("30%")
);
```

```vue
import { trim } from "@cloudinary/url-gen/actions/videoEdit";

new CloudinaryVideo("paradise_location.mp4").videoEdit(
  trim().startOffset("10%").duration("30%")
);
```

```angular
import { trim } from "@cloudinary/url-gen/actions/videoEdit";

new CloudinaryVideo("paradise_location.mp4").videoEdit(
  trim().startOffset("10%").duration("30%")
);
```

```js
import { trim } from "@cloudinary/url-gen/actions/videoEdit";

new CloudinaryVideo("paradise_location.mp4").videoEdit(
  trim().startOffset("10%").duration("30%")
);
```

```python
CloudinaryVideo("paradise_location").video(duration="30p", start_offset="10p")
```

```php
use Cloudinary\Transformation\VideoEdit;

(new VideoTag('paradise_location.mp4'))
	->videoEdit(VideoEdit::trim()->startOffset("10%")
->duration("30%"));
```

```java
cloudinary.url().transformation(new Transformation().duration("30p").startOffset("10p")).videoTag("paradise_location");
```

```ruby
cl_video_tag("paradise_location", duration: "30p", start_offset: "10p")
```

```csharp
cloudinary.Api.UrlVideoUp.Transform(new Transformation().Duration("30p").StartOffset("10p")).BuildVideoTag("paradise_location")
```

```dart
cloudinary.video('paradise_location.mp4').transformation(Transformation()
	.videoEdit(VideoEdit.trim().startOffset("10%")
.duration("30%")));
```

```swift
cloudinary.createUrl().setResourceType("video").setTransformation(CLDTransformation().setDuration("30p").setStartOffset("10p")).generate("paradise_location.mp4")
```

```android
MediaManager.get().url().transformation(new Transformation().duration("30p").startOffset("10p")).resourceType("video").generate("paradise_location.mp4");
```

```flutter
cloudinary.video('paradise_location.mp4').transformation(Transformation()
	.videoEdit(VideoEdit.trim().startOffset("10%")
.duration("30%")));
```

```kotlin
cloudinary.video {
	publicId("paradise_location.mp4")
	 videoEdit(VideoEdit.trim() { startOffset("10%")
 duration("30%") }) 
}.generate()
```

```jquery
$.cloudinary.video("paradise_location", {duration: "30p", start_offset: "10p"})
```

```react_native
import { trim } from "@cloudinary/url-gen/actions/videoEdit";

new CloudinaryVideo("paradise_location.mp4").videoEdit(
  trim().startOffset("10%").duration("30%")
);
```

> **TIP**: If you want a video to play at a certain position but not trim the rest of the video out, use the HTML5 `#t` parameter in the video source.

For example, this URL starts playback of the `docs/bathroom` video at 4.5 seconds and stops it again at 10 seconds:

Copy to clipboardhttps://res.cloudinary.com/demo/video/upload/docs/bathroom.mp4#t=4.5,10

**Try it out**: [Video trimming](https://console.cloudinary.com/app/image/home/video-trim?media=video&back_url=https%3A%2F%2Fconsole.cloudinary.com%2Fvideo%2Fhome&sample=me%2Fpreview-coffee.mp4&startOffset=10&endOffset=20&duration=10&activeOffset=start).


## Video tutorial: Trim videos using the Node.js SDK

Watch this video tutorial to learn how to trim your videos using the [Node.js SDK](node_integration):

  This video is brought to you by Cloudinary's video player - embed your own!Use the controls to set the playback speed, navigate to chapters of interest and select subtitles in your preferred language.
{videoTranscript:publicId=training/Trimming_Videos_Node}

### Tutorial contents This tutorial presents the following topics. Click a timestamp to jump to that part of the video.
### Introduction
{table:class=tutorial-bullets}|  | 
| --- | --- |
|{videotime:id=media :min=0 :sec=00 :player=cld} | If you want to remove the start or end of a video, you can use Cloudinary's [video transformation capabilities](video_trimming#trimming_videos) to do this on the fly.
|

### Define the length of your video
{table:class=tutorial-bullets}|  | 
| --- | --- |
|{videotime:id=media :min=0 :sec=23 :player=cld} | Having [installed and configured the Cloudinary Node.js SDK](node_configuration_tutorial) 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
{table:class=tutorial-bullets}|  | 
| --- | --- |
|{videotime:id=media :min=0 :sec=38 :player=cld} | 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](upload_images) 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:
|

```nodejs
const start_offset = 6.5;
const end_offset = 20;

const videoUrl = cloudinary.url('samples/elephants.mp4', {
  resource_type: 'video',
  transformation: [
    {
      start_offset, 
      end_offset,
    },
  ],
});
```

See the full code example in [GitHub](https://github.com/cloudinary-community/cloudinary-examples/blob/main/examples/node-transformations-effects/video-trim.js).

### Check the resulting URL
{table:class=tutorial-bullets}|  | 
| --- | --- |
|{videotime:id=media :min=1 :sec=27 :player=cld} | Open the resulting URL in a browser to see the trimmed elephants video.
|

## Related topics

* [Video trimming and concatenating](video_trimming_and_concatenating)
* [Video concatenation](video_concatenation)
* [Video transition effects](video_transition_effects)
* [Video resizing and cropping](video_resizing_and_cropping)
* [Video layers](video_layers)

