Linux‎ > ‎

Agasio A622W and Motion

Notes I've taken while getting Agasio A622W Outdoor Pan/Tilt Wireless IP Camera working with Motion software.

Camera

I was looking for a wireless IP camera to install outdoors and came across the Agasio A622W on Amazon that had a good price/feature combo.  I would have preferred to get a well known Foscam model but decided to give this one a chance since it got good reviews and was actually sold by Foscam.  There is a good chance this is just a rebadged Foscam FI8919W anyways.  Sometimes these cheap Chinese IP cameras are not only simple rebadges but also make minor part changes so I'm not up for trying to using Foscam's updated firmware on the Agasio.

Since the camera is running embedded Linux, it would be nice to do some of the work I'm doing on a Linux server on the camera itself.  I've not tried customizing the firmware but it may be possible according to Open IPCAM website.  Real Foscam's seem to be supported for modification.

Setup was pretty straight forward.  I do have to run the camera at 320x240 or lower resolution or else the wireless connection gets backed up and causes some graphical glitches that can only be solved by a camera reboot.  I actually found this work around by reading the Foscam forums.

The two other main negatives you'll find in reviews is that when the camera reboots, it moves to center position instead of the first preset location and also the IR light used by night vision reflects off the camera cover and causes the picture distance to be reduced.  Some people have reported disconnecting the IR LED's internally and then using an external IR flood light to improve distance.

Hidden Settings

The Web GUI does not expose all possible settings.  All settings can be set and retrieved using URL's and most are documented in IPCAM CGI SDK 2.1 while a few require trial and error testing.

One of the complainst is that the camera returns to center upon reboot instead of a preset.  I'm sure sales have been lost because of this complaint but you can actually fix it using the command line.  The following will cause the camera to move to preset 1 upon restart.  A value of 0 means disable this setting.  You'll need to set ${USERNAME} and ${PASSWORD} correctly.  I believe you can also pass in username and password using http://${USERNAME}:${PASSWORD}@192.168.1.99 syntax but doesn't seem worth while in this case.

/usr/bin/wget --quiet -O - "http://192.168.1.99:99/set_misc.cgi?ptz_preset_onstart=1&user=${USERNAME}&pwd=${PASSWORD}"

If you want to trigger a server to do extra processing when motion alarm event occurs on camear, you can have the camera access a remote URL.  This means you need to write a mini-web server to monitor for this access.  Example of command and related cnofig parameters to enable that:

/usr/bin/wget --quiet -O - "http://192.168.1.99:99/set_params.cgi?alarm_http=1&alarm_http_url='http://192.168.1.XX:XXXX/trigger.cgi'&user=${USERNAME}&pwd=${PASSWORD}"

Command Line Control

Presets

Before I found out about the hidden ptz_preset_onstart option, I automated forcing to preset location 1 always.  Even though I don't need it for that purpose, its some times convient to switch presets from the command line. The following can be used for that. You'll need to set ${PRESET}, ${USERNAME} and ${PASSWORD} correctly.  If you want to use a present higher than 9 then you'll need to update this logic.  The "command=" takes a value of 30 + preset # so command=40 would be preset 10.

/usr/bin/wget --quiet -O - "http://192.168.1.99:99/decoder_control.cgi?command=3${PRESET}&user=${USERNAME}&pwd=${PASSWORD}" > /dev/null

The above command can be put in a hourly or daily cron tab if you want the camera to automatically recover from reboots.

Video Stream Capture

You can capture the video stream straight to disk if you like using the following URL.  Its also the value to use in Motion's netcam_url option.  The most interesting part is the "rate=" keyword.  Without any option, the camera streams as fast as it can (around 25-30 fps) which is overkill for most video survallence and can contribute to both wireless network congestion and graphical glitches.  The rate parameter lets you limit the frame rate.  Since I'm now using a frame rate of 10 per second; I saw more than a 1/2 wireless bandwidth reduction from the default rate=0 setting.

http://192.168.1.99:99/videostream.cgi?user=${USERNAME}&pwd=${PASSWORD}&rate=6

Other rates:

  • 0 - max frame rate
  • 1 -20 frames per second
  • 3 - 15 fps
  • 6 - 10 fps
  • 11 - 5 fps
  • 12 - 4 fps
  • 13 - 3 fps
  • 14 - 2 fps
  • 15 - 1 fps
  • 17 - 1 frame per 2 seconds
  • 19 - 1 frame per 3 seconds
  • 21 - 1 frame per 4 seconds
  • 23 - 1 frame per 5 seconds

Normally, I set the video resolution using the web interface but there is also a parameter for it:

  • resolution=2 - 160x120
  • resolution=8 - 320x240
  • resolution=32 - 640x480

Most things can be set or retrieved using URL's and most are documented in IPCAM CGI SDK 2.1. Several things; such as the rate= parameter; are not documented.  Most those were found by various people browsing the javascript from different camera models and some trail and error.  Most URL's that you find for ZoneMinder or Motion for Foscam camera's will also work for this camera.

Motion Image and Video Cleanup

I have motion configured to save a jpg image of motion event as well as an mpg video stream.  They are all dumped into /var/motion and this can quickly become hard to browse.

I use the following script ran daily to help cleanup.  It does two things:

  1. Delete files older the 90 days.
  2. Move files older than a day into subdirectories that have a naming convention of "year-month/day".

So you can see today's events by setting your file browser to /var/motion and then see older events by navigating the folders.

#!/bin/sh

MOTION_PATH=/var/motion

for fn in `/usr/bin/find ${MOTION_PATH} -depth -daystart -mtime +90`; do
  /usr/bin/rm -fr "$fn"
done

for fn in `/usr/bin/find ${MOTION_PATH} -maxdepth 1 -daystart -mtime +1 -type f`; do
  dir_path=`/usr/bin/dirname ${fn}`
  month_day_path=`date -r "${fn}" +%Y-%m/%d`
  new_dir_path=${dir_path}/${month_day_path}
  /usr/bin/mkdir -p ${new_dir_path}
  /usr/bin/mv ${fn} ${new_dir_path}
done

Eventually, I plan to use this script as basis to also move it to a drive visible from internet; perhaps something simple like dropbox or google drive.
Comments