Over a million developers have joined DZone.

Using Your Smartphone’s Camera to Live Stream Through Azure Media Services

Check out this tutorial on how to live stream through Azure Media Services using your smartphone's camera.

· Mobile Zone

You might have seen many examples of Azure Media Services (AMS) Live Streaming demo through Wirecast installed on the laptop as shown in below links:

Now, I’d like to share a different way to live stream, by using your smartphone’s camera. Interesting, isn’t it?

Mingfei has a post leveraging Wirecast’s iOS app here. The idea is that approach leverages a camera on your phone while still requiring a Wirecast on the desktop.

In this post, I’ll be showing a different of my approach, by having a lightweight encoder installed on our smart phone (Windows Phone), and push the feed directly to AMS Live Channel.

Azure Media Capture in Windows Phone

I’m leveraging Azure Media Services Capture that you can download from the Microsoft store for free. If you need to integrate this capability into your mobile application, you may download the source code and SDK from Codeplex

I assume you are familiar with how to do a live streaming through an on-premise encoder like Wirecast. But if you’re not, no issue at all. Please check the 3rd video of this post where I recorded how to live stream step-by-step.

I’ll be using Azure Media Services Explorer tools to manage the live channel, similar to the aforementioned video. The only difference in this approach is you should create a live channel with Fragmented MP4 (Smooth) as the Input Protocol.

image

Figure 1. Creating Live Channel with Live Encoding and Smooth Protocol

Optionally, you may select Live (cloud) Encoding which makes a lot of sense to offload the multi-bitrates encoding from your phone to the cloud as shown as below diagram.

*It’s not mandatory to enable live (cloud) encoding in the demo. Enabling live/cloud encoding, will take much longer channel’s starting time*

image

Figure 2. Architecture of Live Streaming (with Live Encoding) via Windows Phone

Once the channel is running, copy the Primary Input URL of that channel.

image

Figure 3. Copy the Input URL of the Live Channel

Next, open the Azure Media Capture app on your Windows Phone. Click the setting icon and paste the Primary Input URL to the “Channel Ingest URL.”

*Notice that, you actually can push multiple bitrates/resolution from your phone if prefer to, but your phone will suffer as encoding generally is a very processor intensive task*

image image








Figure 4. Azure Media Capture Settings

Click Start Broadcast “Red Dot” button when you’re ready. When live/cloud encoding is enabled, anticipate longer delay (about 45 seconds).

Go back to your Azure Media Services Explorer, right click on the channel and playback the preview with Azure Media Services Explorer.

image

Figure 5. Playback the Preview URL

And if everything goes well, you should be able to see the live stream that pushed from your phone:

image

Figure 6. Multi-bitrates result from phone

What About Android?

Theoretically, you can do similar concept with Android phone. There are several RTMP encoders for Android Phone such as Nano Cosmos and Broadcaster for Android.

I tried Nano Cosmos and worked well with AMS Live Channel (via RTMP).

Hope this helps.

Topics:
mobile ,mobile app ,media playback ,streaming

Published at DZone with permission of Wely Lau, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}