Stop a live stream
To Stop a live stream you need to send an HTTP POST request to the API Endpoint, with the authentication Header.
https://app.tpstreams.com/api/v1/<organization_id>/assets/<str:asset_id>/stop_live_stream/
This will stop the specified live stream
For valid requests the API server returns a JSON:
{
"message": "Live stream stopped successfully",
"trim_scheduled": false
}
Schedule Trim After Live Stream
You can optionally add trim parameters to the stop API request body to schedule a trim operation that will be executed after the live stream recording is completed and transcoded. This allows you to trim the recorded video directly when stopping the live stream.
Fields for Trim Scheduling
| Name | Type | Description | Required |
|---|---|---|---|
| start_time | integer | Start time for trim. Can be either relative seconds from the beginning of the recording or epoch timestamp | Yes (for trim) |
| end_time | integer | End time for trim. Can be either relative seconds from the beginning of the recording or epoch timestamp | Yes (for trim) |
Timestamp Formats
You can specify trim times using either of the following formats:
- Relative Seconds: Time in seconds from the beginning of the recording
- Epoch Timestamps: Unix timestamps
- Both
start_timeandend_timemust use the same format (either relative seconds or epoch timestamps). - Mixing formats in a single request is not allowed
Sample request body with relative seconds
{
"start_time": 30,
"end_time": 120
}
Sample request body with epoch timestamps
{
"start_time": 1736754600,
"end_time": 1736754900
}
When scheduling a trim:
- Both
start_timeandend_timeare required - Both must be non-negative integers
start_timemust be less thanend_timeend_timecannot exceed the total duration of the live stream recording- The trim operation will be executed automatically after transcoding completes
Response with trim scheduled
{
"message": "Live stream stopped successfully",
"trim_scheduled": true
}
If the value of the parameter "transcode_recorded_video" is set to true, you will receive the video object in the webhook response.
Sample webhook response is as follows
{
"title": "Data science Live class",
"bytes": null,
"type": "livestream",
"video": {
"progress": 0,
"thumbnails": [],
"status": "Completed",
"playback_url": "https://d7pdowhru2wq4.cloudfront.net/transcoded/9328558d-e0a5-4093-b3b9-8f15ad1550d8/video.m3u8",
"dash_url": "https://d7pdowhru2wq4.cloudfront.net/transcoded/9328558d-e0a5-4093-b3b9-8f15ad1550d8/video.mpd",
"preview_thumbnail_url": null,
"format": "abr",
"resolutions": ["240p", "360p", "480p", "720p"],
"video_codec": "h264",
"audio_codec": "aac",
"enable_drm_for_recording": true,
"tracks": [],
"inputs": [
{
"url": "https://static.testpress.in/Data_science_Live_class.mp4"
}
],
},
"id": "4PtERT9d9uK",
"live_stream": {
"rtmp_url": "rtmp://23.427.127.24/live",
"stream_key": "org-4xu8ay-live-4PtERT9d9uK-jKP4",
"status": "Completed",
"hls_url": "https://d28qihy7z761lk.cloudfront.net/live/4xu8ay/4PtERT9d9uK/video.m3u8",
"start": null,
"transcode_recorded_video": true,
"chat_embed_url":"https://app.tpstreams.com/live-chat/4PtERT9d9uK/"
},
"parent_id": null
}