Guides: How to clip your videos with the Mux API

0:00

Hey, I'm Dave with Mux, and in this video you'll learn how to

0:03

create shorter clips of videos that exist in your Mux library

0:07

using only the Mux Video API.

0:10

Let me show you a basic example of how this works.

0:13

I have this existing video in my Mux dashboard.

0:17

In the beginning of this video has a couple of artifacts

0:21

that I'd like to trim out.

0:22

Maybe I'm shaking my head here a little bit too much

0:25

and there's this part of the webcam software I'm

0:28

using that got captured.

0:29

I don't want that in the final video.

0:31

So I'd really like to start this video probably

0:33

somewhere around 11 seconds.

0:36

We're going to use a tool called Postman in order

0:39

to make the clipping request to the Mux API.

0:42

There's a couple of pieces of information that we're

0:44

going to need in order to make the request.

0:46

First, you're going to need to get your API access

0:49

tokens, which can be found under the settings menu

0:51

in the Mux dashboard.

0:54

You can create a brand new token ID and a token

0:57

secret by clicking on the generate new token button.

1:01

You'll need this access token ID and secret key

1:04

in order to authenticate with your Mux account.

1:06

Keep in mind that the secret key is basically

1:08

a password for your Mux account, so only share it

1:11

with those that you trust.

1:13

Now I'm going to head over to Postman to

1:14

make the API request.

1:16

We're going to get started by creating a brand new request.

1:20

First, we'll set up the authorization settings

1:22

for our request.

1:23

In the username field, paste your access token ID

1:27

and in the password field, paste your secret key.

1:30

Let's verify this is working by sending a quick get

1:32

request to the Mux API.

1:35

We're seeing some results in the response body, so

1:37

it looks like it's working.

1:38

I'm gonna go back to my Mux dashboard, click on Assets,

1:42

and then go to the video that needs to be trimmed.

1:45

Now we need to make sure that we have the Asset ID, which is

1:48

the unique identifier for this video that we're working with.

1:51

To create a new clip from this video, we're going

1:54

to send a POST request to the Assets endpoint.

1:57

In this request, we'll define a payload with

1:59

some specific options set.

2:04

You can see an input array that contains a link to

2:07

the specific Mux asset that we're referencing.

2:10

I'm going to copy the asset ID and then paste

2:12

it right where this placeholder is in the link.

2:15

You can see this link uses a special format

2:17

to reference assets that already exist on Mux.

2:21

Now the start time for this clip is going to be

2:23

right around 11 seconds.

2:26

I want the end time to go through the current end of

2:28

the clip, so I'm not going to set a parameter for that.

2:31

The playback policy will make sure that the video

2:33

can be publicly viewed.

2:35

We're all set here.

2:36

I'm going to go ahead and send this post request off.

2:39

Our response says the new asset is preparing,

2:41

and we also have the ID for the new asset.

2:45

I'm going to go back to my Mux dashboard and view all

2:47

of the assets that exist.

2:49

All right, this is looking good.

2:51

We have a new video created with a shorter duration.

2:54

And if I go into it, I can see that it's starting off

2:57

with a much better intro.

2:59

Hey, I'm Dave with Mux.

3:00

And in this video, that's all there is to it.

3:04

You've created your first clip with the Mux video API.