Tutorials ยท 4 min read

android robot

Live stream from your Android phone

Live streaming from your phone can be as involved as you'd like. In this post, we'll use a free Android application to create a live stream at api.video. In future posts, we'll build an Android streaming app.

Doug Sillars

February 24, 2021

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. You can also check out our live stream API reference documentation.

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!

Try out more than 80 features for free

Access all the features for as long as you need.
No commitment or credit card required

Video API, simplified

Fully customizable API to manage everything video. From encoding to delivery, in minutes.

Built for Speed

The fastest video encoding platform. Serve your users globally with 140+ points of presence.ย 

Let end-users upload videos

Finally, an API that allows your end-users to upload videos and start live streams in a few clicks.

Affordable

Volume discounts and usage-based pricing to ensure you donโ€™t exceed your budget.