Demo – how to create HLS and Smooth Streaming assets using dynamic packaging

This blog post is a walk-through on how to create HLS and Smooth Streaming assets using dynamic packaging with Windows Azure Media Services (WAMS), by using .NET SDK.

What is dynamic packing?

Before talking about dynamic packing, we have to mention what’s the traditional way of doing things. If you want to delivery both Http Live Streaming and Smooth Streaming, you have to store both of them. Therefore, you stream HLS content to iOS devices and Smooth Streaming content to Windows 8 for instance. However, by using dynamic packing feature in WAMS, You only need to store a Mp4 file in your storage, and we dynamically packaging Mp4 file into HLS or Smooth Streaming based on your client request. If it needs HLS stream, we will package Mp4 into HLS on the fly, and serve out to your client. In this case, you no longer need to store a copy of smooth streaming and HLS, hence, we help you save storage cost by half at least. This diagram below demonstrates what I just described:

How dynamic packaging works in WAMS

How dynamic packaging works in WAMS

Pre-requisites

a. Besides of having a media services account, you need to request for at least one On-Demand Streaming Reserved Unit. You could use portal and click on Scale tab. Pricing detail please refers here.

Noted if you don’t have any on-demand streaming reserved unit, you will still be able to access our origin server. However, dynamic packaging feature won’t be unable.  You could still compose Smooth Streaming and HLS URLs, but you won’t get back any content by accessing them.
On-demand Reserved Unit

b. Here is a sample WMV file and you could download here.
c. This is the finished project if you find the following tutorial hard to follow.

1. Open Visual Studio 2012 and create a console application.
2. Add in WindowsAzure.mediaservices through Nuget in your reference folder.
3. Add in the following code in class Program. You could retrieve your account key and account name from portal. SingleInputFilePath is where you store the source file. And the outputPath is where we will place the file which contains the final streaming URLs information.

4. Add in the following methods to upload asset and track your asset upload progress:

5. Adding encoding method which transcode our WMV input file into Mp4. Here are various H.264 encoding presents that are available in Windows Azure Media Encoder.

6. The following steps are different from the traditional way of packing asset. You will create locator for your Mp4 and just by appending either /manifest (for Smooth Streaming) or /manifest(format=m3u8-aapl), we will dynamically packaging your media assets into Smooth Streaming or HLS based on your URL request.

7. Let’s add in a utility method for writing locator URL into the file.

The reason why we want to write locator URLs into a file is because in portal, you will only see the Mp4 SAS URL, which points to the storage. You won’t be able to grab the locator URL unless you write them down.
8. Adding the following lines into main program in order to create the following workflow: upload WMV ->  encode into MP4 -> create locator -> write locator URL for both Smooth Streaming and HLS into a file.

9. Now you could press F5 and run this program. This is a printscreen of my console.
Console application
10. I have uploaded the whole project here and feel free to try it out yourself!

Additional resources and questions:

  • • Technical blog: Dynamic Packaging and Encoding and Streaming Reserved Units by Nick Drouin
  • • Ch9 video: Introduction to dynamic packing by Nick Drouin
  • Question: What are supported input format and output format? Is MP4 the only input?

  • Answer: We support both Smooth Streaming format and Mp4 as input. And for output, we generate Smooth Streaming and HLS v4. Please noted that we dont support encrypted content as source files, neither Storage Encryption nor Common Encryption.
  • Question: Could I use an existing Mp4 or Smooth Streaming file as input without encoding?

  • Answer: Yes. You could upload existing adaptive bitrate sets and validate them using the Media Packager. Here is a MSDN tutorial on validating your existing asset. Please check it out if you have questions.
9 Responses to Demo – how to create HLS and Smooth Streaming assets using dynamic packaging
  1. Trackback: Wazurr Community
    Demo - how to create HLS and Smooth Streaming assets using dynamic packaging... Thank you fo... wazinf.cloudapp.net/Demo-how-to-create-HLS-and-Smooth-Streaming-assets-using-dynamic-packaging
  2. Eric C Reply

    Hi,

    I just want to know, is the HLS url generated valid for streaming on an IPAD app? Like using it in a simple player?

    Regards,
    Eric C.

    • mingfeiy Reply

      Yes it is.

  3. [...] Packaging: [Demo app] How to create HLS and Smooth Streaming using dynamic packaging by Mingfei Yan [Vid... mingfeiy.com/windows-azure-media-services-useful-resources
  4. Ying Li Reply

    Why on my Azure, there is no scale button, but the encode button. And press the encode button, there is only reserve unit slide?

    • mingfeiy Reply

      We changed the UI sometime.

  5. Javi Logroño Reply

    Good tutorial.
    I have a question. I want to see from a url which captures the kinect V2 in “real time.” If I use Smooth Streaming or HLS file (eg mp4) is needed, but in my case the video file is constantly growing, as are added new frames from kinect V2. What solution do you recommend?

    Greetings and thank you very much!

  6. […] Make sure you have 1 reserved streaming unit. We support dynamic packaging a multi-bitrates Mp4/Smo... mingfeiy.com/android-hls-playback-via-azure-media-services

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">