Learn how to create clips from your video files or live stream event recordings.
Create a clip
Look at the Video API to create a new clip.
Wait for "ready" event
As soon as you POST a video, Mux begins creating the clip from the source asset.
Play your clip
To play your clips, create a playback URL using the PLAYBACK_ID you received when you created the clip.
FAQs
Additional details about clipping.
To drive higher viewer engagement with the videos already on your service, you can create additional videos from your existing library or catalog. These videos could:
Mux can now help you quickly create these kinds of videos using the Clipping functionality.
When you POST a new video or start live streaming, Mux creates a new asset for the video file or live stream event recording.
You can create a clip from an existing asset by making a POST request to /assets endpointAPI and defining the input
object's clipping parameters.
url
is defined with mux://assets/{asset_id}
template where asset_id
is the source Asset Identifier to create the clip from.start_time
is the time offset in seconds from the beginning of the video, indicating the clip's start marker. The default value is 0 when not included.end_time
is the time offset in seconds from the beginning of the video, indicating the clip's end marker. The default value is the duration of the video when not included.A request and response might look something like this:
curl https://api.mux.com/video/v1/assets \
-H "Content-Type: application/json" \
-X POST \
-d '{
"input": [
{
"url": "mux://assets/01itgOBvgjAbES7Inwvu4kEBtsQ44HFL6",
"start_time": 10.0,
"end_time": 51.10
}
],
"playback_policy": [
"public"
]
}' \
-u ${MUX_TOKEN_ID}:${MUX_TOKEN_SECRET}
{
"data": {
"status": "preparing",
"playback_ids": [
{
"policy": "public",
"id": "TXjw00EgPBPS6acv7gBUEJ14PEr5XNWOe"
}
],
"mp4_support": "none",
"master_access": "none",
"id": "kcP3wS3pKcEPywS5zjJk7Q1Clu99SS1O",
"created_at": "1607876845",
"source_asset_id": "01itgOBvgjAbES7Inwvu4kEBtsQ44HFL6"
}
}
Mux creates a new asset for the clip. And the response will include an Asset ID and a Playback ID.
api.mux.com
(e.g. to read or delete an asset).stream.mux.com
. You can add multiple playback IDs to an asset to create playback URLs with different viewing permissions, and you can delete playback IDs to remove access without deleting the asset.source_asset_id
is the video or live stream event recording asset used to create the clip. The source_asset_id
can be useful for associating clips with the source video object in your CMS.When the clip is ready for playback, the asset "status" changes to "ready".
The best way to do this is via webhooks. Mux can send a webhook notification as soon as the asset is ready. See the webhooks guide for details.
If you can't use webhooks for some reason, you can manually poll the asset APIAPI to see asset status. Note that this only works at low volume. Try this example:
curl https://api.mux.com/video/v1/assets/{ASSET_ID} \
-H "Content-Type: application/json" \
-u ${MUX_TOKEN_ID}:${MUX_TOKEN_SECRET}
Please don't poll this API more than once per second.
To play back the video, create a playback URL using the PLAYBACK_ID
you received when you created the clip.
https://stream.mux.com/{PLAYBACK_ID}.m3u8
implementation 'com.google.android.exoplayer:exoplayer-hls:2.X.X'
// Create a player instance.
SimpleExoPlayer player = new SimpleExoPlayer.Builder(context).build();
// Set the media item to be played.
player.setMediaItem(MediaItem.fromUri("https://stream.mux.com/{PLAYBACK_ID}.m3u8"));
// Prepare the player.
player.prepare();
See the playback guide for more information about how to integrate with a video player.
A few commonly asked questions:
Unlimited! Mux creates a new asset for each clip. Hence, there is no limit to how many clips you can create.
Each clip is a new asset and is considered an on-demand video. On-Demand video pricing applies and that includes Encoding, Storage, and Delivery usage.
Mux only allows creating clips from existing videos in your account. That means, clipping specific parameters (start_time
and end_time
) added to Asset CreationAPI are only applicable for input.url
with mux://assets/{asset_id}
format.
Mux copies all the text tracks from the source asset to the new asset created for the clip. Mux also trims the text tracks to match the clip's start and end markers.
Mux copies the captions and watermark image from the source asset to the clips created. If your source asset does not have a watermark image and you want your clipped
asset to have a watermark, pass it through in overlay_settings
. See more details in the watermark guide.
All other fields, such as passthrough
, are not copied over.
Clips must have a duration of at least 500 milliseconds.