Guides: How to clip your videos with the Mux API
Hey, I'm Dave with Mux, and in this video you'll learn how to
create shorter clips of videos that exist in your Mux library
using only the Mux Video API.
Let me show you a basic example of how this works.
I have this existing video in my Mux dashboard.
In the beginning of this video has a couple of artifacts
that I'd like to trim out.
Maybe I'm shaking my head here a little bit too much
and there's this part of the webcam software I'm
using that got captured.
I don't want that in the final video.
So I'd really like to start this video probably
somewhere around 11 seconds.
We're going to use a tool called Postman in order
to make the clipping request to the Mux API.
There's a couple of pieces of information that we're
going to need in order to make the request.
First, you're going to need to get your API access
tokens, which can be found under the settings menu
in the Mux dashboard.
You can create a brand new token ID and a token
secret by clicking on the generate new token button.
You'll need this access token ID and secret key
in order to authenticate with your Mux account.
Keep in mind that the secret key is basically
a password for your Mux account, so only share it
with those that you trust.
Now I'm going to head over to Postman to
make the API request.
We're going to get started by creating a brand new request.
First, we'll set up the authorization settings
for our request.
In the username field, paste your access token ID
and in the password field, paste your secret key.
Let's verify this is working by sending a quick get
request to the Mux API.
We're seeing some results in the response body, so
it looks like it's working.
I'm gonna go back to my Mux dashboard, click on Assets,
and then go to the video that needs to be trimmed.
Now we need to make sure that we have the Asset ID, which is
the unique identifier for this video that we're working with.
To create a new clip from this video, we're going
to send a POST request to the Assets endpoint.
In this request, we'll define a payload with
some specific options set.
You can see an input array that contains a link to
the specific Mux asset that we're referencing.
I'm going to copy the asset ID and then paste
it right where this placeholder is in the link.
You can see this link uses a special format
to reference assets that already exist on Mux.
Now the start time for this clip is going to be
right around 11 seconds.
I want the end time to go through the current end of
the clip, so I'm not going to set a parameter for that.
The playback policy will make sure that the video
can be publicly viewed.
We're all set here.
I'm going to go ahead and send this post request off.
Our response says the new asset is preparing,
and we also have the ID for the new asset.
I'm going to go back to my Mux dashboard and view all
of the assets that exist.
All right, this is looking good.
We have a new video created with a shorter duration.
And if I go into it, I can see that it's starting off
with a much better intro.
Hey, I'm Dave with Mux.
And in this video, that's all there is to it.
You've created your first clip with the Mux video API.