View Full Version : Embed mjpg Webcam?

Jun 28th, 2010, 03:58 PM

I'm trying to embed a motion JPEG (.mjpg) webcam stream into a webpage.
I the an IP address followed by the filename and extension. Simply entering this into the address bar in Firefox displays the image, but I need a way to embed it to work in all browsers.

Can anyone help?

Jun 28th, 2010, 04:24 PM
Many webcams cater to the browser that is being used. IE needs a video stream where as other browsers can use the image stream. What webcam is it? And does it have more than one stream available ie a movie stream? If you go to the ip address in your browser and view the source you can see how they determine what stream to display.

Jun 28th, 2010, 04:34 PM
They are using an AXIS 241S with an ActiveX plugin.
I was hoping not to use any plugins as our firewall wont allow most users to install it.

I think I need to go back to the guys who set the camera up and ask for a jpeg image option. Then I can refresh the image using javscript, hopefully without any plugins.

Jun 28th, 2010, 04:53 PM
You won't need any plugins. If you have access to the admin area of the camera you can modify how it will display the video. I used an axis 207mw and it had an area in the admin that gave you the html you could use to put on your own pages.

Jun 29th, 2010, 08:50 AM
Thanks _Aerospace_Eng_,
I'll contact the admin guys and see if they can help.

Jun 29th, 2010, 10:23 AM
Here is the code I'm using from the Axis website:


It basically loads an activex object for IE or shows the mjpg as a direct image in all other browsers.
The problem for IE is the 1st time the page is loaded, you get the "Install this software?" security dialog. This will be blocked by our firewall for most users.
I can allow this through, but is there a way to avoid the install completely?
Its a shame IE cant just show the mjpg like every other browser can!

Jun 29th, 2010, 02:56 PM
The only other way would be to make the camera use java to display the video. I'm not sure what features your camera has but I'm pretty sure that is what we did with the axis camera we used. We made the camera use java to display any video or images. I'm not sure though if it will ask the user to allow the java install. This is from the user manual for the 241S

If your workstation restricts the use of additional software components, the AXIS 241Q/241S can be configured to use a Java applet for updating JPEG images. Please see the online help for more information

Jun 29th, 2010, 03:54 PM
Thanks for the info.
I've managed to work around the firewall problem by saving the codebase cab file to our server and pointing the code to that. Now all users get the popup to install the plugin.

Is there a way in javascript to detect if a particular plugin is installed on the client's computer? The plan is to show a bit of text explaining that they need to click on "install" and that it is safe to do so.
I originally just has a cookie to detect if the client had visited the page before i.e. if 1st visit, set the cookie to 1 and display the "you must click on install" text.
This is fine, but it doesn't take into account it the client clicks on "dont install" but then comes back to the site later, or reads the "you must click on install" after clicking on "dont install" and reloads the page.

Jun 29th, 2010, 05:29 PM
It depends on the browser. Most of the modern ones have a list of plugins it has available to it. I'm not sure if the activex plugin or whatever plugin you use will show up in this list. You can put this in an html page

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>


<script type="text/javascript">

numPlugins = navigator.plugins.length;
if (numPlugins > 0)
document.writeln("<b><font size=+3>Installed plug-ins</font></b><br>");
document.writeln("<b><font size=+2>No plug-ins ");
document.writeln("are installed.</font></b><br>");
for (i = 0; i < numPlugins; i++) {
plugin = navigator.plugins[i];
document.write("<center><font size=+1><b>");
document.writeln("<dd>File name:");
document.writeln("<table width=100% border=2 cellpadding=5>");
document.writeln("<th width=20%><font size=-1>Mime Type</font></th>");
document.writeln("<th width=50%><font size=-1>Description</font></th>");
document.writeln("<th width=20%><font size=-1>Suffixes</font></th>");
document.writeln("<th><font size=-1>Enabled</th>");
numTypes = plugin.length;
for (j = 0; j < numTypes; j++) {
mimetype = plugin[j];
if (mimetype) {
enabled = "No";
enabledPlugin = mimetype.enabledPlugin;
if (enabledPlugin && (enabledPlugin.name == plugin.name))
enabled = "Yes";
document.writeln("<tr align=center>");

Run it on a system that you know has the plugin installed and see what it says.

Jun 30th, 2010, 11:15 AM
Thanks for your continued support _Aerospace_Eng_.

navigator.plugins doesn't seem to be accessible by IE. IE is the only browser I need to target.

From what I've read here:

Its is possible to check in IE using VBScript. For example, the following checks (boolean) for Flash 10

checkForSW10 = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.1")))

I've modified this to check for the Axis plugin

<script type="text/vbscript">
checkForAxis = (IsObject(CreateObject("AxisMediaControlEmb.AxisMediaControlEmb.1")))
if checkForAxis = true then
document.write("<br><b>Axis installed.</b>")
document.write("<br><b>Axis NOT installed.</b>")
end if

This works fine on my computers where the plugin is already installed, but on a computer that hasn't already got it I get "ActiveX component can't create object" script error. Strange. I would have expected this error for both rather than just one? So close!

I'll try uninstalling the plugin on my computer and run the script again.