Google Ads
By Claire on June 12, 2008
Filed under Hardware, Windows

Update 2012 March 25: Microsoft has stopped supporting Windows Media Encoder. It has been replaced with a new product called Expression. Unfortunately, I have not had a chance to use Expression and figure out how to create a similar result. WME is still available for download, but please keep in mind it may not work at all with Windows 7. If anyone has any information on using Expression, please contact me!


I have friends all over the world. Once in awhile, I make use of the various webcams I own and do a little video chatting. Getting video chat to work well will be for another day – something I learned recently, however, was how to setup a live stream on a webpage. It was surprisingly easy, and works in both Windows Vista and Windows XP.

You need three things : a webcam, a decent high-speed internet connection (the lowest end DSL might not have enough bandwidth to support this well), and Windows Media Encoder, which is available for free from Microsoft. If you’re running Vista, there’s a hotfix you might need (it’s linked on the main WME page), but I have yet to have any problems myself.

You might also want to get a dynamic IP service, like dyndns or no-ip. I used no-ip.org, although they seem to be really big on sending me frequent emails advertising their paid services – I’m not a big fan of free services spamming me about their commerical options. If you don’t use a dynamic IP service with the computer running the webcam, you’ll have to manually update the webpage every time your IP changes.

We’ll walk through how to get setup and going. It’s a bit screenshot heavy, so click the jump to see the rest.

Setting up the stream

Install and run Windows Media Encoder (WME). Click the New Session button. We want to create a live broadcast stream.

Select the webcam and microphone you want to use. If you’re setting up this broadcast so your family and friends can see you during the day, you probably don’t need to have sound at all. Keep in mind that streaming sound with your video will also use more bandwidth. My Dell XPS M1330 has an integrated 0.3MP webcam, so I’m using that for this stream.

The “Configure…” button will allow you to change settings on the camera, such as contrast, white balance, noise reduction, etc. I tend to just use the default settings; they work well in general-use situations.

Unless you happen to have access to a Windows Media Server, you’re going to want to setup this stream to be pulled from a server, rather than pushed to a server.

Next, you’ll want to pick a port to use. This is where you need to figure out what’s going to work for you. I was originally going to use port 80. It wasn’t working, until I realized I’d already setup IIS on my laptop, which uses 80 by default (of course – it’s a webserver). In the end, I picked a port in the 1200-1300 range. If you’re running this stream behind a router at home, make sure you open up the correct port in your router’s configuration.

Don’t worry about the local and remote addresses – we’re going to use a dynamic IP url (e.g. mywebcam.no-ip.org or whatever you’ve registered), or the IP address of the machine running the webcam.

The last step we care about in this wizard is selecting a framerate. I’ve been running my stream on a network connection with high upload bandwidth (I average 6MB/s), but if you’re doing this at home on a cable or DSL connection, you’ll probably want to select something a little lower – 250 or 300 kbps will probably work just fine.

You can click through to the end, make sure things are setup the way you want (you can always change all these settings later), click Finish. If your stream isn’t already running, click the “Start Encoding” button in WME.

Now that we’ve got your stream up and running, we can setup a webpage to broadcast it. You don’t need any kind of server-side technology to broadcast your stream. What we’re going to use is an ActiveX control that loads the stream in a Windows Media format. I’ve had hit-or-miss success with this stream opening in Firefox, but it will always work in IE. This is a pretty quick-and-dirty method of getting a webcam stream up and running. OS X users can open the stream in VLC Media Player, but Safari is generally not compatible, since this uses an ActiveX control to load the stream.

Create an HTML page that looks something like this:

<html>
<head>
<title>My stream</title>
</head>
<body>
<!--- BEGIN PLAYER --->
<!-- webbot bot="HTMLMarkup" startspan ---->
<object ID="MediaPlayer" WIDTH="320" HEIGHT="240" CLASSID="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" STANDBY="Loading Windows Media Player components..." TYPE="application/x-oleobject" CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112">
<param name="autoStart" value="True">
<param name="filename" value="http://your-ip-or-url:port">
<param NAME="ShowControls" VALUE="False">
<param NAME="ShowStatusBar" VALUE="False">
<embed TYPE="application/x-mplayer2" SRC="http://your-ip-or-url:port" NAME="MediaPlayer" WIDTH="320" HEIGHT="240" autostart="1" showcontrols="0"></embed></object>
<!-- webbot bot="HTMLMarkup" endspan ---->
<!--- end PLAYER --->
</body>
</html>

Obviously, you’ll want to replace the “http://your-ip-or-url:port” with your IP address or URL, and the port number you’ve chosen.

Save the file and load it up in Internet Explorer. It will take a few seconds to buffer the stream, but you should be loaded and ready to go.

If you want to get really fancy and have access to some kind of server-side technology (PHP, Java, ASP, etc.), you can setup a login interface so that you can control who can see your stream. The server where I’m hosting my stream allows SSL, so I also have it encrypted.

Julie over at The Gadgeteer is sending me a couple of webcams to review for her site. With those and the other USB cameras I already have, I’m thinking about setting up a little home surveillance system I can log into from work. I haven’t really done much with webcams before now, but with Windows Media Encoder and enough bandwidth, the possibilities are endless.

Happy streaming!

19 Responses to “Setup a webcam stream in ten minutes”
  1. Brando IP Security Camera Review · TechBlogger Says:

    [...] a big fan of webcams. Once I figured out how to broadcast a webcam stream on a webpage, I started broadcasting from work so that my mom and friends could see me. One idea I had related [...]

  2. Mel Says:

    Hello

    I do not use windows media player and do not want to install it. I also have not written code since the Commodore 64. I use Real player or VLC media player instead. I tried your 10 min web Cam setup. The part using windos media encoder went well up to the broadcast connection window where I get a “could not detect”. The stream will run and i have feed from my web cam though. I feel it is because of my not having windows media player on my system.

    So can VLC or Real player be used instead of windows media player?. If so how can I do this. Also would you send me a html file for a web page to broadcast it. Or do you know of a download to do this?

    I’m sure there are a lot of people like me out there.

    Thanks for your time. Mel Henzler

  3. Claire Says:

    This route doesn’t require Windows Media Player – it uses another piece of free software from Microsoft called Windows Media Encoder. The two are pretty much unrelated aside from similar brand names.

    Are you behind a firewall (router, etc.)? You need to make sure that (a) Windows Media Encoder is an exception in the Windows firewall, and (b) you’ve opened the appropriate port on your router’s NAT. If you’re doing this from work, it could very well be that outgoing ports are restricted to only a few (usually 80, 443, and 21), so it won’t work.

    This definitely isn’t the most elegant or platform-independent solution out there, but it’s the fastest and easiest I’ve found for a quick-and-dirty method of getting a stream going.

  4. Sarah Says:

    could i publish this to any website? Will it work on wordpress? What about one of those free hosting sites like geocities?

  5. Claire Says:

    This will work on any server that allows using the OBJECT and EMBED tags. You can use it within WordPress if your server supports that. It’s unlikely to work on a site like Geocities, but you can always try!

  6. Rodney Turner Says:

    Thank you so much for your post. It give me something else to do with my web camera, besides talking to my mom in Korea.
    Here is one of the applications: techyturner.blogspot.com

    FYI, you are now in my Reader!
    Thanks again.

  7. DIANA Says:

    Hello,

    I found this site today while looking for solutions to my web cam problems. I was curious to see if and when you might be posting about how to get a video chat to work well as obviously I can’t. (I’m computer illiterate so second grade english would be appreciated should you do the post!)

    Thank you :)

  8. Claire Says:

    Diana,

    Video chat is very easy to do. I would recommend using Windows Live Messenger if you’re going to be chatting with someone else using Windows. If you’re talking to a Mac or Linux user, Skype works very well.

  9. DIANA Says:

    Hi Claire! I do use WLM…my HP touchsmart has a built in cam…streaming is very slow and choppy (definitely not ‘real time’)and gets annoying …I also tried to set up a moveable cam as the angle in the built in one is not user friendly but that one won’t even turn on after selecting it from messenger setup. I tried turning off the firewall too with no success…any advice would be greatly appreciated!
    (Would changing over to SKype help any? My cable co is my isp)

  10. Glen Says:

    Nice work. Easy to follow and very easy to setup. Now I can keep an eye on my dogs at home.

  11. Arjen Says:

    Thanks it worked great!

  12. asif Says:

    please explain me why i get this:

    URL for internet connections: (could not detect)

  13. Claire Says:

    Diana,

    I’m not sure what your problem is. There might be something else on your network that’s slowing things down, or your ISP might be having problems. Do other streaming apps work okay? Try using this Windows Media Encoder method instead of WLM. You might also tweak the WLM settings for your video stream and see if that helps.

    Asif,

    Did you set the connection to your localhost IP? (e.g. 127.0.0.1)? If that doesn’t work, I’m not certain what to tell you, since that’s the setting I used.

  14. x mplayer2 Says:

    [...] machine in Gutsy (Ubuntu 7.10) How to turn off the annoying system beep in linux (Debian/Ubuntu) …A Better Geek :: Setup a webcam stream in ten minutesOS X users can open the stream in VLC Media Player, but Safari is generally not … OS X. Windows. [...]

  15. Teri Says:

    Thanks for this info. It worked great. I let it find an open port, will look into the dynamic one later. Used the VLC media player. Worked for both the lan and internet. Fun. Thanks again for the turtorial. Even tho this is an old thread, I am using a netbook with windows 7 starter and was concerned about compatability, but no problem there.

  16. Citygum Says:

    Hi,the URL for internet connection chosen by wme is 127.0.0.1 which is different from the real ip 192.168…etc. so which URL:port we should use to watch the video???
    Thank you

  17. Adel Says:

    I opened the webpage using internet explorer , i ‘ve got the windows media player on the page but the streaming doesn’t work for some reason .Please dear friends , could you tell me what’s wrong ?

  18. Claire Says:

    A few things to check – if you are accessing the page over the Internet, make sure the right port is open on the firewall of the network hosting the camera. If you’re accessing the page on your local network, make sure the Windows firewall isn’t blocking anything, and make sure that Windows Media Encoder is running and you can see your stream.

  19. Andrew Says:

    I got this to work after about an hour of tinkering… Save this as an HTML document, create an account for http://www.dropbox.com. save in your public folder and share. Works great!

Leave a Reply


7 − five =

Google Ads