Introduction
You can use Livepeer Studio to create clips of active streams provided via API. Currently, you can create clips from the most recent N seconds of a given stream. You may also clip specific sections of a long-running stream, such as a particular session from a live-streamed conference. This guide offers a comprehensive walkthrough of the clipping functionality.Clipping is currently only supported by livestreams and livestream
recordings. Check back later for further support.
Create a stream
Follow our previous guide on creating a stream to get a stream key to provide to the creator on your platform. They can then start broadcasting to that stream.Create a clip
Clips are created from the perspective of the user who initiates the clip. For
example, if a viewer clips the most recent 30 seconds, it will be the most
recent 30 seconds that they saw.
UNIX timestamp (in milliseconds) of clip’s starts from the browser’s playhead
(commonly supplied by HLS players).
UNIX timestamp (in milliseconds) of clip’s end from the browser’s playhead
(commonly supplied by HLS players).
Active stream’s Playback ID
(Optional) Output clip’s name
Ensure the
startTime aligns with or postdates the stream’s initiation, and
that the endTime isn’t set in the future.API + Player Integration
If you are using HLS.js, it provides an API for getting the program date time,hls.playingDate, which can be used to get the browser’s current playhead. This
returns a Date object which is used similar to:
HLS players typically provide a
Program-Date-Time for each segment when
parsing an HLS manifest. You can utilize Program-Date-Time to create a
clipping user interface (UI) and generate the correct timestamps.Monitor the clip’s status
After calling the clip API, Livepeer generates an asset. You’ll receive the asset’s details in the response.- using the
/api/asset/$ASSET_IDAPI
asset.status field is ready.
- using webhooks
asset.ready
event, you will receive a notification when the clip processing is complete. You
can use the assetId received in the previous response to determine when your
clip is ready.
To determine if an asset you are polling or receiving as an event is a clip, you
can check the source field. If the source field contains a clip type and
the relative session ID, then it is indeed a clip.
You can always fetch clips by stream using the
Clips for Livestream API:
Clips offer source playback just like other assets. On completion, a transcode
job is triggered. Even before this job concludes, the source playback becomes
available. The
playbackUrl field in the asset gets populated when the
playback is ready, and the sourcePlayback field is set to true.