api.video

Features

Documentation

Live stream from your Android Phone

February 24, 2021 - Doug in live - create

We're often asked, can I use api.video to live stream video with my Android/iPhone? Our answer is (of course) a resounding yes! If you want to build our own streaming app, we have SDKs for both Android and iOS. In future posts, we'll build sample apps using these SDKs.

In this post, we'll skip building an app, and start streaming quickly by using a free app from the Google Play store to quickly begin live streaming with api.video.

Setting up a Video Live Stream

Before we download an app to our Android phone, you'll need an api.video live stream. Create a free account (you can livestream with the free account!). Once you have your account, you'll have an API key. We have several posts on creating a livestream that can help you walk through the steps.

First, you'll authenticate with your token (curl code shown):

 curl -X POST \
  https://sandbox.api.video/auth/api-key \
  -H 'Content-Type: application/json' \
  -d '{"apiKey": "your_api_key"}'

This will create a token that you'll use to create a live stream. Insert the access token into the header (line 3), and rename your live stream from "Your Stream Name":

curl -X POST https://sandbox.api.video/live-streams \
-H 'Content-Type: application/json'  \
-H 'Authorization: Bearer {insert access_token here}'\
-d '{"name":"Your Stream Name"}'

The JSON response will have a bunch of parameters:

{"liveStreamId":"li400mYKSgQ6xs7taUeSaEKr",
"streamKey":"30087931-229e-42cf-b5f9-e91bcc1f7332",
"name":"Your Stream Name",
"Record":false,
"Broadcasting":false,
"Assets":{
"iframe":"<iframe src=\"https://embed.api.video/live/li400mYKSgQ6xs7taUeSaEKr\" width=\"100%\" height=\"100%\" frameborder=\"0\" scrolling=\"no\" allowfullscreen=\"\"></iframe>",
"player":"https://embed.api.video/live/li400mYKSgQ6xs7taUeSaEKr",
"hls":"https://live.api.video/li400mYKSgQ6xs7taUeSaEKr.m3u8",
"thumbnail":"https://cdn.api.video/live/li400mYKSgQ6xs7taUeSaEKr/thumbnail.jpg"}}

You'll need the streamKey to set up your live stream - and the assets links for your viewers:

  • iframe can go right into your webpage
  • video player url
  • HLS url.- to insert in your own HLS video player.
  • Thumbnail - the static image that shows when your stream is not playing.

That's the hard technical part. Now we need an app for your phone!

getting an app

There are a number of free apps in the Android app store (I searched for Live Stream). I tested with Larix player and CameraFi Live in this post, and can verify they both worked wwell with api.video (as I am sure most of them do).

App setup

These apps have pre-set configurations for most streaming services. You'll want to use the "Custom RTMP" service. Each app is slightly different - and will either ask for a full URL, or will ask for a URL and a streamKey

Your full URL will be rtmp://broadcast.api.video/s/{streamKey}

Or if you have to enter 2 fields:

  • URL: rtmp://broadcast.api.video/s
  • streamKey: {streamKey}

After entering these, and before you can stream, you'll need to give the app permission to use your camera and microphone (of course!).

Each app will have various settings for streaming, but you're basically ready to go - pick the front or rear camera from your Android phone, and start streaming. In just a few seconds, your video will begin appearing on the video player url (or the HLS link, or the iframe). Share these links with your friends, and they'll be able to watch yo livestream right from your phone.

Caveats

Watch your data usage - streaming video can use a lot of data (if you're data constrained - use your WiFi). Streaming will also use your battery a lot - if you're not near an outlet, make sure you have a battery pack or two to keep your phone fully charged.

Conclusion

That's basically it - there are a lot of free streaming apps in the Google Play store - they are quick to set up, and you can be streaming live on your phone in a matter of minutes.

In the next post, we'll build the framework of a basic Android app using our SDK. But in the meantime, sign up to start streaming from your phone today!

Doug

Developer Evangelist

Get started now

Connect your users with videos