Stream Recordings

How to get your live stream recordings from Castr via API

Overview

Managing your stream recordings is seamless with Castr's API. You have the flexibility to enable or disable stream recording as needed.


Enabling and Disabling Stream Recording

To control stream recording, set the cloud_recording parameter during the stream creation or updating process. Setting it to true will enable recording, while false will disable it.

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.


Enabling cloud recording will store the stream temporarily for three days. To extend this storage duration, you must convert it into a VOD.

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"  
  }  
]  

To preserve a temporary recording for a longer period, you can convert it into a Video on Demand (VOD) asset. To do this, you'll need both the streamID and recordingID.

Flexibility in Exporting

Castr's export functionality offers the flexibility to export a specific portion of your recording. You'll need to specify the starting timestamp (from) and the duration from that timestamp to the end time (duration). For example, to export just the first hour of the recording, you can set the duration parameter to 3600 seconds.

Sample Request

curl --request POST \
     --url https://api.castr.com/v2/live_streams/{stream_id}/temporary_recordings/{recording_id} \
     --header 'accept: application/json' \
     --header 'authorization: {your_authentication}' \
     --header 'content-type: application/json' \
     --data '{
       "from": "2023-10-20T20:13:52.000Z",
       "duration": 3600
     }'

Sample Response

{
  "success": true
}

Note: Replace {stream_id} and {recording_id} with the respective IDs for your specific use case.

To fetch all the permanent recordings associated with a specific live stream, you can make use of the following API endpoint. This enables you to manage your archived content seamlessly.

Sample Request

curl --request GET \
     --url https://api.castr.com/v2/live_streams/{stream_id}/recordings \
     --header 'accept: application/json' \
     --header 'authorization: {your_authentication}'

Sample Response

[
  {
    "videoFolderId": "64978d596003d19d6b47ddcd",
    "id": "archive-1697832832-3600.mp4",
    "name": "20/10/2023_ranged_3600s",
    "from": 1697832832,
    "duration": 3600,
    "bytes": 1468459,
    "abr": false,
    "status": "EXPORTED",
    "creationTime": "2023-10-22T16:27:36.210Z",
    "playback": {
      "embed_url": "https://player.castr.com/live_d24df56030e211ed998b63dd43698e32?range=1697832832-3600&abr=false&namedHls=true"
    }
  }
]

Note: Replace {stream_id} with the ID of the stream you're interested in for your specific use case.