Blog

Archive for January 2008

See Also Part 1: Using Linksys WVC54GC Webcam with Linux and related article How to use the WVC54GC wireless webcam with Firefox

Introduction

Motion detection and capture is a little more complex as it requires you to configure several pieces of software to run together. A widely used motion detection software Motion cannot directly use the stream from the Compact Wireless-G Internet Video Camera WVC54GC, so its necessary to re-stream it using ffserver, part of the ffmpeg suite, into a format understood by motion, which is multipart JPEG (or mjpeg)

Setting up ffserver restreaming

Ffserver, is part of the ffmpeg sweat, and is a streaming server for both audio and video files. It can stream both live video as well as video from a file, likewise it can but a time delay on a live video stream. To set up restreaming, it is necessary to set up both the streaming server and the inbound stream from the WVC54GC Wireless webcam.

Configuring and running ffserver

Below is a sample ffserver configuration which sets up a stream ready for the WVC54GC. Its location depends on your Linux distribution. I use Gentoo Linux, so its found at: /etc/ffserver.conf


# Port on which the server is listening. You must select a different<
# port from your standard HTTP web server if it is running on the same
# computer.
Port 8090

# Address on which the server is bound. Only useful if you have
# several network interfaces.
BindAddress 0.0.0.0

# Number of simultaneous requests that can be handled. Since FFServer
# is very fast, it is more likely that you will want to leave this high
# and use MaxBandwidth, below.
MaxClients 1000

# This the maximum amount of kbit/sec that you are prepared to
# consume when streaming to clients.
MaxBandwidth 10000

# Access log file (uses standard Apache log file format)
# '-' is the standard output.
CustomLog -

# Suppress that if you want to launch ffserver as a daemon.
NoDaemon

##################################################################
# Definition of the live feeds. Each live feed contains one video
# and/or audio sequence coming from an ffmpeg encoder or another
# ffserver. This sequence may be encoded simultaneously with several
# codecs at several resolutions.

<Feed feed1.ffm>

# You must use 'ffmpeg' to send a live feed to ffserver. In this
# example, you can type:
#
# ffmpeg http://localhost:8090/feed1.ffm

# Only allow connections from localhost to the feed.
ACL allow 127.0.0.1

</Feed>

# Multipart JPEG

<Stream test1.mjpeg>
Feed feed1.ffm
Format mpjpeg
VideoFrameRate 4
VideoIntraOnly
VideoSize 320x240
VideoBitRate 900
NoAudio
Strict -1
</Stream>

<Stream stat.html>
Format status

# Only allow local people to get the status
ACL allow localhost
#My Local network – change this to yours
ACL allow 10.0.0.0 10.0.255.255

</Stream>

Once you have saved the configuration file, you will need to start both the streaming server, and a copy ffmpeg which actually streams the content into the streaming server.

1) Start the ffmpeg server, from the bash command shell type:

	ffserver

This will start the server. Typically the server can run as a daemon, running in the backgournd. However using the above configuration, it will stay in the foreground making debugging rather easier. Later when you have everything working you can change the “NoDaemon” setting in the file /etc/ffserver.conf


2) Since this command doesn't return, you will have to use another bash command shell window

ffmpeg -an -i http://yourwebcam.up/img/video.asf http://localhost:8090/feed1.ffm


This will take the output from the WVC54GC and stream it into the streaming server.

Configuring Motion to use ffserver stream

The motion software has a huge number of configuration possibilities, most of which you can leave as default – and all of which are well documented in the motion's sample config file and documentation. It even has the possibility of running more than one webcam, each detecting motion on different threads.

Below is a fragment of a motion configuration file showing the settings specific to the camera, most of the other settings about how to encode, where to save the files and so on are not included here; I recommended you take a look at the motion website for a full description of the configuration options.



Threshold 40
# Image width (pixels). Valid range: Camera dependent, default: 352
width 640

# Image height (pixels). Valid range: Camera dependent, default: 288
height 480

# Maximum number of frames to be captured per second.
# Valid range: 2-100. Default: 100 (almost no limit).
framerate 2

# URL to use if you are using a network camera, size will be autodetected (incl http://)
# Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined
netcam_url http://localhost:8090/test1.mjpeg


# Let motion regulate the brightness of a video device (default: off).
# The auto_brightness feature uses the brightness option as its target value.
# If brightness is zero auto_brightness will adjust to average brightness value 128.
# Only recommended for cameras without auto brightness
auto_brightness off

# Set the initial brightness of a video device.
# If auto_brightness is enabled, this value defines the average brightness level
# which Motion will try and adjust to.
# Valid range 0-255, default 0 = disabled
brightness 32

# Set the contrast of a video device.
# Valid range 0-255, default 0 = disabled
contrast 0

# Set the saturation of a video device.
# Valid range 0-255, default 0 = disabled
saturation 0

# Set the hue of a video device (NTSC feature).
# Valid range 0-255, default 0 = disabled
hue 0


############################################################
# Live Webcam Server
############################################################

# The mini-http server listens to this port for requests (default: 0 = disabled)
webcam_port 8082

# Quality of the jpeg images produced (default: 50)
webcam_quality 50

# Output frames at 1 fps when no motion is detected and increase to the
# rate given by webcam_maxrate when motion is detected (default: off)
webcam_motion off

# Maximum framerate for webcam streams (default: 1)
webcam_maxrate 1

# Restrict webcam connections to localhost only (default: on)
webcam_localhost off

# Limits the number of images per connection (default: 0 = unlimited)
# Number can be defined by multiplying actual webcam rate by desired number of seconds
# Actual webcam rate is the smallest of the numbers framerate and webcam_maxrate
webcam_limit 0

One of the key settings is http://localhost:8090/test1.mjpeg, make sure you change this to point to your ffmpeg server. This is not, then, the URL of the webcam, but the URL of the restreamed video data.

 

See Also Part 1: Using Linksys WVC54GC Webcam with Linux and related article How to use the WVC54GC wireless webcam with Firefox

Posted By: admin on Jan 15, 2008 03:36PM Category:Video Add Comment | View Comments [2]

Google Analytics is an increasingly popular web analytics tool, providing high quality information about visitors to your site, such as how they found you (links, search keywords and so on), where they are from (down to the city in some cases) and which pages they visited and how long they staid on your site. It differs from log analysis (the processing of logs generated by your web server) in that you must have a copy of the Google Analytics Javascript on every page you want analyzed. The Javascript needs to be placed at the very end of your page, just before the closing body tag. With Typo3, this is extremely easy to do, regardless of whether you are using pure TypoScript templates or templates that use HTML, thanks to the 'wrap' property and cascading templates. Below is an example:

After the last line of TypoScript in the Setup section of the web site root template, place code like this:

page.wrap ( 
| <script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-xxxxxx-x");
pageTracker._initData();
pageTracker._trackPageview();
</script>
)

Replace UA-xxxxxx-x with the code found in the Javascript provided by Google Analytics. This example uses the new Google Analytics code replacing the old Urchin code.

Why does this work?

The following code shows how to do multiple line wrap, with all the content placed after the rest of the page content that has already been built by Typo3.

page.wrap ( 
| ...
)


For multiple line values its important that the opening and closing rounded brackets are on their own line or it doesn't take effect, likewise, make sure you don't put in an equals = operator before the first opening curly bracket.

Note: Its recommended to have simulateStaticDocuments or realURL configured to be able to get the best kind of analysis with Google Analytics.

Posted By: admin on Jan 12, 2008 08:42AM Category:Typo3 Add Comment | View Comments [2]

See Also: Part 2: Motion Capture using the WVC54GC Wireless Webcam with Linux and related article How to use the WVC54GC wireless webcam with Firefox

Introduction

The Linksys Compact Wireless-G Internet Video Camera WVC54GC is a linux based wireless webcam with its own streaming web server built in. Windows users can view the video stream through their browser without the need to install any extra software other than allowing the supplied Active-X control to run. Strangely, while the product itself appears to be linux based, and its firmware is open source which you can download from the Linksys website, there isn't much in the documentation about using this camera with Linux.

Installation (setting up the network connection)

The setup tool that comes with it is a windows tool. This is the easiest way to configure the WVC54GC, and of course doesn't prevent you from using the camera from Linux. This was my case, as I have a Windows computer and a Linux computer, and I set the WVC54GC up from Windows, though I tend to use it from Linux. Anyway – if you want to do it from Linux, you can use the following method:

  1. Plug the camera in to your regular network hub, and remove everything else appart from the Linux computer you will be using to configure the Webcam. Temporarily set the IP address of your computer on this interface to 192.168.1.1. The camera should be either at 192.168.1.115. 
  2. Point your browser to the camera's IP address and go to administrator interface - the default username is admin with password admin 
  3. Configure the network, wireless, and image settings, and change the  password.
  4. You can set either an IP address compatible with your network (in the same range) or if you are using a DHCP server (many ADSL routers have one built in and enabled by default) you can select that instead. I actually use a DHCP server which runs on my Linux machine (see the next section).
  5. Change your computers IP address back to normal, unplug the webcam, and plug everything else back in, disconnecting the power to the WVC54GC and then reconnecting it having removed the ethernet cable should be enough to get the camera to start up in wireless mode.

Tip:Use DHCP and DNS

I have one linux computer, used as a server, which is switched on pretty much all of the time, and I run dnsmasq on that. Dnsmasq, which will be the subject of another post, is a combined DHCP and dns server. This works quite well with network devices such as the WVC54GC, since you can set a name, and configure it to request and IP address via DHCP, this name will then resolve correctly on your network. So thats tip 1 really, not necessary to actually use the video camera on your home network (you can always set up the IP address manually), but its certainly a comfortable way of managing the configuration.

Viewing Video

The raw video stream itself is actually available at http://yourwebcamera/img/video.asf. ASF is a Microsoft format – but plenty of Linux software can use it. Its a digital video container format sometimes known as 'Advanced Streaming Format'. The actually encoding of the video is MPEG-4 – a widely used standard. So, while you cannot run the active X control under Linux, you have plenty of choices of software you can use to view the video stream, provided you know where it is. Software you can use include the popular Mplayer, Xine and VLC.

Video Applications

Thats all very well for viewing video, but what about real applications such Video Capture or Motion detection. The Linksys WVC54GC actually has some of this capability built in. It can be configured to detect motion, and email a video fragment to a predefined email address.

Video Still Capture

While the Linksys WVC54GC is first and foremost a video camera, you may want to save snapshots from it from under linux. The video viewing software Mplayer also comes with some tools which allow you to capture video and stills, once you have installed Mplayer, you can issue a command like:

mplayer http://10.0.0.26/img/video.asf -frames 1 -vo jpeg

Obviously, subsitute 10.0.0.26 for the IP or the DNS name of your WVC54GC web camera. Mplayer will save a file 000000001.jpg with a snapshot. Mplayer uses ffmpeg to do the conversion, so you will certainly need that installed too. The best quality image will be achieved if you have set high quality in the Wifi webcams on-line setup page.

Video Capture

Video Capture is just as easy as capturing stills. This can be done with 'ffmpeg' which will have been installed when you installed mplayer, as mplayer has ffmpeg as a dependency. Issue a command like:

ffmpeg -i http://10.0.0.26/img/video.asf -vcodec mjpeg -b 900k test.mjpeg 

Press Q to stop recording. The '-b' option governs the quality (or bitrate) reduce the number to reduce the size of the files that are recorded, however you will see a corresponding decrease in video quality.

See Also: Part 2: Motion Capture using the WVC54GC Wireless Webcam with Linux and related article How to use the WVC54GC wireless webcam with Firefox

Posted By: admin on Jan 07, 2008 03:27PM Category:Video Add Comment | View Comments [2]

AMANDA, the Advanced Maryland Automatic Network Disk Archiver, is software for performing backups that allows the administrator to set up a single master backup server to back up multiple hosts over network to multiple typos of media. It runs on POSIX style operating systems (such as Linux).

While the documentation is very good, I find myself performing some kinds of management operations fairly often outside the regular backups. Here is the Cheat Sheet I use.

I use the filesystem driver, and my backup set is called daily1. You should adjust the commands to suite your situation accordingly i.e. at the very least substitute the name of my backup set with yours :-)

Show the status of all backed up volumes

amoverview daily -skipmissed -last

Remove a tape from the tape cycle?

amrmtape daily daily15

Show a list of which tapes where written on which days.

cat /etc/amanda/daily/tapelist

Count the number of tapes in circulation

wc -l /etc/amanda/daily/tapelist

Flush everything to tape, don't return until finished

amflush -b -f daily

Switch the virtual tape to a selected one? See Also:  http://www.amanda.org/docs/howto-filedriver.html

amtape daily slot 14

or

amtape daily slot next


Quickly label a tape overwriting any label that was there before.

amlabel -f daily daily11 slot 11

Quickly read the contents of an amanda archive

dd if=00007.backuped.up.server._workarea_awstats.0 bs=32k skip=1 | tar tvzf -

Force Level 0 Backups for a Server

amadmin daily force server.to.backup.com /home /boot /opt /var /usr /
Posted By: admin on Jan 07, 2008 03:03PM Category:Backup Add Comment

Has anyone seen the Norton 360 peer to peer user support forums? I have searched all around the Norton site and I cannot find anything. I find that a little surprising as many major software and ICT companies have peer to peer support groups either in the form of mailing lists, newsgroups or forums. I can find forums hosted by Norton for their enterprise products, but no peer to peer groups. If anyone knows where they are, or alternatively is wondering the same thing as me, please leave a comment!

Posted By: admin on Jan 01, 2008 08:32AM Add Comment

Imagine you want to make a backup of everything on your web site, before redeploying your server or moving your site to a different machine, you need to be absolutely confident you have backed everything up, and that your database has not been updated, or mail has not arrived since you started the backup, then you need to shutdown all the services before making the backup. If you are using Plesk, software designed to make server management easier, you can do the shutdown before backing up from the command line. Create yourself a shell script with the following contents:

 

/usr/local/psa/admin/bin/modules/watchdog/wdservice monit stop /usr/local/psa/etc/modules/watchdog/monitrc 
/usr/local/psa/admin/bin/modules/watchdog/wdservice wdcollect stop /usr/local/psa/etc/modules/watchdog/wdcollect.inc.php
/etc/init.d/crond stop
/usr/local/psa/admin/bin/httpsdctl stop
/usr/local/psa/admin/bin/websrvmng --stop
/usr/local/psa/admin/bin/mailmng --stop-qmail-send
/usr/local/psa/admin/bin/mailmng --stop-maild
/etc/init.d/xinetd stop
/etc/init.d/mailman stop
/usr/local/psa/admin/bin/dnsmng --stop
/usr/local/psa/admin/bin/tomcatmng --stop
/usr/local/psa/admin/bin/cfmng --stop
/etc/init.d/mysqld stop
/usr/local/psa/admin/bin/pg_manage --stop
/usr/local/psa/admin/bin/spamd --stop
/usr/local/psa/admin/bin/drwebmng --stop
/etc/init.d/saslauthd stop


Note: The first two lines are actually wrapped (the two commands beginning /usr/local/psa/admin/bin/modules/watchdog/wdservice). These lines are in fact very important to get right as they relate to the watchdog module. The watchdog module is normally very useful, restarting services when they fail for one reason or another, however in the case where you would like to shutdown all your services, the watchdog services need to be shutdown first otherwise they may just restart the other services you wish to shutdown.

The above bash script was tested with Plesk 8.3 and Red Hat Fedora Core 4. You must be logged in as root to be able to execute this script.

If you have any doubts or questions, leave a comment and I'll see if I can help.

Posted By: admin on Jan 01, 2008 08:20AM Category:Plesk Add Comment