Send livestream to a multistream target
Overview
Follow this guide if you wish to send your live stream to any multistream targets or 3rd-party platforms such as Facebook, Youtube, or Twitch.
Before you start
You will need access to the following:
-
LiveAPI Access Token: Refer to the Authentication in LiveAPI section to learn how to generate an access token via the LiveAPI dashboard.
-
The server URL and stream key of the multistream target you wish to send your livestream to.
How to send your livestream to 3rd party platforms
Add multistream target to livestream
The first step in the process is to add the defined multistream target to the livestream using the server URL and key of that target. You can do so by calling POST /live_streams/{Livestream ID}/platforms
.
Sample Request
curl --location --request POST 'https://api.liveapi.com/live_streams/6226ce5f31ddbeb3754aa243/platforms' \
--header 'Content-Type: application/json' \
--header 'Authorization: {your_authentication}' \
--data-raw '{
"template": "custom",
"server": "rtmp://a.rtmp.youtube.com/live2",
"key": "debs-4ux2-r565-1sv4-68zh",
"enabled": true
}'
Sample Response
If the request is successful, it'll return the information of the target added.
{
"_id": "6226ce8431ddbeb3754aa249",
"template": "custom",
"enabled": true,
"server": "rtmp://a.rtmp.youtube.com/live2",
"key": "debs-4ux2-r565-1sv4-68zh"
}
When you start the livestream, the stream will be automatically sent to all multistream targets of that livestream. Make sure you have set enabled
to true
for the multistream targets so they can receive the stream signal.
Status of the multistream targets
To know the status of the multistream targets, whether it's online or offline, you can call GET /live_streams/{Livestream id}
, and the status of all platforms is added under broadcasting_status
.
Sample Response - when the multistream target is offline
{
"_id": "6226ce5f31ddbeb3754aa243",
"enabled": true,
"ingest": {
"server": "rtmp://ingest.liveapi.com/static",
"key": "lv_6ccbd6609e9011ecad519393af92c1a1?password=b47020b2"
},
"playback": {
"embed_url": "https://player.liveapi.com/lv_6ccbd6609e9011ecad519393af92c1a1",
"embed_audio_url": "https://player.liveapi.com/lv_6ccbd6609e9011ecad519393af92c1a1?onlyAudio=true",
"hls_url": "https://live.liveapi.com/620e0ba1ce8f11ddde571d1c/lv_6ccbd6609e9011ecad519393af92c1a1/index.m3u8"
},
"platforms": [
{
"_id": "6226ce8431ddbeb3754aa249",
"template": "custom",
"enabled": true,
"server": "rtmp://a.rtmp.youtube.com/live2",
"key": "debs-4ux2-r565-1sv4-68zh",
"broadcasting_status": "offline"
}
],
"settings": {
"pulling_mode": {}
},
"broadcasting_status": "offline",
"user": "620e0ba1ce8f11ddde571d1c",
"environment": "production",
"organization": "620e0ba2ce8f11ddde571d1d",
"creation_time": "2022-03-08T03:32:47.990Z"
}
Sample Response - when the multistream target is online
{
"_id": "6226ce5f31ddbeb3754aa243",
"enabled": true,
"ingest": {
"server": "rtmp://ingest.liveapi.com/static",
"key": "lv_6ccbd6609e9011ecad519393af92c1a1?password=b47020b2"
},
"playback": {
"embed_url": "https://player.liveapi.com/lv_6ccbd6609e9011ecad519393af92c1a1",
"embed_audio_url": "https://player.liveapi.com/lv_6ccbd6609e9011ecad519393af92c1a1?onlyAudio=true",
"hls_url": "https://live.liveapi.com/620e0ba1ce8f11ddde571d1c/lv_6ccbd6609e9011ecad519393af92c1a1/index.m3u8"
},
"platforms": [
{
"_id": "6226ce8431ddbeb3754aa249",
"template": "custom",
"enabled": true,
"server": "rtmp://a.rtmp.youtube.com/live2",
"key": "debs-4ux2-r565-1sv4-68zh",
"broadcasting_status": "online"
}
],
"settings": {
"pulling_mode": {}
},
"broadcasting_status": "online",
"user": "620e0ba1ce8f11ddde571d1c",
"environment": "production",
"organization": "620e0ba2ce8f11ddde571d1d",
"creation_time": "2022-03-08T03:32:47.990Z",
"pull_urls": {
"rtmp": "rtmp://sg-2.liveapi.com/lv_6ccbd6609e9011ecad519393af92c1a1",
"srt": "srt://sg-2.liveapi.com:9998/?streamid=#!::r=lv_6ccbd6609e9011ecad519393af92c1a1,m=request"
},
"thumb_url": "https://sg-2.liveapi.com/lv_6ccbd6609e9011ecad519393af92c1a1/preview.mp4"
}
Pause sending stream to a multistream target
Suppose you wish to pause sending the stream data to a multistream target without having to delete the target entirely, even during live. In that case, you can change the enabled
param of the multistream target to false
using PATCH /live_streams/{id}/platforms/{multistream-id}
.
Delete multistream target
You can call DELETE /live_streams/{livestream-id}/platforms/{multistream-id}
to permanently remove a multistream target out of a specified live stream.
Recommended livestream settings for popular platforms
Check out this page to know more about recommended settings for Facebook, Youtube, etc. Note that any differences to the recommended setting may result in buffering or interrupted streaming.
Webhook supported for Multistream
You can see the list of webhook events that we support for Multistream here.
Updated over 1 year ago