Demo Live Streams in Silverlight


Customers that I demonstrate Silverlight to, often ask me about Live Streaming using Silverlight. It is actually pretty trivial to demo a live stream.


To create the live source, all you need is a digital video camera that plugs into either a USB port or the 1394 port on your laptop. Your standard DV Handycam is fine(I have tried my Sony Mini DV successfully) , and so are any of the typical clip-on style video conferencing cameras (like a Microsoft Lifecam). Obviously this provides an SD source – to get HD you will probably have to shell out some more money and get one of the new fangled HD consumer cameras.


You will also need an encoder (either Expression Media Encoder or Windows Media Encoder works fine) and a MediaElement on a page pointing to the URL where the encoder publishes the stream. If you want to get fancy and demonstrate a somewhat more realistic scenario, you can also add Windows Media Services as the streaming service to this mix – I typically use Windows Media Services 2008 running in a VM.


Once you plug in the camera and switch to Live Streaming mode in your encoder, xMedia Encoder or WM Encoder will pick up the camera as both a video and an audio source. Below is a snapshot of xMedia Encoder using my Lifecam as a source.


image


The default publishing options for xMedia Encoder is to broadcast over port 8080 – make sure you check the Streaming checkbox in the Output tab.


image


Your MediaElement declaration can look like so:


<MediaElement x:Name=”MediaElem” Source=”mms://localhost:8080/” AutoPlay=”true” Width=”800″ Height=”600″ Stretch=”Fill”/>


And below is the result – my handsome mug in all its glory :-).


image


If you want to make the scenario a little bit more realistic, you may want to add a streaming service to the mix. It is highly unlikely that a production environment would allow players to directly connect to an encoder.


I have been pretty successfully using  Windows Media Services 2008 on a Windows Server 2008 Enterprise RC0 VM. Once you install Media Services, you will need to add the Streaming Media Server role to the server instance. You will then need to take the following steps to set up Windows Media Server to stream your live content:



  • Enable the HTTP Control Protocol on the Media Server. To do that open up the MMC snap-in for the Media Server, navigate to the root node (should be the name of your server), and the Properties tab within. Select the Control Protocol category, select the “WMS HTTP Server Control Protocol” plug-in, and right click “Properties”.  If you are also running IIS on the same box, make sure to select some other port (other than 80) in the property page.

image




  • Bring up the “Add Publishing Point (Advanced)” wizard (right click on the Publishing Points node), and create a Broadcast pub point, and specify “push:*” as the content location. This allows the encoder to push content to the pub point, and activates the pub point automatically once the encoder starts pushing.

image


Once you are done, revisit Expression Media Encoder, and change the Streaming settings in the Output tab to publish to the publishing point you just set up, by providing the URL to the publishing point. The URL is of the format http://[Media Server Name]:[Port You Selected]/[Publishing Point Name]. Clicking the Pre Connect button will confirm connection, and may ask for credentials depending on your domain settings. With this out of the way, if you start Encoding, the stream will automatically be pushed to the Publishing Point by Expression Media Encoder.


image



Your MediaElement declaration can look like so:

<MediaElement x:Name=”MediaElem” Source=”mms://svr08-mediasvr:49000/SLLiveStream” AutoPlay=”true” Width=”320″ Height=”240″ Stretch=”Fill”/>

And that’s all you need to do to get Windows Media Server into the streaming process.

Comments (21)

  1. Amy says:

    Every little bit helps – thanks (and keep them coming)!

  2. dave in tokyo says:

    Can someone remotely access the media stream with an IP address and the port number?  Or do you have to use Media Server step that you describe above?

    Dave

  3. jitghosh says:

    Yes you can. Whether you choose to use WMS for setting up the streaming backend or not, as long as the stream is available over one of the compliant protocols i.e. http, rtsp or mms Silverlight should be able to access and play the stream.

  4. Melvin Ng says:

    This article is very Useful, may I have your email address to know more about live stream with silverlight? Thanks.

  5. Magesh says:

    i am not able to connect to my media server by using your format. is there any alternate

  6. Great post. Right now I’m using Windows Media Services to expose a collection of music. I’m using authentication to protect the media. When I point Silverlight (2 Beta 1) at a protected URI, I get an error. Is there a way to authenticate against a WMS audio/video resource as I do when I point Windows Media Player or Realplayer at it?

  7. justazealot says:

    Very helpful information, thanks! How would you go about adding a second video camera source, can you switch between the two with Windows Media Services or do you need additional software/hardware?

  8. mrprata says:

    Thank you so much. Your post helped me. I’ve been trying to stream a live source from WMS and couldn’t. But I finally can!

  9. shan says:

    Hi,

    I am new to this live streaming. So i dont underlstand completely. Can you send me somthing that may be useful.

    this is my mail id : shanvm@in.com

  10. Nikolay Raychev says:

    Hi,

    Thank you for the nice article!

    Can you please specify where can we find "MMC snap-in for the Media Server".

    Thanks

  11. Durga Prasad says:

    Good information. Currentrly iam working on Smooth Streaming. How to do Live Smooth Streaming using Expression Encoder 3. Could you throw some information on how to generate Live MBR to Media server from Expression Encoder 3. My Mail ID : prasaddamgeti@gmail.com

  12. Tue says:

    I cannot do the same with encoder 2 sp1 and also encoder 3. Its always "Couldnot open media file mms://127.0.0.1:8080/ AG_E_NETWORK_ERROR". Should I try to change some setting in encoder as well as IIS 7 on Vista?

    Thanks

  13. Eric Wilson says:

    Is there any way to remove latency thru Expression Encoder into silverlight?  I only need one person in the world at any given time to view the stream from an IP camera so bandwidth is not an issue?  Any thoughts on how this could be achieved?

  14. Steve Nutt says:

    This is an excellent article. It basically turns USB cameras into IP cameras, which is just waht I was looking for. Thank You for sharing 😉

  15. Bebandit says:

    Works really well! Thanks for posting this. Now, I am going to make a SIlverlight App that I can run the feed into.

  16. Vin says:

    Can silverlight support rtsp streaming?? I have a requirement of streaming rtsp live stream – the camera that monitors the store. I want to do it from sharepoint 2010 using silverlight. Any help would be greatly appreciated

  17. WilsonLast says:

    For implementing Silverlight calls I chose the Ozeki VoIP SIP SDK. Its Mediagateway example ensures communication between two Silverlight clients via a SIP PBX; or communication between a Silverlight

    client and a SIP telephone/softphone.  

  18. Anil says:

    Sir…

    I want to show live video in my website html or asp.net. Can you please send me code for this

  19. Anil says:

    Sir…

    I want to show live video in my website html or asp.net. Can you please send me code for this

    email: anugula.anil@gmail.com

  20. show live video in my silverlight5 application. says:

    I want to show live video in my silverlight5 application.

    Please send me complete source code for the same example?

    My email: Ritesh.Singh@bixi.ch