Instant Video Clipping
Clip and download live stream segments as MP4 with the Instant Video Clipping API.
Overview
With Castr's Instant Video Clipping API, you have the power to seamlessly extract specific segments from your live stream recordings and download them directly as MP4 files. This feature allows for capturing the last few minutes of a live stream and enables the creation and download of video clips for immediate use or archival purposes.
Enabling Stream Recording
Before utilizing the clipping feature, ensure that cloud recording is enabled for your stream. This is controlled via the cloud_recording parameter during stream creation or update.
Sample Request to Enable Recording
curl --request POST \
--url https://api.castr.com/v2/live_streams \
--header 'accept: application/json' \
--header 'authorization: {your_authentication}' \
--header 'content-type: application/json' \
--data '{
"settings": {
"abr": false,
"cloud_recording": true
},
"name": "My Live Event",
"enabled": true
}'
To disable recording for an existing stream, you can update the stream with "cloud_recording": false
.
Once cloud recording is enabled, recordings are stored temporarily for 72 hours, allowing you to clip any segment from the last three days.
Sample Request
curl --request GET
--url https://api.castr.com/v2/live_streams/{stream_id}/temporary_recordings \
--header 'accept: application/json'
--header 'authorization: {your_authentication}'
Sample Response
[
{
"_id": "65354c2524f23b7c0f855627",
"stream_key": "live_d24df56030e211ed998b63dd43698e32",
"start_time": "2023-10-20T20:13:52.000Z",
"end_time": "2023-10-22T16:21:50.000Z",
"duration": 158878,
"download_url": "https://eu-storage-1.castr.io/archives/edge/5b2e1c65f1e043163435d4e9/live_d24df56030e211ed998b63dd43698e32/archive-1697832832-158878.mp4"
}
]
Downloading Specific Segments
To download a specific segment, you'll need the download_url
from the temporary recordings API. Determine the segment you wish to download by specifying the start and end times.
For example, to download the last 5 minutes of a recording:
- Obtain the
end_time
from your desired recording. - Calculate the start time by subtracting 300 seconds (5 minutes) from the
end_time
. - Use the modified URL format below, replacing
{{start_time}}
and{{duration}}
with your calculated values.
https://server-1.castr.io/archives/edge/5b2e1c65f1e043163435d4e9/live_d24df56030e211ed998b63dd43698e32/archive-{{start_time}}-{{duration}}.mp4
Note: The duration is specified in seconds.
What’s Next?
After downloading the desired video segments, integrate them into your content strategy as VOD assets, share them on social media, or use them for content marketing. Explore further API features to enhance your live streaming and video management capabilities.
Updated 9 months ago