Publishing a Facebook live video using Wowza Streaming Cloud REST API from Android

Recently, I was trying to stream some content from my phone to multiple social media platform starting with Facebook. Here’s how I got it working.

Photo by Tarun Savvy on Unsplash

I come from an android background and this was my first time working with Wowza and Facebook. So after a few sessions of research, head-scratching and tinkering, I was making some steady progress.

Note: If you need to connect to Facebook via Wowza using their streaming cloud and not specifically with the REST API then you can check out that guide here:


  1. Have an outgoing RTMP video stream ready.
  2. A Wowza cloud account.
  3. A Facebook developer account and an app created for accessing FB.

Let’s get started!

Setting up Facebook integration:

Photo by Caspar Camille Rubin on Unsplash

Getting started with Facebook is very well documented and straightforward. The only thing to note is that since we are planning to use the app to stream video to Facebook we must request the publish_video permission that can be added to the Facebook login button as shown:

Once we have successfully logged in to FB, then we can request for the live video object from FB; since that will contain the URL that we need to send to Wowza when we are creating a streaming target.

In the code above I’m using retrofit 2 for network calls and GSON for JSON processing, also note that the status parameter must be “LIVE_NOW”.

Capture the details that we receive and we are set to move on to the next step!

Setting up Wowza Cloud from the Rest API is as follows:

Photo by Hu lei on Unsplash

A quick point to note is that while Facebook will maintain your session for you, you’ll have to pass the Wowza API_KEY and ACCESS_KEY with every request you make to the Wowza cloud.

This can be done in retrofit by adding an Interceptor while creating the retrofit instance, like so:

Also, note that you must add a digest in the header for the production code ‘wsc-signature: [signature-generated-from-HMAC-256-Hexdigest-algorithm]’

Okay now with that out of the way, let’s take a look at the steps we need to take to make Wowza send the incoming RTMP stream to Facebook as an RTMPS stream.

  1. Create a Wowza “Live Stream” that captures the incoming stream.
    - this, thankfully, creates the transcoder and a default stream target for us, which we’ll get to in a second.
  2. Creating a stream target that points to Facebook.
  3. Create an output format that the transcoder can use and output to the stream target we mentioned in the previous step.

Let’s get right into it!

NOTE: we will be using API 1.6 for this process: so you can set your base URL to


For step one we have to create an object to be passed in the body of the request and this is what I’ve used:

The LiveStreamWrapper class does nothing other than wrap the LiveStream object with the name “live_stream” like so

Once the network request is sent out using

we are looking for a responseCode of 201

Here we can capture some of the responses we get:

The primaryServer value is the entry point to the created live app in Wowza and we must point the data we want to stream to this URL.


Now that we have created the live stream app, we need to start it before we can interact with it:

Starting the live stream app is done by passing the streamId we received in Step 1 with the request below:

Now, this process could take a while to complete (sometimes even a couple of minutes) but once triggered successfully, we should receive a responseCode of 200.

Since this could take a while you may have to poll for the current status as shown below by passing in the streamId:

The possible states are as follows:

Once the status returns as “started” we can move on to the next step: (Yay! so many steps!)


Okay for this, let's take a look at the streaming URL we received from Facebook when we made the request for getting a live video object. It will be in the following format:

For creating the stream target Wowza requires you to pass the primary URL without the protocol and without the trailing ‘/’ as below

This object is then passed to the server to create the custom target as shown below:

The CustomStreamTargetWrapper class is used simply to wrap the StreamCustomTarget as “stream_target_custom”

Once we have this created we will get a responseCode of 201.


Now we have to connect the streaming target to the transcoder that is automatically created with the live stream app that we created in step 1.

This will contain the live stream app name that we saved earlier as liveStreamAppName +“ / Transcoder”

We can find the transcoder we require by sending the request to fetch all available transcoders and parsing them to find the one we are after:

and on iterating through the list of available transcoders we can find what we are looking for

The createFbRtmpOutputFormat method creates the output format that FB requires and:

This is then sent along with the request to create the RTMP output format as part of the request body

This should return a responseCode of 201.


Since the FB target has been created we can associate this with the output format of the transcoder

This is then sent to Wowza using the following:

Once we get a responseCode of 201, we are all set to stream!

You’ll simply have to start the stream from the app and this will be visible within a few seconds on your Facebook profile page.

Photo by bruce mars on Unsplash

Pro android app developer. Recent discovery: Sometimes reading the documentation can be helpful.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store