Over a million developers have joined DZone.

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

DZone's Guide to

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
Free Resource

Download this comprehensive Mobile Testing Reference Guide to help prioritize which mobile devices and OSs to test against, brought to you in partnership with Sauce Labs.

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.


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*


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.


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.


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:


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.

Analysts agree that a mix of emulators/simulators and real devices are necessary to optimize your mobile app testing - learn more in this white paper, brought to you in partnership with Sauce Labs.

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.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}