Registered a URL and setup a forum as the IPCam stuff really needed its own site vs my irregular blog posts about IPCam hacking at

Author Topic: Foscam and Clones CGI Interface Examples Shown Here  (Read 48723 times)

  • ***
November 06, 2012, 10:34:20 am

While I know the focus is on firmware here, these examples, maybe helpful examples for ideas when modifying any Web/UI firmware, for these cameras or even other cameras.

I have created many examples that use the CGI interfaces for Foscam, Wansview, other brands and clones of these MJPEG based cameras and for H.264 based cameras using Chipsets Hi351x and GM812x. All but one of the tools ("Record video and audio on alarms"), work with any Internet browser capable device, runnning on any OS ("Operating System"), using any browser.

These examples are all HTML or HTA based ("Record video and audio on alarms"), using JavaScript. So you can peek at all of the source code, for any of them, to see how things were done, very easily.

Generic Browser Interface for MJPEG Based Cameras

This Interface works with many different brands and non-branded models and clones of MJPEG based cameras, including but not limited to Foscam, Wansview, other brands and clones. HTTP 200 response headers for these cameras, will have a "Server: Netwave IP Camera" in their Miscellaneous section of their HTTP 200 response header. This is the second best method to determine if your camera will work with this Interface. You can use tools like Fiddler to view HTTP information, from/to your cameras or even Wireshark. It maybe easier to simply try as the best method, using this Interface with your own cameras, which is suppported in real-time via the link below.

The goals when creating this Interface, were to truly make a single generic browser based Interface, that could not only view these camera but also control and configure these cameras, based on User Id Level of Visitor, Operator or Admin. From any Internet browser capable devices, including computers, tablets, phones and TVs running on any OS ("Operating System") and using any browser. Optionally also allowing, going from one camera to the next, using 1 click to manage all your cameras, using the Multiple Device list supported by these cameras. Supporting the ability to embed the same Interface, in web pages, if desired, for one or many cameras, that will work for any Internet browser capable device, that visits/views your web pages. To be able to use the Interface, for tuning the maximum FPS ("Frames Per Second") rates, you can get from these cameras, by using the real-time statistics provided by this Interface, from any Internet browser capable device.

Using This Interface To Tune Your Cameras FPS Rates

Statistics can be enabled/disabled with this Interface. Statistics can show current FPS ("Frame Per Second") rates as well as Bps ("Bytes Per Second") rates ("Bps rates will only show with IE based browsers"). This can be very helpful when installing or moving or repositioning a Router/AP or Camera, or their antennas for optimal wireless communications. To see your changes, in real-time of any benefits of doing so. Statistics are averaged every 5 seconds. You can also decrease/increase this average, using the Interface configuration options.

It's extremely important to first make sure there is no wireless contention going on with your wireless networks and nearby wireless networks if the cameras in question are in wireless mode, not wired mode. There are many tools to do this, it depends on the operating system you will be using to do tuning from. Some are free others are not. One example is inSSIDer, which has versions for virtually all operating systems, some versions are free, others are at cost.

Linux (free):

Windows (free), Mac (cost), Android (cost):

Documentation on Optimizing Wireless Networks:

If possible, it's best to use tools like the above, not only checking at the host Router/AP location, but also using a laptop or other mobile device at each camera location as well, because other nearby wireless networks, maybe stronger at the camera locations, then they are at the hosting Router/AP location.

When using this Interface to tune wireless communications between cameras and a Router/AP, its best to use a video resolution of 160*120 and an Internal FPS rate of 30, as Interface selections. This will allow you to reach the maximum FPS rates, with your cameras, while doing your tuning.

Most of these cameras come with a short 3dBi gain wireless antenna, it's possible to get 9dBi antennas for these cameras. Every 3dBi gain is a 100 percent "theoretical" increase. In real life, this is closer to 50-75 percent but, if your Router/AP signal is weak, your Router/AP can impact the results of any performace increase in FPS rates between the Router/AP and your cameras when using higher performace antennas.

Generally, these cameras, in wireless mode, will be in the range of 3-12 maximum FPS rates, when using a 160*120 video resolution, with this Interface. This is normal. The end-goal, is to get the highest FPS rates possible, while tuning. These cameras can produce highest FPS rates when using 802.11b or 802.11g wireless modes and WEP wireless security with their host Router/AP. Of course, some of these cameras support 802.11n and most of these cameras support other forms of wireless security, but there is some internal overhead for the cameras, when doing so, that can cause lower FPS rates.

Documentation on dealing with cameras that drop their connections and/or have very low FPS rates:

Using This Interface To View, Control and Configure Your Cameras

The Internal FPS rate, used in this Interface, is a throttle, more of a maximum rate limit, to try and pull from the camera, than an absolute guaranteed rate. It is an internal setting to this Interface and has no impact on any FPS rate for alarms or with any other applications you may use for your cameras, including the Standard Camera Interface, that comes with these cameras.

Changing video resolutions with this Interface, will in fact change the default video resolution for your camera. So, if you are using this Interface on a device that has a small screen for example or changed the video resolution for tuning and testing, and changed the video resolution to say 160*120, but also want to record video on alarms at a higher video resolution, please remember to change the video resolution to what it should be for video alarm recording when you are done using the Interface before exiting the Interface.

Infinite Zoom is a feature included with this Interface, which you can configure the percentage of zoom to use. You can also set this zoom percentage to zero, to disable infinite zoom.

Here is a side-by-side example of the default User Interface presentations, without any Interface configuration changes, using a 160*120 default video resolution, which can also be 340*240 or 640*480, and a default FPS ("Frames Per Second Rate") of 1, which could be from .1-30 FPS rates, for all user levels of a camera, from left to right: Visitor, Operator and Admin:

Note: The demo above, is using an older version of the Interface. The latest version of this Interface, now has more Admin Level User Id functions. It's simply an example. Default, video resolution size, as well as FPS rates are configuration options that can be set in the Interface. You can also configure, if changing these defaults are allowed as well. If you wish to move the cameras in this example, it would be best to change the FPS rate to 30 from 1 first to see the best fluid movements, in the above example. An Admin User Level, will also see any other cameras defined in that cameras Multi-Device list, and be able to click on the link to those cameras, which will instantly jump to that camera, and then be able to then access any other camera in that cameras, Multi-Device list with one click.

Using This Interface To Embed Cameras In Web Pages

Here is an example of embedding this Interface in a web page. The example is using a 160*120 video resolution ("which could also be configured to be 320*240 or 640*480"), for all 4 cameras. Each camera is being displayed at 1 FPS ("Frame Per Second"), which could also be from .1-30 FPS. Each camera displayed can have different configuration settings, including video size and FPS on the same web page.

The Live Demo below, is using 1 camera to represent all 4 cameras. You can use as many different cameras embedded in the same web page, with this Interface as you wish, not limited to simply 4, with this Interface.

If you try controlling the 2 cameras, of the 4 cameras shown in the Live Demo below, it may seem like camera movement is delayed, this is because of the 1 FPS rate being used to conserve bandwidth for the Live Demo below. The example below, shows how to include cameras in web pages with and without controls. You can also decide which controls to display using the Interface configuration options.

This Interface also has the ability to limit by time, how long your cameras can be viewed by a web page visitor. Once that maximum time has been reached, you can configure this Interface to jump to another web page. This timeout and jump to another web page option, can be set by User Level Id, Visitor, Operator and Admin. Each using different timeouts or no timeouts, each going to different web pages, when that timeout is triggered. You can even use this option, to go to other cameras, in a loop, based on the interval of your choice. With the last cameras timeout, jumping back to the first camera. You can use this feature, without needing a web site.

This Live Demo, gives you an idea of some of the possibilities:

Using This Interface On Any Internet Browser Capable Device

You can easily try the examples above using any Internet browser capable device and you will see that they work. After all, you want all your web page visitors, using any device, runnning any OS ("Operating System"), using any browser, to be able to see your cameras on your web page, not just "Some of them" or only 4 of them at a time. See below about this maximum of 4 limitation.

One BIG MJPEG IP Camera Secret

Many people, are not aware that these cameras can only support a maximum of 4 open connections that are formally logged in, at any one moment of time. This includes video streams, as well as the Standard Camera Interface, that comes with these cameras and many if not most 3rd party applications for these cameras. Connection requests, received by the cameras while it's at its maximum connection limit, will be refused or hang.

You can emulate this by simply opening the Standard Camera Interface that comes with these cameras, in 4 different browser windows, logging on in each window and then attempting, to do the same in a 5th browser window. You can also emulate this by creating 4 video streams to the camera at the same time, and then trying to create a 5th video stream.

This can cause you to be "Locked Out" of viewing, controlling and configuring your own camera, when and if this takes place. This also is not good news for those that wish to embed their cameras in web pages. Because, using many other methods, including direct video streams from cameras, to web page visitors devices, only 4 web page visitors, would be able to view your cameras at one time, all other web page visitors will be refused access or their request will simply hang.

Because of the methods used in this Interface. It never formally does a logon to the camera. This means that there is no such maximum limit when using this Interface or placing this Interface in web pages. This also means you can use this Interface to access your camera when it has reached the maximum connection limit as well. When you are refused to connect to your cameras because this maximum limit has been reached. You can open any of the Interface examples here, or use any of the Live Demos for this Interface, at the link below, being opened up in multiple browser windows, on the same or different devices, at the same time, to prove this point.

Using This Interface As Visitor, Operator And Admin User Levels

The UI ("User Interface") of this Interface, as you can see by the examples above or any of the 10 Live Demos from the link below, is presented differently, depending on what User Level you are using with the Interface. It's all the same code used to do the different UI presentations, based on User Level. There are many configuration options in this Interface, that also allow you to control what functions the Interface will support, as well as what the UI looks like.

Visitor User Ids can only view the camera, Operator User Ids can control the camera. Admin User Ids can do all the other things the other User Ids can do, plus configure the camera. This Interface supports the ability to define what controls will be available to Operator User Level Ids using the Interface. This allows you to define and configure, a subset of the normal Operator Level User Id controls, that are normally available when using the Standard Camera Interface as an Operator User Level Id, that comes with these cameras.

The Interface suppports both prompt for logon and automatic logon to the camera. Your Choice. You can make as many copies of the Interface you need, for the same or different cameras, using different Interface configuration options.

Using This Interface To Access The Multiple Device List

This Interface also is able to use the cameras Multi-Device list when using a Admin Level User Id with this Interface, which the Standard Camera Interface, that comes with these cameras, only displays in IE ("Internet Explore") browsers as a menu option, from any Internet browser capable device running on any OS ("Operating System") using any browser.

Using This Interface To Access Hidden IP Camera Functions

These cameras support many functions natively, in their firmware, that the Standard Camera Interface, that comes with the camera, does not have any UI ("User Interface") for. These Include:
  • Use 160*120 Video Resolution not only 320*240 or 640*480
  • Sound Dectection and Sound Detection Sensitivity Alarms
  • Forbidden Schedule to set times of days video and image capture is not allowed
  • FTP Now Schedule to set times of days and intervals of images to be sent via FTP
  • Alarm Input/Output set a open or closed circuit result on alarms
  • Go To Preset on alarms
  • Go To HTTP Address on alarms
  • Multi-Device List ("From Non-IE Based Browsers")
  • Display Internal Camera Configuration settings
  • Display Internal Camera Miscellaneous settings
  • Display Internal Camera Status
  • Display Internal Camera Parameters
This Interface has a UI ("User Interface") to access these functions and settings that normally are unreachable using the Standard Camera Interface that comes with these cameras. Currently this Interface does not have a UI ("User Interface") to set/define the Forbidden or FTP Now Schedules, you can use .cgi commands to do this, if needed. However, once those schedules are defined, this Interface does currently support enabling/disabling them.

Using This Interface From Anywhere At Anytime

Even if you do not have a web server to park a copy of this Interface at. So that you always have access to this Interface, no matter where you happen to be at the time, or what Internet browser capable devices, you have access to at that time. You can easily add this Interface as an Email attachment and send an Email to yourself, this way, all you need to do is access your Email at anytime, download the attachment, then use the Interface on the device in question.

Try 10 Live Demos Using This Interface And Download Your Free Copy

The are 10 example Live Demos including the ability to use your own cameras, without the need to first download and customize your own copy of the Interface first, which should be done for long term use.

More Here:

How Much Bandwidth Can My MJPEG Camera Use? Demonstration Interface

A special version of the Interface above, was created to show how many bytes would be used by 1 connection to the camera, at a specific video resolution and FPS ("Frames Per Second") rate, over a 30 day period of time, if that connection was viewing the camera 24/7 during that time.

Both a live demo as well as a special copy of the above Interface for download, for your cameras, are show there, so that you can also do the same test, with your own cameras.

Many of us have devices and/or an ISP that have maximum byte limits per month, that can cause those accounts to charge more, or even suspend an accounnt, if this maximum limit is exceeded.

Link to calculate 30 day byte rates:

It's important to note that these Byte totals over 30 days are for 1 connection, 24/7 for 30 days. If you have for example, cameras embedded in web pages, then this Byte count could be much higher, depending on how many visitors over that 30 day period, 24/7 could be viewing your cameras, at any given moments in time. This is why having the ability to control the FPS ("Frames Per Second") rates for your cameras which are being publicly accessed, or embedded in web pages, is so important.

Generic Browser Interface for Hi35xx Chipset Based H.264 Cameras

The CGI Interface for these cameras, is nowhere near as mature as the CGI Interface for the MJPEG based cameras. So this example does not have all the same features that the MJPEG version, currently does. As the CGI interface for the H.264 based cameras becomes as capable to use as the MJPEG version of same, it will be updated.

More Here:

Use a Preset and Patrol Loop for MJPEG Based Cameras

You can have as many as 16 different Presets, only 4 of them are accessible and presented via the Standard Camera Interface, that comes with the cameras. So why can't you chain them together, anyway you wish, with your own delay times, between them, so your camera can focus on important areas in its view vs. only being able to do vertical and/or horizontal patrols, that might be covering many dead areas?

Decided to do something about this and create an Interface, that you can jump from Preset to Preset using your own delay times, in an infinite loop, with any delay between loops you wish. You can also chain vertical and horizontal patrols in the mix of Presets, also, with your own delay times.

The list is expandable, so there is no limit to the number of presets or patrols you can use and configure, you can use any Preset and/or patrol, as many times as you wish in the loop.

More Here:

Record Video with Audio on Alarms for MJPEG Based Cameras for as many as 10 Cameras at the same time.

The Standard Camera Interface that comes with these cameras, requires you use an IE ("Internet Explorer") browser window, which needs to be open at all times, 1 IE browser window per camera must be open at all times, in order to capture video recordings on alarms for that camera. That said, these alarm based video recordings are video only, and are a fixed 60 seconds in length, which cannot be made shorter or longer, which is considered the alarm period.

This Interface can monitor alarms and record both video and audio on alarms, for as many as 10 different cameras, at the same time, only using 1 window. With each camera, having their unique video recording configurations. Each camera can be set to record from 1 second to as many seconds, minutes, hours or days, once an alarm takes place as you wish. Each camera can record at 160*120, 320*240 or 640*480 video resolution and each camera can record at a specified FPS rate, defined and configured on a per camera basis.

It's important to note that these cameras natively, in their firmware, also support sound detection, but there is no UI ("User Interface") in the Standard Camera Interface to be able to enable/disable or set sound detection sensitivity. In the "Generic Browser Interface for MJPEG Based Cameras" Interface, I listed above, I added a UI to that Interface, to be able to do this and use the sound detection features of these cameras.

So now, your camera can start recording video with audio, as soon as your cameras hears a noise vs. only after it detects motion, in the cameras "frame of view".

More Here:

Generic Browser Interface for Grain Media Based H.264 Cameras Using GM812x Chipsets

These cameras far exceed the video capabilities of any Hi35xx chipset based cameras that Foscam and Wansview, other brands of IP cameras and some clones use for their H.264 based cameras. Their maximum video resolution is 1280*720 as well.

This example is a work in progress and not perfect. I also have the SDK for these cameras as well.

Example GM8126 Chipset based H.264 camera with no controls:

The above example also supports infinite zoom, by single left-clicking on the image and double left-clicking on the image, to reset video size. You can see how clear the images are even when using zooms that zoom at 50 percent, each zoom, compared to other H.264 based cameras.

Hopefully, these examples, will contribute to some more good ideas, for future Web UI firmware modifications.

If you have any questions about these Interface examples. Please ask.

About Me:

« Last Edit: November 11, 2012, 05:54:37 pm by TheUberOverLord »

  • ***
February 02, 2013, 01:12:55 pm

The first version of a generic Interface for the NEW Foscam IP Camera models FI9821W FI9801W FI9802W has been created.

Live Demos are also included in the link below.

More here:

This free Interface allows you to access and control these IP Camera models from ANY Internet browser capable device, that is running on any Operating System and using any browser. From Computers to Tablets, to Phones and TVs.