Getting Started with Live Streaming using the Media Services SDK

Azure Media services just announced the public preview of its Live streaming service. This tutorial will show you how to set up live streaming with Azure Media Services .NET SDK. You can download full source code in our GitHub. Meanwhile, if you want to skip the coding part, please check out Getting Started with Live Streaming Using the Azure Management Portal.

1. Create a console application on .NET 4.0. You can get Media Services .NET SDK through Nuget, by searching windowsazure.mediaservices.

2. Please add the following code into your app.config. You can find Account Name and Account Key in Azure Management portal.

3. Connect to Azure Media Services through CloudMediaContext in program.cs.

4. Create live channel and start the channel. Channels are a fundamental set of components that are needed to stream your live event. Each channel could have an ingest URL, a preview URL and multiple programs associated with it. It takes around 15 minutes to start a channel. You don’t have to start the channel right away, usually people set up the channel in advance but start it once when the streaming is about to start.

5. We will implement each of the methods in part 4. Here is how to create Channel Input. You could choose either Fragmented Mp4 (Smooth Streaming) or RTMP as input streaming protocol. In Access Control, you will need to define IP allow list to permit Ingest point access.

6. Create Channel Preview and channel output.

7. Putting the following lines into main to create channel, and print out ingest URL And Preview URL. Ingest URL is what you suppose to configure with your encoder (please refer to Live encoder configuration blog if you want to set up encoder such as wirecast). Once you configured your live encoder, you should be able to watch stream from Preview URL in order to verify that your stream is correct.

8. However, if you want to persist your stream and set a DVR window, you need to create program and streaming endpoint. Let’s put the following code into Main method.

9. A Program enables you to control the publishing and storage of segments in a live stream. Programs can run concurrently. This allows you to publish and archive different parts of the event as needed.

You can specify the number of hours you want to retain the recorded content for the program by setting the ArchiveWindowLength property. This value can be set from a minimum of 5 minutes to a maximum of 25 hours. This also dictates the maximum amount of time clients can seek back in time from the current live position. Programs can run over the specified amount of time, but content that falls behind the window length is continuously discarded. This value of this property also determines how long the client manifests can grow.

10. After that, you must create a streaming locator in order to access the stream. The streaming locator is a streaming endpoint that maps to your media asset with a particular access policy.

11. Lastly, you need to create streaming endpoint and get locator URLs. A single Media Services account can have multiple streaming endpoints. You may want to have multiple streaming endpoints if you want to have different configurations for each (for example, security settings, cross site access policies, scale units, etc.) or if you want to separate you Video on Demand (VOD) and Live streaming.

12. Now you could run this program and enjoy the live stream. You can download full source code in our GitHub. And all these settings could be viewed through our Azure portal as well.

One Response to Getting Started with Live Streaming using the Media Services SDK
  1. […] my earlier post on how to configure Live Streaming using .NET SDK, there is step 8 used to create Pr... mingfeiy.com/configure-aes-encryption-live-streaming-using-azure-media-services

Leave a Reply

Your email address will not be published. Please enter your name, email and a comment.