Share via


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 https://[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

  • Anonymous
    November 30, 2007
    PingBack from http://www.absolutely-people-search.info/?p=1649

  • Anonymous
    December 02, 2007
    Every little bit helps - thanks (and keep them coming)!

  • Anonymous
    January 10, 2008
    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

  • Anonymous
    January 10, 2008
    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.

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

  • Anonymous
    February 26, 2008
    i am not able to connect to my media server by using your format. is there any alternate

  • Anonymous
    April 03, 2008
    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?

  • Anonymous
    May 24, 2008
    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?

  • Anonymous
    May 25, 2009
    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!

  • Anonymous
    May 26, 2009
    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

  • Anonymous
    June 19, 2009
    Hi, Thank you for the nice article! Can you please specify where can we find "MMC snap-in for the Media Server". Thanks

  • Anonymous
    October 02, 2009
    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

  • Anonymous
    October 02, 2009
    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

  • Anonymous
    November 03, 2009
    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?

  • Anonymous
    July 02, 2010
    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 ;-)

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

  • Anonymous
    July 18, 2011
    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

  • Anonymous
    April 12, 2012
    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.  

  • Anonymous
    February 05, 2013
    Sir... I want to show live video in my website html or asp.net. Can you please send me code for this

  • Anonymous
    February 05, 2013
    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

  • Anonymous
    July 17, 2013
    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