Scott Hanselman

Installing and Setting Up and Encoding for IIS 7 Smooth Streaming and Silverlight

February 05, 2010 Comment on this post [25] Posted in ASP.NET | IIS | Silverlight
Sponsored By

I heard someone saying they were having trouble setting up Smooth Streaming for IIS, so I wanted to try it myself.

If you just want to see Smooth Streaming work, visit http://www.smoothhd.com/ for some sample demos. They'll adapt to your bandwidth and look as nice as they can. If you want to fake a low-bandwidth situation, you can use the player at http://www.iis.net/media/experiencesmoothstreaming and play with limiting the bit rate.

Step 0: Got IIS?

I've got IIS 7 because I've got Win 7. If your Win 7 installation doesn't have IIS yet, go to Programs and Features and click "Turn Windows Features On or Off" and select Internet Information Services. Don't forgot to go through the tree and turn on the things you want, like "Static Content" in this case. (Remember, if you've just installed IIS, shut down Skype as it grabs port 80 if it gets there first. Lame.)

Step 1: Add IIS Media Services

I'm running Windows 7 x64 so I installed IIS Media Services 3.0 64-bit, but you can certainly install IIS Media Services for 32-bit also. Even easier, just install it from the Web Platform Installer directly.

IIS Media Services 3.0 Setup

Installing the IIS Media Services pack gives you a new icons in the IIS manager:

image

Step 2: Get (or Make) Some Content (and Encode It)

If you just want to see this work, you can get some pre-encoded content, below in 2a. Later in 2b, I'll encode some new content.

Step 2a: Get Some Pre-Encoded Content to Test

Use At this point, if you're just testing, you can go download the pre-encoded "Buck The Bunny" HD Video Sample Content (about 500 megs of HD video). Run it, extract the files, and put them somewhere like c:\inetpub\wwwroot\bunny.

HOW SMOOTH STREAMING WORKS - SIDE NOTE: You kind have to see it to get it, but it's actually clever in its simplicity. Some folks freak out when they take a, say, 200 meg video file and encode it for Smooth Streaming and the resulting directory is, say, 500 megs. They might say, it's larger! I don't have that kind of bandwidth! In fact, less is sent over the wire than exists on disk. The idea is that Smooth Streaming creates "steps" of bitrates. It encodes and stores your file multiple bit-rates on the disk.
To illustrate this, I will use the DJ Hero video game as an example: Picture of the tracks on the record in DJ Hero as the DJ moves between tracks
Just as the DJ moves between tracks depending on how the crowd feels, Silverlight between encoded streams depending on the bandwidth is doing. Remember, it's called "Adaptive" Smooth Streaming.

Now I visit http://localhost/bunny/default.html and rather than the standard Silverlight Player, I'm going to select one called "User Experience Simulator." Basically, I want to fake a low bandwidth situation and see the Smooth Streaming react.

NOTE: If you like, or you're demoing this to a boss or someone, there's a prettier/shinier player on the Smooth Streaming Sample Content page that you can swap out. Details on the Getting Started Page for Smooth Streaming.

I start the player, and you'll notice on teh right side there's "Now Downloading" and "Max Bit Rate." I'll force a lower bit-rate (again, I'm simulating congestion here) and seek within the video. Then raise it, and wait, or seak. Notice the chart showing that the Silverlight Player "switched tracks" without dropping frames.

Another metaphor would be changing gears on a bicycle to adapt to a changing road.

Big Buck Bunny in Silverlight Smooth Streaming

Step 2b: Encode Some Content of Your Own.

Ok, so that was just existing content. You can download Expression Encoder 3.0 and encode all the video you want, but if you want to encode Smooth Streaming or H.264, you have to upgrade for $49 to Expression Encoder 3.0 with IIS Smooth Streaming. (By the way, Expression Encoder will also do Screen Capture, which is nice to know. The free version will do up to 10 min of Screen Capture, which is also useful to know.)

I drag a video of ScottGu in HD into the Encoder and select IIS Smooth Streaming. Since my source is HD 720p, I'll select that. By default, the profile will basically encode a high version and low version, but for best results you'll want to decide how many levels of stepping you want. Expression Encoder can be run in a batch from the command-line also, BTW.

Make sure you click the encoding option you want, right-click and say "Apply to Selected Items." You'll know you got it right if the Video section further down (that you can open up) includes multiple streams of various sizes and bitrates. Notice the screenshot. More streams will mean longer encodes and more space on disk taken up, BUT it'll make for more bitrate options for the player to choose and a MUCH better, smoother experience. Again, you might have 1, 5 or 10 streams for a 1 gig source and end up using 5+gigs of space on disk (I made those numbers up) but the end user's experience will be smooth and the bandwidth used will be as small as possible.

Microsoft Expression Encoder 3

It is worth noticing that screencasts should mostly be encoded using an H.264 Screen Encoding profile, while action like sports games work better with other codecs. What looks good on the football field often looks like crap if it's some dude coding on his screen. You'll also want to have a reasonable minimum resolution and a minimum bitrate. Experiment and you'll find what works and save it as a custom profile that's right for your content.

After I encoded all this, I thought to myself, crap, the REALLY LOW bandwidth version is not acceptable. Do I have to re-encode to not include that one? I can just hack the .ism file manifest as it's just XML and remove all knowledge of that lower bit-rate file. UPDATE: There's a nice UI to managed rethe different bit rates, so no need to hack any XML.

It can be tricky to do the math and figure out what resolutions and bitrates to use for your smooth streaming content so you can use this Silverlight-based Smooth Streaming Multi-Bitrate Calculator. There's a WPF one also. To get really good quality you'll vary not only the bitrate, but also the resolution (but you'll stretch it, so the user won't know the resolution changed also.) Ultimately you have complete control as everyone's content has different needs.

The "More Info Than You Asked For" Section: What's Really Happening?

If you want a deep deep dive into what's going on, check out the Smooth Streaming section of Alex Zambelli's blog. It's wonderfully deep. A lot of people don't realize that Smooth Streaming is still just plain HTTP.

Traditionally streaming is a long running stream over a stateful protocol, where a packet is a some milliseconds of video.

Smooth_Slide06

Adaptive Streaming is chunked over HTTP where the client can choose different chunk sizes in various bit rates.

 

Smooth_Slide08

From Alex's blog:

A typical Smooth Streaming media asset therefore consists of the following files:

  • MP4 files containing video/audio
    • *.ismv – contains video and audio, or only video
      • 1 ISMV file per encoded video bitrate
    • *.isma - contains only audio
      • In videos with audio, the audio track can be muxed into an ISMV file instead of a separate ISMA file
  • Server manifest file
    • *.ism
    • Describes the relationships between media tracks, bitrates and files on disk
    • Only used by the IIS Smooth Streaming server – not by client
  • Client manifest file
    • *.ismc
    • Describes to the client the available streams, codecs used, bitrates encoded, video resolutions, markers, captions, etc.
    • It’s the first file delivered to the client

Both manifest file formats are based on XML. The server manifest file format is based specifically on the SMIL 2.0 XML format specification.

With IIS7 Smooth Streaming, a client is expected to request fragments in the form of RESTful URLs:

http://video.foo.com/NBA.ism/QualityLevels(400000)/Fragments(video=610275114)

http://video.foo.com/NBA.ism/QualityLevels(64000)/Fragments(audio=631931065)

The values passed in the URL represent encoded bitrate (i.e. 400000) and the fragment start offset (i.e. 610275114) expressed in an agreed-upon time unit (usually 100 ns). These values are known from the client manifest.

But most importantly, therefore I make it bold and in red so you'll read it twice:

...what about dynamic bitrate switching that makes adaptive streaming so effective? This part of the Smooth Streaming experience is implemented entirely in client-side Silverlight application code – the server plays no part in the bitrate switching process.

An important thing to think about when doing network capacity planning is that in a traditional scenario, clients will drop to the bit rate they can sustain on average. In Smooth Streaming, it will continually hop up to the highest they can handle. Smooth Streaming gives each client the highest quality video they can handle. That may result in some network stress for the video provider and network infrastructure if you were expecting video that was less than awesome. ;)

Shiny.

A Q&A from Alex's Smooth Streaming FAQ

Q: Is Smooth Streaming based on Microsoft’s ASF file format? Or does it use some new proprietary file format?
A:
No, the Smooth Streaming File Format is based on the ISO-standardized Base Media File Format, better known as the MP4 file format. It follows the ISO/IEC 14496-12 specification

Q: Will Smooth Streaming ensure I can deliver HD video to all my customers?
A:
No. Smooth Streaming can’t perform any miracles; it’s simply an enhanced HTTP delivery method. Delivery of HD video is still bound by the efficiency of the codecs used: VC-1, H.264, etc. For example, most video experts would agree that 720p/24 video can’t be delivered at a satisfactory quality level with less than 2 Mbps encoded bitrate. Well, 2 Mbps of encoded video still requires 2 Mbps of network bandwidth in order to be delivered in real-time – and there’s nothing IIS7 or Silverlight can do to change that.

Q: Where can I see Smooth Streaming in action?
A:
Visit SmoothHD.com for a demo of on-demand Smooth Streaming, with video content ranging up to 720p HD for those on fast connections (3 Mbps or more). Also check out the IIS.net demo which lets you simulate variable network bandwidth during playback. The only requirement to view Smooth Streaming video is a Silverlight 2 (or better) browser plugin. For a demo of live Smooth Streaming, check out Home Shopping Network’s 24-hr live shopping channel, also offering up to 720p in full-screen mode.

Conclusion

It's really easy to setup and easy to encode for Smooth Streaming. In my case, I just encoded the files off my HD video camera. You'll see more Smooth Streaming around various Microsoft sites that serve video in the coming months.

Have fun!

Related Links

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
February 05, 2010 11:30
Since the video file(s) themselves are just plain old mp4 containers w/ h.264 video in them, can we use our own tools to encode the video (e.g. x264) and have some tool to generate the manifest files?
February 05, 2010 11:45
Well, since I was called out :) I spose I should clarify... I didn't say I was "having a hard time" with it - what I did say was that it produced files that were 5 times the size of my original. A single 200Mb file turned into 1 gig - in some cases more. I understand why, now, because I got an email today clarifying that each of these files represents different bitrates, they're not all streamed (which makes me feel better).

The other issue I was having was the best way to secure the URLs with token authorizations - something we need to reduce hijacking. Currently our flash player has an embedded token that authorizes the stream - I couldn't see how to do that with Silverlight and Smooth Streaming.

Our final issue was the player. We, unfortunately, were losing business because there were people from Reddit who came to view our Git series and would not install Silverlight. At first I just let it go - but after the repeated requests (and emails) I couldn't ignore it (we need to eat).

I do appreciate the reach-out from Tim today but it would have been nice to have this conversation 3 months ago :). Hopefully we'll get a FREE episode up on Smooth Streaming with Tim - that would be great.

Good post, as always.

Rob
February 05, 2010 11:46
Hmm, so if all the cleverness is client-side, presumably IIS7 isn't really necessary -- is someone working on an open-source smooth streaming server I wonder?
February 05, 2010 11:53
Called out? Naw. A "virtual loving squeeze" that's all. Did you get your auth question answered?

Max and random Google ID guy, I'll try to get you those answers.
February 05, 2010 12:15
Scott,

It would be nice to discuss where you can actually host this. It's great to install locally for testing etc but trying to find a host that already has this installed is almost like trying to locate a Sasquatch.

I know we could go and get a dedicated server and then install ourselves but costs obviously rise quickly.
February 05, 2010 14:48
Scott, any idea why they didn't just use HTTP byte range requests e.g:

GET /blah HTTP/1.1
Range: bytes=0-999
...
HTTP/1.0 206 Partial Content
Content-Length: 1000
Content-Range: bytes 0-999/10000
...

This is what the iPhone/iPod Touch does: no special software required on the server - it's plain old HTTP 1.1.
February 05, 2010 15:32
...think I may have worked this one out. HTTP byte-range requests are probably not cacheable by proxies.
February 05, 2010 16:31
Great info Scott! A handy article.
February 05, 2010 16:37
Scott,
Great post, but do you know why IIS cant not agree with the IIS Manager sometimes ?
(Sorry if wrong post)
February 05, 2010 17:17
Thanks Scott,

Is it possible to have a website hosted with a traditional shared hosting company, and to have the video files hosted on Azure and served to the silverlight client using adaptive smooth streaming?

February 05, 2010 18:50
Curious about one of your summary points,
RE>?IIS *LIVE* Smooth Streaming - you can do this with LIVE content also, BTW."
Last time I checked in on this, the ability to do Live Smooth Streaming was limited to hardware devices, such as Inlet's Spinnaker appliance.
I know there is a simulator in the Smooth Streaming SDK to allow the emulation of a "live" smooth streaming using a pre-encoded file, however any information on support real live encoding of video sources from an expression encoder type application/plugin or ideally supported SDK?
I realize that encoding HD content in real-time and into smooth streaming will be very CPU intensive, but would be very interested in tool-sets to do live smooth streaming on our own hardware/software boxes, without requiring third party appliances.
Undeniably, the Smooth Streaming technology is very cool and shows great promise, but until we can readily produce/encode content for both on demand and live scenarios, a lot of us are still relegated to using Microsoft Windows Media Service and the older WMEncoder technologies to get our content on the web.
Any leads on such an encoder SDK?
February 05, 2010 21:42
Duncan - There's always a reason...;) Still, I agree with you...don't invent what already exists, unless necessary.

Herberts - I'm not sure what you are asking?

Luddite - I think so. I'll ask.

NicS - Yes, I don't know of any way to do LIVE *full HiDef* streaming. I've done Live Streaming BTW. I'll ask. Here's an article on setting up Live Smooth Streaming with a Spinnaker.

February 06, 2010 0:16
I've been researching live smooth streaming from Apache, but there appears to be something occuring on the IIS server side that is making it work that's not in any of the MSFT published specs. We have all the manifests all the chunking, but once the manifest loads the PDK will only play the chunks that are in the manifest and not continue with the live stream once those have been exhausted. If you can get answers I would appreciate it I've been trying to reach out to the IIS team, but once I mention Apache they seem to disappear.
February 06, 2010 4:56
To answer the question about using other tools to encode yes, if the tools support the necessary capabilities i.e. fragmented MP4 container, closed GOP VC-1 or H.264 etc then you could use them.
February 06, 2010 9:35
Google guy(first comment) - Smooth Streaming has the logic to switch bit-rates on the client site. However when you talk about a E2E streaming solution the server does a lot other interesting things for both OD / Live presentations. Especially for live presentations where you can do live ad insertion, pass control data to clients, live marker insertion, etc. In addition, with server you would be able to streaming to additonal devices like IPhone in the future.

Max - These are FMP4 files so you could use tools that know how to generate those files. Standard MP4 files are slightly different. However, FMP4 is also a standard.

Duncan - not all proxies/caches honor HTTP 1.1 so we can't always Byte-ranged requests.

Luddite developer - hosters like discountasp.net are now offering Smooth Streaming for hosting accounts. However we dont have Smooth Streaming on Azure yet.

Nick - yes, Live Smooth Streaming today requires special encoders but more and more encoding partners are now supporting Live Smooth Streaming encoding solutions. We don't have a Microsoft tool to do Live Smooth yet.

Google guy (live smooth streaming question) - you are right there sevrer-side requires special logic to make Smooth streaming happen. I am not sure if we have published that in documentation anywhere.

February 06, 2010 17:59
Skype has a setting to prevent it using port 80. Maybe a little unfair to call it lame?
February 08, 2010 9:17
What good is HD streaming in Silverlight if it cannot support anything other than stereo audio?
Screencasts may be OK, but it's utterly useless for movie streaming without at least 5.1.

See http://msdn.microsoft.com/en-us/library/cc189080(VS.95).aspx (do a search for "5.1")
February 09, 2010 18:55
Adaptive streaming is a really terrible idea for super low bandwidth connections. Before adaptive streaming, you would just start the player and pause it immediately and come back 30 min later and watch the video. With adaptive streaming it is impossible to view the video without pauses all the time.
February 09, 2010 20:46
I still don't know why netflix streaming sucks on every system I tried. The streaming is flaky after watching 30 minutes of video.
February 11, 2010 3:01
Scott, are you aware of any You-Tube-style video hosts for this sort of thing? Would be great to just upload and let it happen.
February 12, 2010 22:50
Why is installation on IIS 7 using shared configuration not supported?
February 14, 2010 9:56
I like Rob Conery's question - How do you secure the streams? For example how to I prevent someone from just hot linking to my video files or downloading the raw streams and putting them on their site? Maybe silverlight's cross-domain stuff covers that problem.

What about protected content that only a logged in user can see?

Sounds like a good topic for some Channel 9 videos! The Olympics are a perfect example, as some of the streams require authentication with your cable provider ("entitled content").

It would also be interesting to hear the details on how they are doing the live streaming on such a large for the Olympics.
June 14, 2010 23:42
I have few WMV files and few WMA files and have been playing them as a playlist via IIS Media Services.
Now I converted them to ISMV and ISMA files for variety of kbps connections.

Now, how can I play them in a playlist. I don't see any option there even for that?

Can I call ISM files one by one in c# by using PLAYLISTITEM where one ISM is connected with several ISMV or ISMA files.
Hence this way, I can individually play different content mixed audio and video encoded separately for smooth streaming via the playlist?

Please confirm.

Thanks.
June 14, 2010 23:54
I have few WMV files and few WMA files and have been playing them as a playlist via IIS Media Services.
Now I converted them to ISMV and ISMA files for variety of kbps connections to use Smooth Streaming.

Now, how can I play them in a playlist. I don't see any option there even for that?

Can I call ISM files one by one in c# by using PLAYLISTITEM where one ISM is connected with several ISMV or ISMA files.
Hence this way, I can individually play different content mixed audio and video encoded separately for smooth streaming via the playlist?

I mean would this work:

PlaylistItem item = new PlaylistItem();
item.MediaUrl = new Uri("url/filename1.ism" + "/manifest");
item.IsAdaptiveStreaming = true;
base.Playlist.Add(item);

item.MediaUrl = new Uri("url/filename2.ism" + "/manifest");
item.IsAdaptiveStreaming = true;
base.Playlist.Add(item);

item.MediaUrl = new Uri("url/filename3.ism" + "/manifest");
item.IsAdaptiveStreaming = true;
base.Playlist.Add(item);

Here filename1.ism contains information of several ISMV files, filename1.ism contains information of several ISMA files...

Please confirm if this would work like a playlist rather than creating ONE SINGLE file as WMV by joining Video and Audio and then creating single ISM file?

Thanks.

Love,
Rishi

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.