Exploring Live Video

Even if you're unfamiliar with using the Graph API, there are still many ways to go live on Facebook. From using publisher tools to creating unlimited live streams, you can have engaging conversations with your followers and interact with viewers in real time.

If you want to get started with the Live API check our our Quick Start Guide. If you want to create highly customized streams, read our How To Guide on streaming production-quality broadcasts.

Below are some of our newer available features:

Go Live Dialog

Our Live API allows you to create an incredible, customized live experience. We want to make the process of integrating with the Live API as easy as possible, so we've created a plugin that simplifies the process by enabling you to authenticate with Facebook, then preview and describe your live stream through a pop-up window before going live. This dialog is best suited for those streaming from the client side. Backend integrations should continue to use the API directly.

Note: If your page is associated with a Business Manager account, you will need to use the Publisher Tools UI to post a live video.

First, follow these instructions to initialize the Facebook SDK for Javascript in either a browser (website) or WebView (desktop app).

Then, call the following code to initialize a pop-up window with controls that determine where to direct your POST request.

<button id="liveButton">Create Live Stream To Facebook</button>
<script>
document.getElementById('liveButton').onclick = function() {
  FB.ui({
    display: 'popup',
    method: 'live_broadcast',
    phase: 'create',
}, function(response) {
    if (!response.id) {
      alert('dialog canceled');
      return;
    }
    alert('stream url:' + response.secure_stream_url);
    FB.ui({
      display: 'popup',
      method: 'live_broadcast',
      phase: 'publish',
      broadcast_data: response,
    }, function(response) {
    alert("video status: \n" + response.status);
    });
  });
};
</script>

In the create pop-up window, you can choose your post destination which can be on your timeline, a friend's timeline, any page you manage, or groups.

After you click Next, the response will include the stream_url and secure_stream_url fields. Either one can be broken out into a server URL and stream key. A complete stream_url will look like this: rtmp://rtmp-api.facebook.com:80/rtmp/10153307708286557?ds=1&a=AdrRKk4mOaqPbQdxDuk

The server URL is the first half of the stream_url: rtmp://rtmp-api.facebook.com:80/rtmp/

The stream key is the latter half of the stream_url: 10153307708286557?ds=1&a=AdrRKk4mOaqPbQdxDuk

In our code snippet, we have an alert call with the stream_url. This is where your client should start streaming to the stream_url. Soon after the stream starts, you will notice a preview of the broadcast appear in the publish phase pop-up window.

If the publish pop-up window is appearing to be Offline, ensure that your firewall is not blocking RTMP and that any Adblocker software on your browser is turned off.

The dialog enables users to choose privacy settings without adjusting the request's privacy parameter. Additionally, you can set the Live video description, title, and topic tags.

When the you click Go Live, the dialog will close. Within a few seconds, you'll see the live stream on your profile, page, or group, according to the destination you chose.

With the latest updates, released on Sept. 11, 2017, metadata is injected into the first frame of a live video with frame-accurate start times. Encoders can now implement a countdown to alert publishers to the exact start of the video. You can also start and stop the video from the Facebook interface.

Parameters value Description

display

popup, iframe

How the dialog is open in your web page.

phase

create, publish

Dialog in create phase allows you to get stream url to upload video; Dialog in publish phase will provide preview and go live button. required

broadcast_data

The response object returned from either API or create phase.

This parameter is required for publish phase.

Response Field Phase Description

id

create, publish

The ID of broadcast video.

stream_url

create

A rtmp url that contains stream server and stream key, where the live stream should be uploaded to.

secure_stream_url

create

A rtmps url, the stream url with secure protocol.

status

publish

string value indicate the status of broadcast.

Continuous Live

Continuous live video is a recent addition to the Facebook Live product family. It supports an unlimited live stream on Facebook. Some great use cases for continuous live include live feeds of aquariums, museums, and zoos.

Before streaming, please note:

  1. Continuous live will not generate a VOD
  2. Continuous live does not send notifications to followers
  3. If the broadcaster ends the live video, the post will be unpublished from the timeline, which means only the broadcast owner will see it.

You can create a continuous live stream by making a POST request with the stream_type parameter set to AMBIENT.

curl -k -X POST https://graph.facebook.com/$your_userid_or_pageid/live_videos
-F "access_token=$your_user_or_page_token" 
-F "stream_type=AMBIENT"

When you want to end the continuous live stream, be sure to end it programmatically through the Graph API.

curl -k -X POST https://graph.facebook.com/$your_live_video_id 
-F "access_token=$your_user_or_page_token" 
-F "end_live_video=true"

Scheduled Live

Broadcasters can now schedule a live video in advance through the Graph API, providing the option for people to opt in to be notified, Get Reminder, when a live broadcast starts. This allows audiences to opt in to receive a reminder notification when a live broadcast starts, ensuring that they don't miss a second of a live broadcast!

A scheduled live video will help broadcasters:

  • Build anticipation and buzz before a broadcast
  • Start a broadcast strong, without any dead time
  • Test recurring programmed content

To learn more about how to implement Scheduled Live, check out the Scheduled Live section of our Production Broadcast documentation.

Live Video With Publisher Tools

Similar to the Go Live Dialog, our publisher tools UI allows you to go live directly from your page. This is the best solution if you're unfamiliar with how to make programmatic calls to Facebook's Graph API either through curl commands or through the Graph API Explorer tool. You can still create professional-looking live content using your existing video software or hardware.

To get setup, check out our Publisher Tools Setup Guide!

Troubleshooting

Having trouble connecting to publisher tools? Does the Preview box say you're Offline?

  • Make sure you have a reliable internet connection
  • Disable all ad blocking software or browser plugins that could prevent the video player from loading
  • Check your firewall settings and ensure RTMP is allowed
  • If the server URL and key are older than 24 hours, they are no longer valid. Please create a new URL and key.

Media Developer Partners

If you are still interested in going live but aren't sure where to get started, contact one of our Media Solutions Live API partners. They can help you easily build rich, interactive Live experiences.

View Partners