VideoTools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
doxygen.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2017 Graeme Walker
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 // ===
17 ///
18 /// \file doxygen.h
19 ///
20 /* \htmlonly */
21 
22 /*! \mainpage Introduction
23 
24 
25 What is it?
26 -----------
27 VideoTools is software for video surveillance that can record, analyse and
28 replay images from webcams and network cameras. It runs on Linux and BSD
29 Unix, and it is licensed as Open Source under the GPLv3.
30 
31 It can use direcly-attached webcams or network cameras that provide JPEG or
32 H.264 video streams over HTTP or RTP.
33 
34 It is not suitable for entertainment or video conferencing applications
35 because there is no audio or strict time synchronisation.
36 
37 VideoTools does some of the same things as "ZoneMinder" and other programs,
38 so check them out too.
39 
40 How does it work?
41 -----------------
42 VideoTools is made up of several co-operating programs that communicate over
43 the network or through shared-memory channels.
44 
45 The shared-memory publication channels are used for publishing video from
46 one program to another running on the same machine. Each channel has one
47 publisher but any number of subscribers, and once the publisher terminates
48 the channel is deleted.
49 
50 The Linux kernel's "V4L" infrastructure is used to communicate with
51 directly-attached webcams, and standard HTTP or RTSP/RTP protocols are used
52 to communicate with network cameras. Network cameras must use JPEG or H.264
53 encoding, and videotools uses the "libav" library to handle the H.264
54 decoding.
55 
56 Simple motion detection works by looking for pixels that change by more than
57 a set amount from one frame to the next, and then counting those pixels to
58 see if they are more than some threshold number. Motion detection events can
59 be used to control the recording process, or to raise alarms.
60 
61 Video streams are recorded to disk with separate files for each video frame,
62 organised by date and time in a directory hierarchy.
63 
64 A single "viewer" program is used for displaying video in a window. Web
65 browsers can also be used for viewing video served up by the
66 `vt-httpserver` web server.
67 
68 Hardware support
69 ----------------
70 Hardware support for webcams on Linux is dependent on the V4L framework, and
71 other websites should give you an idea whether your hardware will work with
72 V4L. Using the "libv4l" shim library (`./configure --with-libv4l`) might help
73 with more obscure webcam data formats.
74 
75 Network cameras must use either HTTP or RTP. When using HTTP the camera
76 must return one JPEG image for each HTTP GET, or generate a JPEG image stream
77 using the `multipart/x-mixed-replace` content type. When using RTP the camera
78 must return video images with JPEG or H.264 encoding.
79 
80 Build and install
81 -----------------
82 The system can be built and installed with the usual rubric:
83 
84  ./configure ; make ; sudo make install
85 
86 Use your favourite package management tool (apt, pkg, or whatever) to install
87 the following dependencies before running the `configure` script:
88 
89 + libav
90 + libjpeg
91 + xlib
92 + libncurses
93 + libv4l
94 + v4l_compat (BSD)
95 + webcamd (BSD)
96 
97 On some BSD systems you will have to add `CPPFLAGS` and `LDFLAGS` options to the
98 `configure` command to pick up the header files and libraries installed under
99 `/usr/local` or `/opt`. Refer to the `INSTALL` file for more information, or
100 just use the `configure.sh` script instead of `configure`.
101 
102 If there are missing dependencies the build will still go ahead but some
103 features will not be available, so please look for warnings in the output
104 from the `configure` script.
105 
106 The "start/stop" script, which is normally installed under `/etc/init.d` on
107 Linux or `/usr/local/etc/rc.d` on BSD, can be used to start up the server
108 processes, but you must edit its configuration file to tell it exactly what
109 to run.
110 
111 On BSD systems enable the start/stop script by adding the following line to
112 `/etc/rc.conf`:
113 
114  videotools_enable="YES"
115 
116 Instructions for the impatient
117 ------------------------------
118 + Use `vt-httpclient` and `vt-webcamplayer` to obtain
119 video from network cameras and webcams, and send each video stream to its own
120 publication channel.
121 
122 + Forward video streams across the network by running `vt-httpserver`
123 on one side and `vt-httpclient` on the other. Use
124 `--channel=<channel>` on the server's command-line and `vt://<address>`
125 on the client's.
126 
127 + Record video to disk by running `vt-recorder` for each channel.
128 Use a different base directory for each channel, and give each recorder a
129 control socket.
130 
131 + Do motion detection for each channel using `vt-watcher`, and let each
132 watcher control its channel's recorder via the recorder's control socket.
133 
134 + Run `vt-fileplayer` to replay each channel's recordings to a playback
135 channel. Give each fileplayer a control socket.
136 
137 + Run a central `vt-httpserver` web server with `--channel=*` and
138 `gateway=localhost` on the command-line.
139 
140 + Use a web browser with URL paths like `_0`, `_1` etc. to view each channel,
141 and add `?streaming=1` if your browser supports `multipart/x-mixed-replace`.
142 Check out the example HTML code for HTML5 streaming techniques and
143 user-interface ideas.
144 
145 Getting started
146 ---------------
147 Once the videotools system is installed you can try out some of the
148 components by running them from a terminal.
149 
150 Start with the "fileplayer", and specify a directory that contains some
151 static picture files:
152 
153  vt-fileplayer --fade /usr/share
154 
155 This should show all the images in succession and then stop. If running
156 without X Windows then the output will use text characters as pixels filling
157 the whole terminal, so stand back and squint, and use Control-C to quit.
158 
159 Then try the "webcamplayer" in its test mode:
160 
161  vt-webcamplayer --device=test
162 
163 This should show window with a test pattern of moving coloured bars.
164 
165 Next try viewing video from a webcam, or install the Linux "vivi" module if
166 you do not have a webcam attached:
167 
168  sudo modprobe vivi
169  vt-webcamplayer --retry=0 --device=/dev/video0
170 
171 You might need to try different device names (`/dev/video1` etc.) to find the
172 webcam output. You will need root permissions to install the vivi module.
173 
174 Then try viewing the webcam video using a web browser. For this you will need
175 to run the "webcamserver", listening on a free TCP port:
176 
177  vt-webcamserver -v --port=8080 --device=/dev/video0
178 
179 Tell your web browser to connect to the server by putting
180 `http://127.0.0.1:8080` into the address bar. This should show a static image
181 from the webcam.
182 
183 If your web browser supports the `multipart/x-mixed-replace` content type
184 you can get moving video by adding `/?streaming=1` to the URL in the address
185 bar. Alternatively, add `--refresh=1` to the "webcamserver" command-line to
186 get a one second refresh:
187 
188  vt-webcamserver -v --refresh=1 --port=8080 --device=/dev/video0
189 
190 Next you can try viewing the output from a network camera, but you will need
191 to know the full URL for getting JPEG images over HTTP, including any
192 username and password. If you have this information then just run the
193 "httpclient" program with the URL on the command-line, eg:
194 
195  vt-httpclient -v --viewer http://admin:secret@192.168.0.3/streaming/channels/1/httppreview
196 
197 Add the `--scale=3` option if the window is too big.
198 
199 Now try sending video to a publication channel. Use the "httpclient", if
200 that worked, or use "webcamplayer". In either case add `--channel=camera`:
201 
202  vt-httpclient --channel=camera http://...
203 
204  vt-webcamplayer --channel=camera --device=demo
205 
206 View the channel using the "viewer" program:
207 
208  vt-viewer camera
209 
210 Try recording the video from the "camera" channel by running a "recorder",
211 using `/tmp` as the base directory:
212 
213  vt-recorder -v camera /tmp
214 
215 Check for the recorded images under a sub-directory named after the current
216 calendar year, and replay the recorded video with the "fileplayer":
217 
218  find /tmp/20?? -type f
219  vt-fileplayer --loop /tmp/20??
220 
221 Make sure you kill the recorder before it has a chance to fill up your disk.
222 
223 Now try doing motion detection on the "camera" channel by running the
224 "watcher" program:
225 
226  vt-watcher -v --viewer camera
227 
228 You should see a dim, monochrome image with bright green highlights where the
229 image is changing.
230 
231 Create a mask file to define which regions of the image are used for motion
232 detection. Run the "maskeditor" program using the "camera" channel to provide
233 the base image:
234 
235  vt-maskeditor --image-channel=camera /tmp/mask
236 
237 Use the mouse to define the masked regions and close the window when you
238 are done. The new mask file can now be used by the "watcher":
239 
240  vt-watcher -v --viewer --mask=/tmp/mask camera
241 
242 You should see the masked areas in dark red, and the motion detection
243 spots in bright green.
244 
245 Finally, if you have a network camera that can send over RTP and you know its
246 URL scheme, try using the "rtspclient" program to encourage it to transmit:
247 
248  vt-rtscpclient -v rtsp://admin:secret@192.168.0.3:554/streaming/channels/1
249 
250 While the "rtspclient" is still running check that you are getting RTP
251 packets on UDP port 8000 by using "netcat":
252 
253  nc -l -u -4 0 8000 | base64
254 
255 And then try viewing the RTP video stream using the "rtpserver":
256 
257  vt-rtpserver -v --viewer --scale=auto --port=8000
258 
259 Configuration
260 -------------
261 The videotools system is normally configured through the system's `init`
262 system. For each videotools process that you want to run you should construct
263 a complete command-line containing all the relevant command-line options.
264 The options available for each videotools program are described in its `man`
265 page.
266 
267 For traditional script-based `init` systems a videotools start/stop script is
268 installed as `/etc/init.d/videotools` on Linux, and this reads a configuration
269 file `/etc/videotools` containing the list of "run" command-lines. Optional
270 overrides for directory paths etc. are taken from a file
271 `/etc/defaults/videotools`.
272 
273 On BSD systems the relevant files are `/etc/rc.d/videotools`,
274 `/etc/videotools` and `/etc/rc.conf.d/videotools`, but possibly under
275 `/usr/local` or `/opt`.
276 
277 As an example, consider a machine with just one webcam that needs to run a
278 "webcamserver" to capture the video from the webcam and serve it up over
279 HTTP. Its configuration file would have one "run" line, like this:
280 
281  # one webcam serving up jpeg video over http on port 80
282  run vt-webcamserver --port 80 /dev/video0
283 
284 A central file-server machine doing recording, motion detection and
285 web-serving might look more like this:
286 
287  # read from network camera "front" using h.264 encoding over rtp
288  run vt-rtspclient --port=8000 --format-file=$RUNDIR/camera.cfg rtsp://admin:secret@192.168.0.2/streaming/channels/1
289  run vt-rtpserver --port=8000 --format-file=$RUNDIR/camera.cfg --scale=auto --channel=front
290 
291  # read from network camera "rear" using jpeg encoding over http
292  run vt-httpclient --channel=rear http://192.168.0.3/streaming/channels/2
293 
294  # read from remote webcam "inside" by talking to its webcamserver
295  run vt-httpclient --channel=inside vt://rpi.localnet:80
296 
297  # record the three video streams to disk
298  run vt-recorder --command-socket=$RUNDIR/front.s front $SHAREDIR/front
299  run vt-recorder --command-socket=$RUNDIR/rear.s rear $SHAREDIR/rear
300  run vt-recorder --command-socket=$RUNDIR/inside.s inside $SHAREDIR/inside
301 
302  # motion detection, controlling the recorders
303  run vt-watcher --recorder=$RUNDIR/front.s --event-channel=front-events front
304  run vt-watcher --recorder=$RUNDIR/rear.s --event-channel=rear-events rear
305  run vt-watcher --recorder=$RUNDIR/inside.s --event-channel=inside-events inside
306 
307  # alarms from motion detection events
308  run vt-alarm front-events /usr/bin/aplay /usr/share/sounds/dog.wav
309  run vt-alarm rear-events /usr/local/bin/my-alarm.sh
310  run vt-alarm inside-events /usr/bin/wall
311 
312  # file players, for replaying recordings
313  run vt-fileplayer --channel=front-replay --command-socket=udp://0:3001 $SHAREDIR/front
314  run vt-fileplayer --channel=rear-replay --command-socket=udp://0:3002 $SHAREDIR/rear
315  run vt-fileplayer --channel=inside-replay --command-socket=udp://0:3003 $SHAREDIR/inside
316 
317  # main web server, to allow viewing from a html5 web-browser
318  run vt-httpserver --gateway=localhost --port=8080 --dir=$SHAREDIR --channel=*
319 
320 Viewing
321 -------
322 The video passing through a channel can be viewed by simply running the
323 "viewer" program on the same machine as the channel.
324 
325  vt-viewer somechannel
326 
327 Make sure you are using an account that has permission to access the
328 channel's shared memory.
329 
330 If X-Windows is not available then the viewer program will try to display
331 the images in text mode, using characters as pixels.
332 
333 To view the video images from a channel on another machine you should use
334 `ssh -X` (or `ssh -Y` from MacOS).
335 
336  ssh -X somebox.localnet vt-viewer somechannel
337 
338 The "httpserver" program can also be used to serve up video from a channel,
339 so that it can be viewed using a web browser.
340 
341 Snapshot images can be extracted from a channel by using the "channel"
342 utility and then viewed with a graphics program, perhaps after using
343 ImageMagick tools to change the image format.
344 
345  vt-channel --out=temp.dat read somechannel
346  convert temp.dat temp.jpg
347  gimp temp.jpg
348 
349 Recording and playback
350 ----------------------
351 The "recorder" program is used to record video from a publication channel.
352 
353 For example, to record from the "camera1" channel to a directory tree under
354 `/data/video`, start up a recorder like this:
355 
356  vt-recorder camera1 /data/video/camera1
357 
358 The "fileplayer" program can be used to play back the recordings for a
359 particular date:
360 
361  vt-fileplayer /data/video/camera1/2017/12/31
362 
363 Motion detection
364 ----------------
365 The "watcher" program can be used for motion detection. It monitors video
366 from one channel and emits motion detection events on another.
367 
368 The "alarm" program can be used to react to the motion detection events,
369 perhaps by playing a sound or sending an email.
370 
371  vt-watcher --channel=camera1-events camera1
372  vt-alarm camera1-events aplay alarm.wav
373 
374 You will normally need a mask file to inhibit motion detection in certain
375 parts of the video image.
376 
377  vt-maskeditor --image-channel=camera1 camera1-mask.pbm
378  vt-watcher --mask=camera1-mask.pbm --viewer --event-channel=camera1-events camera1
379 
380 The watcher can control the recorder by using the recorder's
381 `--command-socket` option. Motion detection will then cause the recorder to
382 start recording in its "fast" mode.
383 
384  vt-recorder --command-socket=/var/run/recorder1.s --state=stopped --timeout=20 camera1 /data/video/camera1
385  vt-watcher --recorder=/var/run/recorder1.s camera1
386 
387 There are two main parameters for the motion detection algorithm: "squelch"
388 and "threshold". Refer to the "watcher" documentation for the details.
389 
390 Security and privacy
391 --------------------
392 Always use firewalls and encrypted tunnels to protect your privacy when
393 exposed to the public internet. Also consider the following points.
394 
395 + Use the `--address` option to restrict the listening ports to a single
396 network interface.
397 
398 + Note that usernames and passwords in URLs on the command-line will be widely
399 visible on the local machine using `ps`.
400 
401 + Operating system resources such as files (excluding pid files), directories,
402 local-domain sockets, shared memory segments, semaphores etc. are all created
403 with permissions restricted by the inherited "umask", so make sure that the
404 umask in the videotools startup script (or equivalent) is set
405 appropriately.
406 
407 + Consider creating a special user group to control access to the videotools
408 resources more precisely: create a new group and make all the videotools
409 executables group-suid (for example), and then add user accounts to the group
410 in order to grant access to the videotools resources. Note that the `--user`
411 option does not affect resource ownership, although it can indirectly affect
412 the ownership of files created by an external program run by
413 `vt-alarm`.
414 
415 + Local-domain sockets are created whenever a program subscribes to a
416 publication channel and these sockets are briefly bound to a filesystem
417 path of `/tmp/vt-<channel>.<pid>`. However, they can be put in a
418 more private directory by prefixing the channel name on the subscriber's side
419 using an extended format of `<dir>/<name>/<channel>`, to give socket paths
420 of `<dir>/<name>.<pid>`.
421 
422 + The `vt-alarm` program uses the `system()` function to execute the program
423 you specify on the command-line. This provides a lot of flexibility for
424 output redirection, back-ticks, environment variable substitution etc, but
425 it also presents a large attack surface if the program's configuration or
426 run-time environment is compromised.
427 
428 IPv6
429 ----
430 IPv6 is used whenever an address uses an IPv6 format or whenever a hostname
431 resolves to an IPv6 address.
432 
433 Programs that use the `--port` option for the port number also have an
434 `--address` option for the network address, so adding `--address=::` will
435 switch from IPv4 to IPv6 since "::" is the IPv6 wildcard address. Similarly
436 for programs with a `--command-socket` option the full IPv6 transport address
437 can be given, so for example using `--command-socket=:::9000` will switch
438 the socket to IPv6 port 9000.
439 
440 IPv6 addresses can be used in URLs (eg. `vt-httpclient http://::1:80/x`),
441 but they will generally also need square brackets to avoid ambiguity with
442 respect to port numbers, eg. `http://[fc00::1]/x`.
443 
444 For hostnames that can resolve to IPv4 or IPv6 addresses the first returned
445 address is used. (Refer to `getaddrinfo()`'s `AI_ADDRCONFIG` option for more
446 details.)
447 
448 RTP multicast features are only relevant to IPv4.
449 
450 Connections
451 -----------
452 When videotools processes start up they usually wait for their primary inputs
453 to become available, whether that's a webcam device, publication channel, or
454 network peer; and if that input subsequently disappears then they will go
455 back to a waiting state. This means that a set of co-operating processes can
456 be started up without worrying about the order in which they connect to each
457 other, and it makes is easy to restart individual components without restarting
458 the whole videotools system.
459 
460 However, this default behaviour can be modified by `--retry` and `--once`
461 command-line options: if `--retry=0` is used then the program will exit
462 immediately if the input resource is not available, and if `--once` is used
463 then then any disappearance of a previously active input causes the program to
464 exit. These options might be useful if the videotools processes are being
465 managed by an "init" system that knows about their resource dependencies, or
466 if they are operating in a stable, low-maintenance system where failing fast
467 might be desirable.
468 
469 The connectivity of an established set of local videotools processes can be
470 deduced from metadata held within publication channels. Each channel has a
471 small structure describing the publisher process and a set of "slot"
472 structures where the channel subscribers register themselves.
473 
474 Channel metadata can be seen by using the "channel" utility:
475 
476  vt-channel -q list | xargs -n1 vt-channel info
477 
478 The "httpserver" program can also make the channel metadata available across
479 the network via the special double-underscore url path ("__"):
480 
481  vt-httpserver --port=8080 --channel=\*
482  wget -q http://localhost:8080/__ -O channels.json
483 
484 Troubleshooting
485 ---------------
486 If you encounter problems then stop all the videotools processes, and then
487 run only the relevant videotools program from the command-line. Use the the
488 `--verbose` option to get extra log messages, and do not use the `--daemon`
489 option. If the problems seem to be related to permissions then run your
490 tests as "root" by using `sudo` or equivalent.
491 
492 Add the `--scale` option wherever possible to reduce the image sizes during
493 your tests. This is particularly important if you see dropped RTP packets or
494 corrupted H.264 video from the "rtpserver".
495 
496 Work through the "Getting started" section (above) and vary the steps to get
497 closer to the problem you are seeing.
498 
499 Program aborts can cause publication channels to become congested or invalid
500 in some way. Use the "channel" utility to purge or delete them. As a last
501 resort carefully remove files from the `/dev/shm` directory (Linux only and
502 at your own risk), or reboot.
503 
504  vt-channel list
505  vt-channel purge somechannel
506  vt-channel delete somechannel
507 
508 Problems with USB webcams can sometimes be resolved by unplugging them and
509 the plugged them back in, particularly if you get weird errors on startup.
510 
511 Wireshark can be useful for diagnosing network problems and for figuring out
512 the capabilities of network cameras; the `Analyze->FollowTcpStream` option
513 can be particularly productive for HTTP.
514 
515 The "vlc" media player is useful for experimenting with RTSP/RTP.
516 
517 If you have corruped webcam images then experiment with adding `;fmt=x` to
518 the device name, where x is a small integer, eg. `/dev/video0;fmt=10`. (Use
519 a backslash or single-quotes to protect the semi-colon.) Also try building
520 with and without "libv4l".
521 
522 If JPEG video over RTP looks really bad then try using the "rtpserver"
523 program's `--jpeg-table` option.
524 
525 */
526 
527 
528 /*! \page Programs
529 
530 \tableofcontents
531 
532 <h1>Programs</h1>
533 
534 The sections below describe the separate programs that make up the system. Most
535 programs support the following common command-line options, and for clarity these are
536 listed here only:
537 
538 <h3>Common options</h3>
539 <table class="options_">
540  <tr><td>&ndash;&ndash;help</td><td>shows usage help and exits</td></tr>
541  <tr><td>&ndash;&ndash;syslog</td><td>sends logging to the system log</td></tr>
542  <tr><td>&ndash;&ndash;daemon</td><td>runs in the background</td></tr>
543  <tr><td>&ndash;&ndash;user</td><td>switches to the given user if run as root</td></tr>
544  <tr><td>&ndash;&ndash;log-time</td><td>adds timestamps to the logging output</td></tr>
545  <tr><td>&ndash;&ndash;pid-file=&lt;path&gt;</td><td>records the process id in a pid file</td></tr>
546  <tr><td>&ndash;&ndash;debug</td><td>emits debug-level logging, if compiled in</td></tr>
547 </table>
548 
549 \section alarm alarm
550 
551 Monitors a watcher's output channel and runs an external command on
552 each motion-detection event.
553 
554 For example, an "alarm" process can be used to generate an alarm sound
555 when motion detection is triggered, by running an external command
556 like "aplay".
557 
558 If the `--run-as` option is given then the external command runs with
559 that account's user-id and group-id if possible.
560 
561 If you need pipes, backticks, file redirection, etc. in your external
562 command then add the "--shell" option. Awkward shell escapes can
563 avoided by using "--url-decode".
564 
565 <h3>Usage</h3>
566 <p><pre class="fragment">vt-alarm [&lt;options&gt;] &lt;event-channel&gt; [&lt;command&gt; [&lt;arg&gt; ...]]</pre></p>
567 
568 <h3>Options</h3>
569 <table class="options_">
570  <tr><td>&ndash;&ndash;verbose</td><td>verbose logging</td></tr>
571  <tr><td>&ndash;&ndash;threshold=&lt;pixels&gt;</td><td>alarm threshold in pixels per image</td></tr>
572  <tr><td>&ndash;&ndash;shell</td><td>use '/bin/sh -c'</td></tr>
573  <tr><td>&ndash;&ndash;url-decode</td><td>treat the command as url-encoded</td></tr>
574 </table>
575 
576 \section channel channel
577 
578 A tool for working with publication channels.
579 
580 The following sub-commands are available: "list" lists all local
581 publication channels; "info" displays diagnostic information for
582 the channel; "read" reads one message from the channel; "peek"
583 reads the last-available message from the channel without
584 waiting; "purge" clears subscriber slots if subscribers have
585 failed without cleaning up; and "delete" deletes the channel,
586 in case a publisher fails without cleaning up.
587 
588 <h3>Usage</h3>
589 <p><pre class="fragment">vt-channel [&lt;options&gt;] {list|info|purge|delete|peek|read} &lt;channel&gt;</pre></p>
590 
591 <h3>Options</h3>
592 <table class="options_">
593  <tr><td>&ndash;&ndash;all</td><td>include info for unused slots</td></tr>
594  <tr><td>&ndash;&ndash;out=&lt;filename&gt;</td><td>output filename</td></tr>
595  <tr><td>&ndash;&ndash;quiet</td><td>fewer warnings</td></tr>
596 </table>
597 
598 \section fileplayer fileplayer
599 
600 Plays back recorded video to a publication channel or into a viewer window.
601 
602 The directory specified on the command-line is a base directory where the
603 video images can be found.
604 
605 The base directory can also be specified using the `--root` option, in which
606 case the directory on the end of the command-line is just the starting point
607 for the playback. If the `--rerootable` and `--command-socket` options are
608 used then the root directory can be changed at run-time by sending an
609 appropriate `move` command.
610 
611 In interactive mode (`--interactive`) the ribbon displayed at the bottom of
612 the viewer window can be used to move forwards and backwards through the
613 day's recording. Click on the ribbon to move within the current day, or click
614 on the left of the main image to go back to the previous day, or on the right
615 to go forwards to the next.
616 
617 The `--skip` option controls what proportion of images are skipped during
618 playback (speeding it up), and the `--sleep` option can be used to add a
619 delay between each displayed image (slowing it down). A negative skip value
620 puts the player into reverse.
621 
622 A socket interface (`--command-socket`) can be used to allow another program
623 to control the video playback. Sockets can be local-domain unix sockets or
624 UDP sockets; for UDP the socket should be like `udp://<address>:<port>`, eg.
625 `udp://0:20001`.
626 
627 Command messages are text datagrams in the form of a command-line, with
628 commands including `play`, `move {first|last|next|previous|.|<full-path>}`,
629 `ribbon <xpos>` and `stop`. The play command can have options of `--sleep=<ms>`,
630 `--skip=<count>`, `--forwards` and `--backwards`. The `move` command can
631 have options of `--match-name=<name>` and `--root=<root>`, although
632 the `--root` option requires `--rerootable` on the program command-line.
633 Multiple commands in one datagram should be separated by a semi-colon.
634 
635 The timezone option (`--tz`) affects the ribbon at the bottom of the display
636 window so that that the marks on the ribbon can span a local calendar day
637 even with UTC recordings. It also changes the start time for each new day
638 when navigating one day at a time. A positive timezone is typically used for
639 UTC recordings viewed at western longitudes.
640 
641 If multiple recorders are using the same file store with different filename
642 prefixes then the `--match-name` option can be used to disentangle the
643 different recorder streams. Note that this is not the recommended because
644 it does not scale well and it can lead to crazy-slow startup while looking
645 for a matching file. The match name can be changed at run-time by using the
646 `--match-name` option on a `move` command sent to the command socket.
647 
648 <h3>Usage</h3>
649 <p><pre class="fragment">vt-fileplayer [&lt;options&gt;] &lt;directory&gt;</pre></p>
650 
651 <h3>Options</h3>
652 <table class="options_">
653  <tr><td>&ndash;&ndash;verbose</td><td>verbose logging</td></tr>
654  <tr><td>&ndash;&ndash;viewer</td><td>run a viewer</td></tr>
655  <tr><td>&ndash;&ndash;interactive</td><td>respond to viewer mouse events</td></tr>
656  <tr><td>&ndash;&ndash;viewer-channel=&lt;channel&gt;</td><td>override the default viewer channel name</td></tr>
657  <tr><td>&ndash;&ndash;channel=&lt;channel&gt;</td><td>publish the playback video to the named channel</td></tr>
658  <tr><td>&ndash;&ndash;sleep=&lt;ms&gt;</td><td>inter-frame delay time for slower playback</td></tr>
659  <tr><td>&ndash;&ndash;skip=&lt;count&gt;</td><td>file skip factor for faster playback</td></tr>
660  <tr><td>&ndash;&ndash;command-socket=&lt;path&gt;</td><td>socket for playback commands</td></tr>
661  <tr><td>&ndash;&ndash;root=&lt;path&gt;</td><td>base directory</td></tr>
662  <tr><td>&ndash;&ndash;rerootable</td><td>allow the root to be changed over the command-socket</td></tr>
663  <tr><td>&ndash;&ndash;stopped</td><td>begin in the stopped state</td></tr>
664  <tr><td>&ndash;&ndash;loop</td><td>loop back to the beginning when reaching the end</td></tr>
665  <tr><td>&ndash;&ndash;scale=&lt;divisor&gt;</td><td>reduce the image size</td></tr>
666  <tr><td>&ndash;&ndash;tz=&lt;hours&gt;</td><td>timezone offset for ribbon</td></tr>
667  <tr><td>&ndash;&ndash;match-name=&lt;prefix&gt;</td><td>prefix for matching image files</td></tr>
668  <tr><td>&ndash;&ndash;monochrome</td><td>convert to monochrome</td></tr>
669  <tr><td>&ndash;&ndash;width=&lt;pixels&gt;</td><td>output image width</td></tr>
670  <tr><td>&ndash;&ndash;height=&lt;pixels&gt;</td><td>output image height</td></tr>
671  <tr><td>&ndash;&ndash;fade</td><td>fade image transitions</td></tr>
672 </table>
673 
674 \section httpclient httpclient
675 
676 Pulls video from a remote HTTP server or network camera and sends it to a
677 publication channel or a viewer window.
678 
679 Uses repeated GET requests on a persistent connection, with each GET request
680 separated by a configurable time delay (`--request-timeout`). A watchdog
681 timer tears down the connection if no data is received for some time and
682 then the connection is retried. Watchdog timeouts and peer disconnections
683 result in connection retries; connection failures will terminate the
684 program only if using `--retry=0`.
685 
686 The server should normally return a mime type of `image/jpeg`, or
687 preferably `multipart/x-mixed-replace` with `image/jpeg` sub-parts.
688 In the latter case the client only needs to make one GET request and
689 the server determines the frame rate.
690 
691 When getting video from a network camera the exact form of the URL to use
692 will depend on the camera, so please refer to its documentation or
693 search the internet for help.
694 
695 To get video from a remote webcam use the `vt-webcamserver` on the remote
696 maching and use `vt-httpclient` to pull it across the network.
697 
698 As a convenience, a URL of `vt://<address>` can be used instead of `http://<address>`
699 and this is equivalent to `http://<address>/_?streaming=1&type=any`.
700 
701 <h3>Usage</h3>
702 <p><pre class="fragment">vt-httpclient [&lt;options&gt;] &lt;http-url&gt;</pre></p>
703 
704 <h3>Options</h3>
705 <table class="options_">
706  <tr><td>&ndash;&ndash;verbose</td><td>verbose logging</td></tr>
707  <tr><td>&ndash;&ndash;viewer</td><td>run a viewer</td></tr>
708  <tr><td>&ndash;&ndash;scale=&lt;divisor&gt;</td><td>reduce the viewer image size</td></tr>
709  <tr><td>&ndash;&ndash;viewer-title=&lt;title&gt;</td><td>viewer window title</td></tr>
710  <tr><td>&ndash;&ndash;watchdog-timeout=&lt;seconds&gt;</td><td>watchdog timeout (default 20s)</td></tr>
711  <tr><td>&ndash;&ndash;request-timeout=&lt;ms&gt;</td><td>time between http get requests (default 1ms)</td></tr>
712  <tr><td>&ndash;&ndash;channel=&lt;channel&gt;</td><td>publish to the named channel</td></tr>
713  <tr><td>&ndash;&ndash;connection-timeout=&lt;seconds&gt;</td><td>connection timeout</td></tr>
714  <tr><td>&ndash;&ndash;retry=&lt;seconds&gt;</td><td>retry failed connections or zero to exit (default 1s)</td></tr>
715  <tr><td>&ndash;&ndash;once</td><td>exit when the first connection closes</td></tr>
716 </table>
717 
718 \section httpserver httpserver
719 
720 Reads video from one or more publication channels and makes it available
721 over the network using HTTP.
722 
723 The HTTP client can either request individual images ("client-pull") or
724 receive a continuous JPEG video stream delivered as a
725 `multipart/x-mixed-replace` content type ("server-push").
726 
727 For server-push add a `streaming=1` parameter to the URL, eg.
728 `http://localhost:80/?streaming=1`. This should always be used when the
729 client is the `vt-httpclient` program, but be careful when using a browser
730 because not all of them support `multipart/x-mixed-replace`, and some of
731 them go beserk with "save-as" dialog boxes.
732 
733 The client-pull model works best with a browser that uses JavaScript code
734 to generate a continuous stream of GET requests, typically using the
735 "Fetch" API.
736 
737 For browsers that do not have JavaScript or support for `multipart/x-mixed-replace`
738 a `refresh=1` URL parameter can be used so that the server sends
739 back static images with a HTTP "Refresh" header, causing the browser to
740 repeat the GET requests at intervals. This can also be made the default
741 behaviour using the `--refresh` command-line option on the server.
742 
743 A `scale` URL parameter can be used to reduce the size of the images, and
744 a `type` parameter can be used to request an image format (`jpeg`, `pnm`, or
745 `raw`, with `jpeg` as the default). The type can also be `any`, which means
746 that no image conversion or validation is performed; whatever data is
747 currently in the publication channel is served up.
748 
749 Static files can be served up by using the `--dir` option. Normally any file
750 in the directory will be served up, but a restricted set of files can be
751 specified by using the `--file` option. The `--file-type` option can be used
752 to give the files' content-type, by using the filename and the content-type
753 separated by a colon, eg. `--file-type=data.json:application/json`. The default
754 file that is served up for an empty path in the url can be modified by the
755 `--default` option, eg. `--default=main.html`.
756 
757 One or more channel names should normally be specified on the command-line
758 using the `--channel` option. Clients can select a channel by name by
759 using URL paths with an underscore prefix (eg. `_foo`, `_bar`); or by index
760 by using URL paths like `_0`, `_1`, etc.
761 
762 If `--channel=*` is specified then any valid channel name can be used in
763 the URL path. This also enables the special `/__` url that returns channel
764 information as a JSON structure.
765 
766 The `--gateway=<host>` option can be used to integrate static web pages
767 with UDP command sockets; HTTP requests with a `send` parameter of the
768 form `<port> <message>` are sent as UDP messages to the `--gateway` IP
769 address and the specified port.
770 
771 <h3>Usage</h3>
772 <p><pre class="fragment">vt-httpserver [&lt;options&gt;]</pre></p>
773 
774 <h3>Options</h3>
775 <table class="options_">
776  <tr><td>&ndash;&ndash;port=&lt;port&gt;</td><td>listening port</td></tr>
777  <tr><td>&ndash;&ndash;timeout=&lt;seconds&gt;</td><td>network idle timeout (default 60s)</td></tr>
778  <tr><td>&ndash;&ndash;data-timeout=&lt;seconds&gt;</td><td>initial image timeout (default 3s)</td></tr>
779  <tr><td>&ndash;&ndash;repeat-timeout=&lt;ms&gt;</td><td>image repeat timeout (default 1000ms)</td></tr>
780  <tr><td>&ndash;&ndash;address=&lt;ip&gt;</td><td>listening address</td></tr>
781  <tr><td>&ndash;&ndash;dir=&lt;dir&gt;</td><td>serve up static files</td></tr>
782  <tr><td>&ndash;&ndash;file=&lt;filename&gt;</td><td>allow serving the named file </td></tr>
783  <tr><td>&ndash;&ndash;file-type=&lt;fname:type&gt;</td><td>define the content-type of the the named file </td></tr>
784  <tr><td>&ndash;&ndash;default=&lt;fname-or-channel&gt;</td><td>define the default resource</td></tr>
785  <tr><td>&ndash;&ndash;channel=&lt;name&gt;</td><td>serve up named video channel</td></tr>
786  <tr><td>&ndash;&ndash;gateway=&lt;udp-host&gt;</td><td>act as a http-post-to-udp-command-line gateway</td></tr>
787  <tr><td>&ndash;&ndash;refresh=&lt;seconds&gt;</td><td>add a refresh header to http responses by default</td></tr>
788 </table>
789 
790 \section maskeditor maskeditor
791 
792 Creates and edits a mask file that can be used by the `vt-watcher` program.
793 
794 The `vt-watcher` program analyses a video stream for moving objects, and it uses
795 a mask file to tell it what parts of the image to ignore.
796 
797 The mask is edited over the top a background image, and that image can come
798 from a static image file or from a publication channel (`--image-channel`).
799 
800 Click and drag the mouse to create masked areas, and hold the shift key to
801 revert. The mask file is continuously updated in-place; there is no "save"
802 operation.
803 
804 <h3>Usage</h3>
805 <p><pre class="fragment">vt-maskeditor [&lt;options&gt;] &lt;mask-file&gt;</pre></p>
806 
807 <h3>Options</h3>
808 <table class="options_">
809  <tr><td>&ndash;&ndash;verbose</td><td>verbose logging</td></tr>
810  <tr><td>&ndash;&ndash;image-file=&lt;path&gt;</td><td>background image file</td></tr>
811  <tr><td>&ndash;&ndash;image-channel=&lt;channel&gt;</td><td>channel for capturing the initial backgound image</td></tr>
812  <tr><td>&ndash;&ndash;viewer-channel=&lt;channel&gt;</td><td>override the default viewer channel name</td></tr>
813 </table>
814 
815 \section recorder recorder
816 
817 Reads a video stream from a publication channel and records it to disk.
818 
819 Individual video frames are stored in a directory tree, organised by date
820 and time.
821 
822 Images are recorded as fast as they are received, or once a second, or not
823 at all. These are the fast, slow and stopped states.
824 
825 The state can be changed by sending a `fast`, `slow`, or `stopped` command
826 over the recorder's command socket (`--command-socket`).
827 
828 The fast state is temporary unless the `--timeout` option is set to zero;
829 after recording in the fast state for a while the state drops back to the
830 previous slow or stopped state.
831 
832 The recorder enters the fast state on startup (`--fast`) or when it gets a
833 `fast` command over its command socket, typically sent by the `vt-watcher`
834 program. On entering the fast state any in-memory images from the last few
835 seconds are also committed to disk.
836 
837 A sub-directory called `.cache` is used to hold the recent images that have
838 not been commited to the main image store. These files are held open, and
839 they should not be accessed externally. When the recorder is triggered
840 by a `fast` command on the command socket the cached files are moved
841 into the main image store so that they provide a lead-in to the event
842 that triggered the recording.
843 
844 On machines with limited memory the cache size should be tuned so that
845 there is no disk activity when the recorder is in the "stopped" state.
846 The cache can be completely disabled by setting the cache size to zero,
847 but then there will be no lead-in to recordings triggered by an event.
848 
849 Use `--fast --timeout=0 --cache-size=0` for continuous recording of a
850 channel.
851 
852 The `--tz` option is the number of hours added to UTC when constructing
853 file system paths under the base directory, so to get local times at western
854 longitudes the value should be negative (eg. `--tz=-5`). However, if this
855 option is used inconsistently then there is a risk of overwriting or
856 corrupting old recordings, so it is safer to use UTC recordings and
857 add `--tz` adjustments elsewhere.
858 
859 Loopback filesystems are one way to put a hard limit on disk usage. On
860 Linux do something like this as root
861 `dd if=/dev/zero of=/usr/share/recordings.img count=20000`,
862 `mkfs -t ext2 -F /usr/share/recordings.img`,
863 `mkdir /usr/share/recordings`,
864 `mount -o loop /usr/share/recordings.img /usr/share/recordings`,
865 add add the mount to `/etc/fstab`.
866 
867 Individual video streams should normally be recorded into their own directory
868 tree, but the `--name` option allows multiple video streams to share the same
869 root directory by adding a fixed prefix to every image filename. However,
870 this approach does not scale well on playback, so only use it for a very
871 small number of video streams.
872 
873 <h3>Usage</h3>
874 <p><pre class="fragment">vt-recorder [&lt;options&gt;] &lt;input-channel&gt; &lt;base-dir&gt;</pre></p>
875 
876 <h3>Options</h3>
877 <table class="options_">
878  <tr><td>&ndash;&ndash;verbose</td><td>verbose logging</td></tr>
879  <tr><td>&ndash;&ndash;scale=&lt;divisor&gt;</td><td>reduce the image size</td></tr>
880  <tr><td>&ndash;&ndash;command-socket=&lt;path&gt;</td><td>socket for commands</td></tr>
881  <tr><td>&ndash;&ndash;file-type=&lt;type&gt;</td><td>file format: jpg, ppm, or pgm</td></tr>
882  <tr><td>&ndash;&ndash;timeout=&lt;s&gt;</td><td>fast-state timeout</td></tr>
883  <tr><td>&ndash;&ndash;fast</td><td>start in fast state</td></tr>
884  <tr><td>&ndash;&ndash;state=&lt;state&gt;</td><td>state when not fast (slow or stopped, slow by default)</td></tr>
885  <tr><td>&ndash;&ndash;tz=&lt;hours&gt;</td><td>timezone offset</td></tr>
886  <tr><td>&ndash;&ndash;cache-size=&lt;files&gt;</td><td>cache size</td></tr>
887  <tr><td>&ndash;&ndash;name=&lt;prefix&gt;</td><td>prefix for all image files (defaults to the channel name)</td></tr>
888  <tr><td>&ndash;&ndash;retry=&lt;timeout&gt;</td><td>poll for the input channel to appear</td></tr>
889  <tr><td>&ndash;&ndash;once</td><td>exit if the input channel disappears</td></tr>
890 </table>
891 
892 \section rtpserver rtpserver
893 
894 Listens for an incoming RTP video stream and sends it to a local publication
895 channel.
896 
897 Some network cameras use RTP rather than HTTP because it is more suited to
898 high resolution video, especially when using H.264 encoding, and it also
899 allows for IP multicasting.
900 
901 Only the "H264/90000" and "JPEG/90000" RTP payload types are supported by this
902 server.
903 
904 The H.264 video format requires plenty of processing power; if the H.264
905 decoding is too slow then packets will be missed and the packet stream
906 will have too many holes to decode anything. The processing load can
907 be reduced by handling only RTP packets that match certain criteria by
908 using the `--filter` option, or by using `--scale` and `--monochrome`
909 to reduce the image resolution after decoding.
910 
911 Cameras that use RTP will normally be controlled by an RTSP client (such as
912 `vt-rtspclient`); the RTSP client asks the camera to start sending
913 its video stream to the address that the RTP server is listening on.
914 
915 The camera responds to the RTSP request with a "fmtp" string, which describes
916 the video format for the H.264 video packets. If this information is not
917 available from within the RTP packet stream itself then it can be passed
918 to the rtpserver using the `--format-file` option.
919 
920 The RTCP protocol is not currently used so the rtpserver only opens one
921 UDP port for listening, not two. Also be aware that if two rtpservers
922 are listening on the same UDP port then they will steal packets from
923 one another and it is likely that both will stop working.
924 
925 <h3>Usage</h3>
926 <p><pre class="fragment">vt-rtpserver [&lt;options&gt;]</pre></p>
927 
928 <h3>Options</h3>
929 <table class="options_">
930  <tr><td>&ndash;&ndash;verbose</td><td>verbose logging</td></tr>
931  <tr><td>&ndash;&ndash;viewer</td><td>run a viewer</td></tr>
932  <tr><td>&ndash;&ndash;scale=&lt;divisor&gt;</td><td>reduce the image size (or 'auto')</td></tr>
933  <tr><td>&ndash;&ndash;monochrome</td><td>convert to monochrome</td></tr>
934  <tr><td>&ndash;&ndash;port=&lt;port&gt;</td><td>listening port</td></tr>
935  <tr><td>&ndash;&ndash;channel=&lt;channel&gt;</td><td>publish to the named channel</td></tr>
936  <tr><td>&ndash;&ndash;address=&lt;ip&gt;</td><td>listening address</td></tr>
937  <tr><td>&ndash;&ndash;multicast=&lt;address&gt;</td><td>multicast group address</td></tr>
938  <tr><td>&ndash;&ndash;format-file=&lt;path&gt;</td><td>file to read for the H264 format parameters</td></tr>
939  <tr><td>&ndash;&ndash;type=&lt;type&gt;</td><td>process packets of one rtp payload type (eg. 26 or 96)</td></tr>
940  <tr><td>&ndash;&ndash;jpeg-table=&lt;ff&gt;</td><td>tweak for jpeg quantisation tables (0,1 or 2)</td></tr>
941 </table>
942 
943 \section rtspclient rtspclient
944 
945 Issues RTSP commands to control network cameras that send out their video
946 over RTP with H.264 encoding (RTP/AVP).
947 
948 The RTSP protocol acts as a "remote control" for video devices, so an RTSP
949 client is used to ask a camera to send its RTP video stream back to a
950 particular pair of UDP ports where the RTP server is listening.
951 
952 The RTSP client also reports on what video format the camera will send,
953 encoded as a "fmtp" string. This information can help the RTP server
954 decode the video stream. Use the `--format-file` option to make it
955 available to the RTP server.
956 
957 The RTSP protocol is similar to HTTP, and it uses the same URL syntax, with
958 `rtsp://` instead of `http://` , eg. `rtsp://example.com/channel/1`. The
959 format of right hand side of the URL, following the network address, will
960 depend on the camera, so refer to its documentation.
961 
962 The camera should send its video stream for as long as the `vt-rtspclient`
963 program keeps its session open; once it terminates then the video stream from
964 the camera will stop.
965 
966 <h3>Usage</h3>
967 <p><pre class="fragment">vt-rtspclient [&lt;options&gt;] &lt;rtsp-url&gt;</pre></p>
968 
969 <h3>Options</h3>
970 <table class="options_">
971  <tr><td>&ndash;&ndash;verbose</td><td>verbose logging</td></tr>
972  <tr><td>&ndash;&ndash;port=&lt;port-port&gt;</td><td>listening port range eg. 8000-8001</td></tr>
973  <tr><td>&ndash;&ndash;multicast=&lt;address&gt;</td><td>multicast address eg. 224.1.1.1</td></tr>
974  <tr><td>&ndash;&ndash;format-file=&lt;path&gt;</td><td>a file to use for storing the video format string</td></tr>
975  <tr><td>&ndash;&ndash;connection-timeout=&lt;seconds&gt;</td><td>connection timeout</td></tr>
976  <tr><td>&ndash;&ndash;retry=&lt;seconds&gt;</td><td>retry failed connections or zero to exit (default 1s)</td></tr>
977  <tr><td>&ndash;&ndash;once</td><td>exit when the first session closes</td></tr>
978 </table>
979 
980 \section socket socket
981 
982 Sends a command string to a local-domain or UDP socket.
983 
984 This can be used with the `vt-fileplayer` and `vt-recorder` programs when using
985 their `--command-socket` option.
986 
987 The socket is a local-domain socket by default, but a UDP network socket
988 if the socket name looks like a transport address or if it starts
989 with `udp://`.
990 
991 The standard "netcat" utility (`nc`) can also be used to send messages to
992 UDP and local-domain sockets.
993 
994 <h3>Usage</h3>
995 <p><pre class="fragment">vt-socket &lt;socket&gt; &lt;command-word&gt; [&lt;command-word&gt; ...]</pre></p>
996 
997 
998 \section viewer viewer
999 
1000 Reads images from a publication channel and displays them in a window.
1001 
1002 The viewer is also used when a parent process such as a the `vt-fileplayer`
1003 needs a display window, and in that case the video is sent over a
1004 private pipe rather than a publication channel and the two file descriptors
1005 are passed on the command-line.
1006 
1007 If there is no windowing system then the video images are displayed in the
1008 terminal using text characters for pixels. It looks better if you stand
1009 back and squint.
1010 
1011 Mouse events can be sent to a publication channel by using the `--channel`
1012 option. The `vt-maskeditor` and `vt-fileplayer` programs use this feature, and
1013 they have a `--viewer-channel` option to override the name of the publication
1014 channel used for these mouse events.
1015 
1016 A pbm-format mask file can be used to dim fixed regions of the image.
1017 The mask is stretched as necessary to fit the image.
1018 
1019 <h3>Usage</h3>
1020 <p><pre class="fragment">vt-viewer [&lt;options&gt;] { &lt;channel&gt; | &lt;shmem-fd&gt; &lt;pipe-fd&gt; }</pre></p>
1021 
1022 <h3>Options</h3>
1023 <table class="options_">
1024  <tr><td>&ndash;&ndash;verbose</td><td>verbose logging</td></tr>
1025  <tr><td>&ndash;&ndash;channel=&lt;channel&gt;</td><td>publish interaction events to the named channel</td></tr>
1026  <tr><td>&ndash;&ndash;scale=&lt;divisor&gt;</td><td>reduce the image size</td></tr>
1027  <tr><td>&ndash;&ndash;static</td><td>view only the first image</td></tr>
1028  <tr><td>&ndash;&ndash;mask=&lt;file&gt;</td><td>use a mask file</td></tr>
1029  <tr><td>&ndash;&ndash;title=&lt;title&gt;</td><td>sets the window title</td></tr>
1030  <tr><td>&ndash;&ndash;quit</td><td>quit on q keypress</td></tr>
1031 </table>
1032 
1033 \section watcher watcher
1034 
1035 Performs motion detection on a video stream received over a shared-memory
1036 publication channel.
1037 
1038 If motion detection exceeds some threshold then an event is published on the
1039 `--event-channel` channel as a json formatted text message. These messages are
1040 normally read by a `vt-alarm` process that can run other external programs.
1041 
1042 Motion detection events can also be used to control a `vt-recorder` process
1043 by sending a `fast` command to the recorder's command socket.
1044 
1045 The `--viewer` or `--image-channel` options can be used to visualise the
1046 motion detection. The viewer window shows in green the pixels that change in
1047 brightness by more than the "squelch" value, and it also shows in red the
1048 pixels that are ignored as the result of the mask.
1049 
1050 The motion detection algorithm is extremely simple; one video frame is
1051 compared to the next, and pixels that change their brightness more that the
1052 squelch value (0..255) are counted up, and if the total count is more than
1053 the given threshold value then a motion detection event is emitted.
1054 
1055 The `--scale` option also has an important effect because it increases the
1056 size of the motion detection pixels (by decreasing the resolution of the
1057 image), and it affects the interpretation of the threshold value.
1058 
1059 Histogram equalisation is enabled with the `--equalise` option and this can
1060 be particularly useful for cameras that loose contrast in infra-red mode.
1061 
1062 The command socket, enabled with the `--command-socket` option, accepts
1063 `squelch`, `threshold` and `equalise` commands. Multiple commands can
1064 be sent in one datagram by using semi-colon separators.
1065 
1066 The squelch and threshold values have default values that will need
1067 fine-tuning for your camera. This can be done interactively by temporarily
1068 using the `--verbose`, `--viewer` and `--command-socket` options, and then
1069 sending `squelch`, `threshold` and `equalise` commands to the command socket
1070 with the `vt-socket` tool (eg. `vt-watcher -C cmd --viewer -v <channel>`
1071 and `vt-socket cmd squelch=20\;threshold=1\;equalise=off`).
1072 Adjust the squelch value to eliminate the green highlights when there is
1073 no motion. Repeat in different lighting conditions.
1074 
1075 <h3>Usage</h3>
1076 <p><pre class="fragment">vt-watcher [&lt;options&gt;] &lt;input-channel&gt;</pre></p>
1077 
1078 <h3>Options</h3>
1079 <table class="options_">
1080  <tr><td>&ndash;&ndash;log-threshold</td><td>threshold for logging motion detection events</td></tr>
1081  <tr><td>&ndash;&ndash;verbose</td><td>verbose logging</td></tr>
1082  <tr><td>&ndash;&ndash;viewer</td><td>run a viewer</td></tr>
1083  <tr><td>&ndash;&ndash;viewer-title=&lt;title&gt;</td><td>viewer window title</td></tr>
1084  <tr><td>&ndash;&ndash;mask=&lt;file&gt;</td><td>use a mask file</td></tr>
1085  <tr><td>&ndash;&ndash;scale=&lt;divisor&gt;</td><td>reduce the image size</td></tr>
1086  <tr><td>&ndash;&ndash;event-channel=&lt;channel&gt;</td><td>publish analysis events to the named channel</td></tr>
1087  <tr><td>&ndash;&ndash;image-channel=&lt;channel&gt;</td><td>publish analysis images to the named channel</td></tr>
1088  <tr><td>&ndash;&ndash;recorder=&lt;path&gt;</td><td>recorder socket path</td></tr>
1089  <tr><td>&ndash;&ndash;squelch=&lt;luma&gt;</td><td>pixel value change threshold (0 to 255) (default 50)</td></tr>
1090  <tr><td>&ndash;&ndash;threshold=&lt;pixels&gt;</td><td>pixel count threshold in changed pixels per image (default 100)</td></tr>
1091  <tr><td>&ndash;&ndash;interval=&lt;ms&gt;</td><td>minimum time interval between comparisons (default 250)</td></tr>
1092  <tr><td>&ndash;&ndash;once</td><td>exit if the watched channel is unavailable</td></tr>
1093  <tr><td>&ndash;&ndash;equalise</td><td>histogram equalisation</td></tr>
1094  <tr><td>&ndash;&ndash;command-socket=&lt;path&gt;</td><td>socket for update commands</td></tr>
1095  <tr><td>&ndash;&ndash;plain</td><td>do not show changed-pixel highlights in output images</td></tr>
1096  <tr><td>&ndash;&ndash;repeat-timeout=&lt;seconds&gt;</td><td>send events repeatedly with the given period</td></tr>
1097 </table>
1098 
1099 \section webcamserver webcamserver
1100 
1101 Serves up video images from a local webcam or video capture device over HTTP.
1102 
1103 The HTTP client can either request individual images ("client-pull") or
1104 receive a continuous JPEG video stream delivered as a
1105 `multipart/x-mixed-replace` content type ("server-push"). Refer to the
1106 `vt-httpserver` program for more information.
1107 
1108 This program is useful for running on satellite machines in the local network
1109 that have webcams attached; a central monitoring machine can run `vt-httpclient`
1110 to pull the video stream across the network and onto a local publication
1111 channel.
1112 
1113 Use `--device=test` or `--device=demo` for testing without an attached
1114 camera, or on linux use the "vivi" kernel module (`sudo modprobe vivi`).
1115 Device-specific configuration options can be added after the device
1116 name, using a semi-colon separator.
1117 
1118 The server will normally poll for the webcam device to come on-line, although
1119 `--retry=0` can be used to disable this behaviour. When the device goes
1120 off-line again the program will go back to polling, or it will terminate if the
1121 `--once` option is used.
1122 
1123 The `--tz` option can be used with `--caption` to adjust the timezone for the
1124 caption timestamp. It is typically a negative number for western longitudes
1125 in order to show local time.
1126 
1127 <h3>Usage</h3>
1128 <p><pre class="fragment">vt-webcamserver [&lt;options&gt;]</pre></p>
1129 
1130 <h3>Options</h3>
1131 <table class="options_">
1132  <tr><td>&ndash;&ndash;verbose</td><td>verbose logging</td></tr>
1133  <tr><td>&ndash;&ndash;port=&lt;port&gt;</td><td>listening port</td></tr>
1134  <tr><td>&ndash;&ndash;caption</td><td>add a timestamp caption</td></tr>
1135  <tr><td>&ndash;&ndash;caption-text=&lt;text&gt;</td><td>defines the caption text in ascii, with %t for a timestamp</td></tr>
1136  <tr><td>&ndash;&ndash;timeout=&lt;seconds&gt;</td><td>network idle timeout (default 60s)</td></tr>
1137  <tr><td>&ndash;&ndash;data-timeout=&lt;seconds&gt;</td><td>initial image timeout (default 3s)</td></tr>
1138  <tr><td>&ndash;&ndash;repeat-timeout=&lt;ms&gt;</td><td>image repeat timeout (default 1000ms)</td></tr>
1139  <tr><td>&ndash;&ndash;address=&lt;ip&gt;</td><td>listening address</td></tr>
1140  <tr><td>&ndash;&ndash;tz=&lt;hours&gt;</td><td>timezone offset for the caption</td></tr>
1141  <tr><td>&ndash;&ndash;device=&lt;device&gt;</td><td>webcam video device (eg. /dev/video0)</td></tr>
1142  <tr><td>&ndash;&ndash;refresh=&lt;seconds&gt;</td><td>add a refresh header to http responses by default</td></tr>
1143  <tr><td>&ndash;&ndash;retry=&lt;timeout&gt;</td><td>poll for the webcam device to appear (default 1s)</td></tr>
1144  <tr><td>&ndash;&ndash;once</td><td>exit if the webcam device disappears</td></tr>
1145 </table>
1146 
1147 \section webcamplayer webcamplayer
1148 
1149 Displays or publishes video from a local webcam or video capture device.
1150 
1151 If no publication channel is specified then the video is just displayed in
1152 a window. The published video can be recorded by the `vt-recorder` program
1153 and later played back by `vt-fileplayer`, and it can be analysed by a
1154 `vt-watcher`.
1155 
1156 Use `--device=test` or `--device=demo` for testing without an attached
1157 camera, or on linux use the "vivi" kernel module (`sudo modprobe vivi`).
1158 Device-specific configuration options can be added after the device
1159 name, using a semi-colon separator.
1160 
1161 The program will normally poll for the webcam device to come on-line, although
1162 `--retry=0` can be used to disable this behaviour. When the device goes
1163 off-line again the program will go back to polling, or it will terminate if the
1164 `--once` option is used.
1165 
1166 The `--tz` option can be used with `--caption` to adjust the timezone for
1167 the caption timestamp. It is typically a negative number for western
1168 longitudes in order to show local time.
1169 
1170 <h3>Usage</h3>
1171 <p><pre class="fragment">vt-webcamplayer [&lt;options&gt;]</pre></p>
1172 
1173 <h3>Options</h3>
1174 <table class="options_">
1175  <tr><td>&ndash;&ndash;verbose</td><td>verbose logging</td></tr>
1176  <tr><td>&ndash;&ndash;device=&lt;device&gt;</td><td>video device (eg. /dev/video0)</td></tr>
1177  <tr><td>&ndash;&ndash;caption</td><td>add a timestamp caption</td></tr>
1178  <tr><td>&ndash;&ndash;caption-text=&lt;text&gt;</td><td>defines the caption text in ascii, with %t for a timestamp</td></tr>
1179  <tr><td>&ndash;&ndash;viewer</td><td>run a viewer</td></tr>
1180  <tr><td>&ndash;&ndash;channel=&lt;channel&gt;</td><td>publish to the named channel</td></tr>
1181  <tr><td>&ndash;&ndash;scale=&lt;divisor&gt;</td><td>reduce the image size</td></tr>
1182  <tr><td>&ndash;&ndash;tz=&lt;hours&gt;</td><td>timezone offset for the caption</td></tr>
1183  <tr><td>&ndash;&ndash;monochrome</td><td>convert to monochrome</td></tr>
1184  <tr><td>&ndash;&ndash;retry=&lt;timeout&gt;</td><td>poll for the device to appear</td></tr>
1185  <tr><td>&ndash;&ndash;once</td><td>exit if the webcam device disappears</td></tr>
1186 </table>
1187 
1188 */
1189 
1190 /*! \namespace G
1191 \short
1192 Low-level classes for o/s services.
1193 
1194 Key classes are:
1195 - Path
1196 - FatPipe
1197 - Publisher
1198 - GetOpt
1199 - etc
1200 
1201  */
1202 
1203 /*! \namespace GSsl
1204 \short
1205 Stubbed-out TLS/SSL classes.
1206 
1207  */
1208 
1209 /*! \namespace GNet
1210 \short
1211 Network classes.
1212 
1213 Key classes are:
1214 - Address
1215 - EventHandler
1216 - EventLoop
1217 - Server
1218 - Socket
1219 - Timer
1220 
1221 */
1222 
1223 /*! \namespace GX
1224 \short
1225 Xlib classes.
1226 
1227 Key classes are:
1228 - Window
1229 - Canvas
1230 
1231 */
1232 
1233 /*! \namespace Gr
1234 \short
1235 Static image classes.
1236 
1237 Key classes are:
1238 - ImageData
1239 - JpegReader
1240 - PngReader
1241 - ImageDecoder
1242 - Image
1243 
1244 */
1245 
1246 /*! \namespace Gv
1247 \short
1248 Video classes.
1249 
1250 Key classes are:
1251 - AvcReader
1252 - Capture
1253 - Camera
1254 - ImageInputSource
1255 - ImageOutput
1256 - ViewerWindow
1257 
1258 */
1259 
1260 /*! \namespace md5
1261 \short
1262 Standalone MD5 implementation.
1263 
1264 Key classes are:
1265 - digest_stream
1266 - digest
1267 
1268 */
1269 
1270 /* \endhtmlonly */