User Tools

Site Tools


video:api:foscam_mjpeg

Foscam MJPEG Camera API

This plugin will talk to the older, pre-HD versions of the foscam cameras.

These commands are issued by telling the specific interface to perform the command in the fashion of:

tell xInterface “my ancient camera” to gotoPreset( 4)

Note that your camera may only support a subset of these commands.

Most of these older cameras want the user and password embedded into the URL you are using to either get snapshots or the mjpeg stream. The camera API however needs them to also be filled into the interfaces user and password fields so make sure to fill them in both places if necessary.

In addition to these API commands some information about controlling the resolution and fps via the query string in the request are also available.

/snapshot.cgi?user=&pwd=
/videostream.cgi?user=&pwd=&resolution=&rate=

Resolution:

  • 8: 320*240
  • 32: 640×480

rate:

  • 0: full speed
  • 1: 20 fps
  • 3: 15 fps
  • 6: 10 fps
  • 11: 5 fps
  • 12: 4 fps
  • 13: 3 fps
  • 14: 2 fps
  • 15: 1 fps
  • 17: 1 fp/2s
  • 19: 1 fp/3s
  • 21: 1 fp/4s
  • 23: 1 fp/5s

Camera Video Settings:

Set Brightness

Valid values are from 0 to 255.

setBrightness( 49)

Set Contrast

Valid values are from 0 to 6.

setContrast( 4)

Set IR

Control the IR illumination. Pass True or False.

setIR( True)

Set Flip and Mirror

Control if the image is flipped upside down and/or mirrored left to right. These 2 settings are combined together as one in the camera so you must pass both into this single command. Pass 2 boolean values the first to indicate if the image should be flipped, the second if it should be mirrored. If your camera is mounted upside down you’ll want to pass 2 boolean true.

setFlipMirror( True, True)

Motion and Sound Detection:

By default the plugin will begin scanning the camera for information about Motion and Sound events. Upon the first reception of either a unit will be created in XTension to receive the events and you can use that to perform any scripting based on the event.

If your camera does not support these, if you have them turned off in the camera or if the support is different than what is supported and generates errors you can disable one or the other or both via the following commands:

tell xInterface “doorbell” to enableMotionDetection( [True|False])
tell xInterface “doorbell” to enableSoundDetection( [True|False])

The background processing will be started or stopped as needed. This effects if XTension will scan the camera for events, it does not change the cameras processing of events. Use the next verbs for that.


Motion Detection Commands:

Set Motion

Pass True or False to enable or disable motion detection in the camera. This does not effect the scanning for events in XTension. To turn those on or off use the above enableMotionDetection command.

setMotion( True)

Set Motion Sensitivity

Adjusts the sensitivity of the camera to motion. Valid values are from 0 to 9 with 0 being the highest sensitivity and 9 being the least sensitive.

setMotionSensitivity( 2)

Set Motion Compensation

Some cameras will support motion compensation to try to ignore rapid changes in light level which can otherwise be seen as motion. Valid values are True or False

setMotionCompensation( True)

Sound Detection Commands:

Set Sound

Turns on or off sound detection in the camera if supported. Valid values are True or False.

setSound( True)

Set Sound Sensitivity

Sets the sound level necessary to trigger an event. Valid values are from 0 to 9

setSoundSensitivity( 1)

Pan, Tilt, Zoom and Preset Commands:

Goto Preset

Asks the camera to move to the specified preset. The number of presets available depends on the camera model but the command supports numbers 1 through 16. Note that there is no preset 0.

gotoPreset( 7)

Set Preset

Saves the current PTZ location into the specified preset. The number of presets available depends on the camera model but the command supports numbers 1 through 16. Note that there is no preset 0.

setPreset( 7)

PTZ Center

Asks the camera to center itself.

ptzCenter()

PTZ Up

Asks the camera to tilt up by the specified number of degrees. A degree number is required.

ptzUp( 25)

===PTZ Down===
Tilt down by the specified number of degrees.
<code>
ptzDown( 13)

PTZ Left

Pan left by the specified number of degrees.

ptzLeft( 75)

PTZ Right

Pan right by the specified number of degrees.

ptzRight( 12)

Diagonal Movement

Many of the cameras also support diagonal movement via these 4 commands:

ptzUpLeft( 10)
ptzUpRight( 10)
ptzDownLeft( 10)
ptzDownRight( 10)

PTZ Patrol

ptzUpDownPatrol()
ptzStopUpDown()

ptzLeftRightPatrol()
ptzStopLeftRight()

PTZ Speed

The ptz movement speed can also be set but the change requres a reboot (use the reboot() command below) in order for the effect to take effect. Or at least it does on my camera, yours may be different. Some experimentation may be needed. Valid values are from 0 to 30.

tell xInterface “my old camera”
    ptzSpeed( 25)
    reboot()
end tell

PTZ Goto Preset On Boot

By default most of the cameras will center themselves after they reboot, potentially leaving you looking in the wrong direction after a power hit. You can set which preset you would like the camera to go to after it’s booted and the motors are calibrated. Pass the number of any valid preset you have set from 1 to 16.

ptzPresetOnBoot( 7)

Utility Commands:

Reboot

Takes no parameters, causes the camera to reboot itself.

tell xInterface “my ancient cam” to reboot()

Led Mode

Not to be confused with the IR illumination LEDs controled via the setIR command above this controls the LED’s on the front of the camera, or possibly the LED’s on the network port?. Valid values are from 0 to 2.

  • 0 - Led Mode 1 (dont know what this means exactly)
  • 1 - Led Mode 2 (dont know what this means exactly either)
  • 2 - Leds OFF
setLEDMode( 2)

video/api/foscam_mjpeg.txt · Last modified: 2023/02/13 14:52 by 127.0.0.1