How to build your own Video-on-Demand service in an afternoon

 

In April, Azure Media Player was released and this was the missing piece of the puzzle when describing how to build a media solution for Azure customers. It is easy to understand and in less than a day, you can build a Video-on-demand service together with the backend support from Azure Media Services. This is really cool and opens up business opportunities that doesn’t cost a fortune up front.

This blog post will not dive deep into all technologies, since there are many technical explanations out there already about Azure Media Services if you need to go deep. This blog post is a simple end-to-end solution, from the Video Camera, through Azure, to watching the content it in your web browser. You will get a chance to view what I recorded and what (little) I did to make it available to you. I will also show you what it costed.

The web page I have create for this post is available here and you can view it already now if you like http://redbaronamp.azurewebsites.net/

screenshot

A business opportunity as big as Grand Canyon

In my private time, I’ve been into sports since an early age and for more a decade I’ve been coaching volleyball to youngsters, including my three children. With the digital explosion, photographs have been surpassed by video as the way to document and share sports events. First there was Youtube that launched 2005 and then came Bambuser and Ustream in 2007. Youtube is a VOD service while Bambuser and Ustream primarily are Live Streaming services, although they have VOD too after broadcasting an event. In recent years, sharing of sports video have catapulted on facebook and vimeo too since you can tag people in the ever lasting hunt for more likes.

However, all these services have two common problems. They force their advertisement upon you and you also hand over ownership of your video to the service owner. As a sports club, you want to have your sponsors logos on the web page surrounding the highlight clips from last match played since the sponsors pay good money. Having Viagra och breast inplants ads next to junior sport videos may lead to unhappy sponors. In small sports, such as volleyball, you are constantly looking for values to sell to your sponsors, and VOD or Live Streaming via the free services hasn’t been an good option. But now you can build your own VOD service include only your sponsors on the web page. If you have control of it, you can also package it and you have something to sell.

Your in good company

If you are wondering if it’s worth using Azure Media Services for such a service, perhaps it’s good to know you are in good company. Azure Media Services (AMS) has been used for the Vancouver 2010, London 2012, Sotji 2014 Olympic Games and also for the Football World Cup 2014 in Brazil (I refuse to call it Soccer – see https://www.youtube.com/watch?v=2sD_8prYOxo). NBC Sports use AMS too for showing NFL. The scale of the cloud in the digital world.

My VOD Solution

The first part of my production process is recording the sport event with my cheap $200 Canon camcorder. When the day is over I dump over the AVHCD files to my laptop and do post production in Movie Maker where I edit the shootings into a WMV/MP4 file. For an important and well played match, I edit a hightlights video also.

Step1-recording2

Next step is to hand the file off to Azure Media Services. This is a three step process which consists of uploading the file, encoding the file and lastly publish it for viewing. You can do all steps in the Azure Management Portal, but that’s not really a solution that scales or that you want to roll out in your organization or sports club. The portal also has a max limit on 200MB for uploading which means you must use a program to upload larger files.

Step2-encoding

Uploading, Encoding and Publishing

To automate this process, I have written a little C# console program from scratch that in 250 lines of code performs the uploading, encoding and publishing of a video file you have locally on disk. The sources you’ll find at the end of this blog post. I’m not going to explain the code here. If you are interested, look into the source code and read the comments.

UploadVideo-run

App.config

The encoding step requires information about what encoder that should be used and this is controlled via a setting in the config file for the console program. I use the H264 Adaptive Bitrate MP4 Set 720p encoding since that is enough for my videos. While the encoding job is running you can see the progress in the Azure portal.

AMS-Jobs-Encoding

The publishing step applies an AccessPolicy to the video. In my case, the policy is allowing for the next 365 days Read + List access of the assets (MediaServices lingo for media files). The AccessPolicy also creates a locator which gives a public url that we can reference the video with in the player.

AMS-Content-Published

Azure Media Player

What I have described so far has existed since day one with Azure Media Services, although new processors and encoders have appeared internally in AMS. The missing piece of the puzzle was the ability to build a player to view this content without being a development guru. In April this year, Microsoft released Azure Media Player which is a javascript based player that you easily can integrate in your web page. It’s really as simple as snooping on the html source of a web page and realizing how it’s built.

What I did was to build a really simple web page in Visual Studio where I included the refrences to the AMP javascripts. The page enumerates published assets in my Media Services account and provides you with a list of videos to play. To prove my point about ads, I added a few logotypes on the page to the real sponsors of my sports club to give you the idea of what you can do.

The web page containing the player can be used from Windows, Mac, Tablets/iPads, Smartphones, etc. Use the link below on your different devices and see how it works.

What was my effort?

I coded a small program to handle the upload-encoding-publishing steps and spent a few hours building the web page (yes, I could have done a better job on the web layout, but that’s beside the point here). All in all, the effort took 4-5 hours of development, including writing this blog post. Then I published the web app to Azure WebSites and just uploaded a few videos. With it, I have my own Video-on-Demand service available here. Check it out!

http://redbaronamp.azurewebsites.net/

Cost for my solution

Based on azure.com list prices per May 21, 2015

Storage – 475MB of multi-bitrate MP4 files. 215MB is the size of the file that was uploaded. 260MB is created during encoding. Price of storage for this is $0.12/month.

Network Bandwidth – To pick any number I assumed network egress of 100GB / month which means 200 views. Price of bandwidth is $8.27/month.

Encoding – Encoding price for 475MB is close to $0.70 as a one time cost. I do not have any reserved units since this is not a time critical process.

Streaming Unit – I use 1 on-demand streaming unit to guarantee me of a 200Mbps streaming capacity. The cost for this is $139/month. In the really low end scenario you can get the solution to work with 0 streaming units, but then you might experience bad viewing.

Total cost is ca $140/month with a streaming unit or as cheap as $10/month for no reserved streaming bandwidth capacity. In $140 you have 200 Mbps of dedicated streaming capacity for the entire month 24×7, so perhaps it’s not entierly fair to attach the full cost for that to a single video file.

Source Code

http://data.redbaronofazure.com/public/MediaServices.zip

References

MSDN Building a VOD service sample – https://msdn.microsoft.com/en-us/library/dn735912.aspx
this is a sample that has it all. Nothing is missing. However, be prepared to read code. Lots of it!

Azure Media Player demo – http://amsplayer.azurewebsites.net/

Azure Media Player samples –  http://amp.azure.net/libs/amp/latest/docs/samples.html