import os
from gcore import Gcore
client = Gcore(
api_key=os.environ.get("GCORE_API_KEY"), # This is the default and can be omitted
)
clips = client.streaming.streams.clips.list(
0,
)
print(clips)package main
import (
"context"
"fmt"
"github.com/G-Core/gcore-go"
"github.com/G-Core/gcore-go/option"
)
func main() {
client := gcore.NewClient(
option.WithAPIKey("My API Key"),
)
clips, err := client.Streaming.Streams.Clips.List(context.TODO(), 0)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", clips)
}
curl --request GET \
--url https://api.gcore.com/streaming/streams/{stream_id}/clip_recording \
--header 'Authorization: <api-key>'const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://api.gcore.com/streaming/streams/{stream_id}/clip_recording', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gcore.com/streaming/streams/{stream_id}/clip_recording",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.get("https://api.gcore.com/streaming/streams/{stream_id}/clip_recording")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/streaming/streams/{stream_id}/clip_recording")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body[
{
"id": "d7bsli54p8n4",
"created_at": "2024-01-05T20:15:00.000Z",
"vod_required": true,
"video_id": 459857,
"renditions": [
"media_1_360",
"media_2_468",
"media_3_720",
"media_4_1080"
],
"hls_master": "https://CID.domain.com/rec/12345_330031/rec_d7bsli54p8n4_qsid42_master.m3u8",
"mp4_master": "https://CID.domain.com/rec/12345_330031/rec_d7bsli54p8n4_qsid42_master.mp4",
"start": 1716559200,
"duration": 60,
"expiration": 1716562860
}
]{
"error": "Couldn't find Video with 'id'=100"
}Get clips
Get list of non expired instant clips for a stream.
You can now use both MP4 just-in-time packager and HLS for all clips. Get URLs from “hls_master” and “mp4_master”.
How to download renditions of clips:
URLs contain “master” alias by default, which means maximum available quality from ABR set (based on height metadata). There is also possibility to access individual bitrates from ABR ladder. That works for both HLS and MP4. You can replace manually “master” to a value from renditions list in order to get exact bitrate/quality from the set. Example:
- HLS 720p:
https://CID.domain.com/rec/111_1000/rec_d7bsli54p8n4_qsid42_master.m3u8 - HLS 720p:
https://CID.domain.com/rec/111_1000/rec_d7bsli54p8n4_qsid42_media_1_360.m3u8 - MP4 360p:
https://CID.domain.com/rec/111_1000/rec_d7bsli54p8n4_qsid42_master.mp4 - MP4 360p:
https://CID.domain.com/rec/111_1000/rec_d7bsli54p8n4_qsid42_media_1_360.mp4
import os
from gcore import Gcore
client = Gcore(
api_key=os.environ.get("GCORE_API_KEY"), # This is the default and can be omitted
)
clips = client.streaming.streams.clips.list(
0,
)
print(clips)package main
import (
"context"
"fmt"
"github.com/G-Core/gcore-go"
"github.com/G-Core/gcore-go/option"
)
func main() {
client := gcore.NewClient(
option.WithAPIKey("My API Key"),
)
clips, err := client.Streaming.Streams.Clips.List(context.TODO(), 0)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", clips)
}
curl --request GET \
--url https://api.gcore.com/streaming/streams/{stream_id}/clip_recording \
--header 'Authorization: <api-key>'const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://api.gcore.com/streaming/streams/{stream_id}/clip_recording', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.gcore.com/streaming/streams/{stream_id}/clip_recording",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.get("https://api.gcore.com/streaming/streams/{stream_id}/clip_recording")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.gcore.com/streaming/streams/{stream_id}/clip_recording")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body[
{
"id": "d7bsli54p8n4",
"created_at": "2024-01-05T20:15:00.000Z",
"vod_required": true,
"video_id": 459857,
"renditions": [
"media_1_360",
"media_2_468",
"media_3_720",
"media_4_1080"
],
"hls_master": "https://CID.domain.com/rec/12345_330031/rec_d7bsli54p8n4_qsid42_master.m3u8",
"mp4_master": "https://CID.domain.com/rec/12345_330031/rec_d7bsli54p8n4_qsid42_master.mp4",
"start": 1716559200,
"duration": 60,
"expiration": 1716562860
}
]{
"error": "Couldn't find Video with 'id'=100"
}Authorizations
Response
Successful
Requested segment duration in seconds to be cut.
Please, note that cutting is based on the idea of instantly creating a clip, instead of precise timing. So final segment may be:
- Less than the specified value if there is less data in the DVR than the requested segment.
- Greater than the specified value, because segment is aligned to the first and last key frames of already stored fragment in DVR, this way -1 and +1 chunks can be added to left and right.
Duration of cut segment cannot be greater than DVR duration for this stream. Therefore, to change the maximum, use "dvr_duration" parameter of this stream.
Link to MP4 with immediate clip. The link points to max rendition quality. Request of the URL can return:
- 200 OK – if the clip exists.
- 404 Not found – if the clip did not exist or has already ceased to exist.
- 425 Too early – if recording is on-going now. The file is incomplete and will be accessible after start+duration time will come.
Starting point of the segment to cut.
Unix timestamp in seconds, absolute value.
Example: 24.05.2024 14:00:00 (GMT) is Unix timestamp = 1716559200
If a value from the past is specified, it is used as the starting point for the segment to cut. If the value is omitted, then clip will start from now.
Expire time of the clip via a public link.
Unix timestamp in seconds, absolute value.
This is the time how long the instant clip will be stored in the server memory and can be accessed via public HLS/MP4 links. Download and/or use the instant clip before this time expires.
After the time has expired, the clip is deleted from memory and is no longer available via the link. You need to create a new segment, or use vod_required: true attribute.
If value is omitted, then expiration is counted as +3600 seconds (1 hour) to the end of the clip (i.e. unix timestamp = <start> + <duration> + 3600).
Allowed range: 1m <= expiration <= 4h.
Example: 24.05.2024 14:00:00 (GMT) + 60 seconds of duration + 3600 seconds of expiration = 24.05.2024 15:01:00 (GMT) is Unix timestamp = 1716562860
Was this page helpful?