You can simultaneously stream backup live video data to a live video broadcast. If your primary stream fails, we will automatically switch to your backup stream so your live video broadcast can continue uninterrupted. Your broadcast will continue using the backup stream unless you manually switch back to the primary stream, or your primary stream has resumed and your backup stream fails.
In order to use a backup stream with a live video broadcast, you must enable backup streaming when you create the broadcast's LiveVideo object, or enable it on the LiveVideo object before it receives streaming data.
To enable backup streaming when you create your broadcast's LiveVideo object, include the enable_backup_ingest=true
query string parameter in your query.
For example, to create a LiveVideo with backup streaming enabled on a User:
POST /{user-id}/live_videos ?status=LIVE_NOW &enable_backup_ingest=true &access_token={access-token}
This will return two URLs, one for your primary stream, and one for you backup (secondary):
{ "id": "{live-video-id}", "stream_url": "{stream-url}", "secure_stream_url": "{secure-stream-url}", "stream_secondary_urls": [ "{stream-secondary-urls}" ], "secure_stream_secondary_urls": [ "{secure-stream-secondary-urls}" ] }
Use secure_stream_url
for your primary ingest stream and secure_stream_secondary_urls
for your backup ingest stream. You can stream backup data to your LiveVideo object at any time during the broadcast.
curl -i -X POST \ "https://graph.facebook.com/362629830945302/live_videos ?enable_backup_ingest=true &access_token=EAAI4b..."
{ "id": "10215840463339953", "stream_url": "rtmps://rtmp.facebook.com/rtmp/10215840463339953?s_bl=1&s_l=1&s_sml=3&s_sw=0&s_vt=api&a=AbxMhT-cq73GTdpuPLo", "secure_stream_url": "rtmps://rtmp.facebook.com/rtmp/10215840463339953?s_bl=1&s_l=1&s_sml=3&s_sw=0&s_vt=api&a=AbxMhT-cq73GTdpuPLo", "stream_secondary_urls": [ "rtmp://rtmps.facebook.com/rtmp/10215840463339953?s_bl=1&s_l=1&s_sml=3&s_sw=1&s_vt=api&a=AbzhD2fKJw1Uw7JQjFc" ], "secure_stream_secondary_urls": [ "rtmps://rtmps.facebook.com/rtmp/10215840463339953?s_bl=1&s_l=1&s_sml=3&s_sw=1&s_vt=api&a=AbzhD2fKJw1Uw7JQF80" ] }
You can enable backup streaming on an existing LiveVideo object as long as it has not received any live video streaming data by sending a POST
request to the LiveVideo’s /input_streams
edge. For example:
POST /{live-video-id}/input_streams &access_token={access-token}
This will return the LiveVideo’s ID:
{ "id": "{live-video-id}" }
Once enabled, you can [get the primary and backup stream URLs] from the LiveVideo object.
curl -i -X POST \ "https://graph.facebook.com/10215840463339953/input_streams &access_token=EAAI4b..."
{ "id": "10215840463339953" }
You can manually switch between a LiveVideo’s primary and backup stream by sending a request to:
POST /{live-video-id} ?master_ingest_stream_id={master-ingest-stream-id} &access_token={access-token}
The {master-ingest-stream-id}
value is a boolean; 0
represents the primary ingest stream, and 1
represents the backup ingest stream.
curl -i -X POST \ "https://graph.facebook.com/10215840463339953 ?master_ingest_stream_id=1 &access_token=EAAI4b..."
You can read a LiveVideo’s ingest_streams
field to get its primary and backup stream URLs:
GET /{live-video-id} ?fields=ingest_streams &acess_token={access-token}
This will return the ingest stream health and stream URLs for the primary and backup streams (if any) on the LiveVideo:
{ "ingest_streams": [ { "stream_id": "{stream-id}", "stream_url": "{stream-url}", "secure_stream_url": "{secure-stream-url}", "is_master": {is-master}, "stream_health": {stream-health}, "id": "{id}" }, { "stream_id": "{stream-id}", "stream_url": "{stream-url}", "secure_stream_url": "{secure-stream-url}", "is_master": {is-master}, "stream_health": {stream-health}, "id": "{id}" } ], "id": "10215840874550233" }
curl -i -X GET \ "https://graph.facebook.com/10215840463339953 ?fields=ingest_streams &access_token=EAAI4b..."
{ "ingest_streams": [ { "stream_id": "0", "stream_url": "rtmps://live-api.facebook.com/rtmp/10215840874550233?s_bl=1&s_l=1&s_sml=3&s_sw=0&s_vt=api&a=AbyvsHKGRrur_sZOeuo", "secure_stream_url": "rtmps://live-api.facebook.com/rtmp/10215840874550233?s_bl=1&s_l=1&s_sml=3&s_sw=0&s_vt=api&a=AbyvsHKGRrur_sZOF08", "is_master": true, "stream_health": { "video_bitrate": 2304481.75, "video_framerate": 27.586206436157, "video_gop_size": 2000, "video_height": 700, "video_width": 1120, "audio_bitrate": 118149.8828125 }, "id": "10215840874630235" }, { "stream_id": "1", "stream_url": "rtmps://live-api.facebook.com/rtmp/10215840874550233?s_bl=1&s_l=1&s_sml=3&s_sw=1&s_vt=api_dev&a=AbySai39Wr08FKpUYw0", "secure_stream_url": "rtmps://live-api.facebook.com/rtmp/10215840874550233?s_bl=1&s_l=1&s_sml=3&s_sw=1&s_vt=api_dev&a=AbySai39Wr08FKpUv3M", "is_master": false, "stream_health": { "video_bitrate": 1866942.625, "video_framerate": 22.338048934937, "video_gop_size": 2000, "video_height": 700, "video_width": 1120, "audio_bitrate": 95675.3515625 }, "id": "10215840874670236" } ], "id": "10215840874550233" }