The resulting image is saved to a file or sent to stdio where it can be piped to something like ncftpput or scp.
Latest version is fswebcam-20110717 tar.gz tar.xz
Older versions and other related files can be found here.
A public git repository is available here: http://github.com/fsphil/fswebcam
fswebcam is the simplest and easiest way to have your webcam capture single frames, also programmatically at a specified timer interval. Of course it’s also possible to call fswebcam from a bash script anytime it’s required, but this is another story.
To install fswebcam simply run:
sudo apt-get install fswebcam
One of the nice features of fswebcam is that it’s possible to add a footer to the capture, where you can specify your text of choice.
For instance, this is the command I ran fswebcam with:
$ fswebcam -r 640x480 -S 15 --flip h --jpeg 95 --shadow --title "SLB Labs" --subtitle "Home" --info "Monitor: Active @ 1 fpm" --save home.jpg -q -l 60
fswebcam is a small and simple webcam app for *nix. It can capture
images from a number of different sources and perform simple
manipulation on the captured image. The image can be saved as one or
more PNG or JPEG files.
The PNG or JPEG image can be sent to stdio using the filename "-". The
output filename is formatted by strftime.
Config files use the long version of options without the "--" prefix.
Comments start with a # symbol at the beginning of the line.
Show a usage summary.
Load options from a file. You can load more than one config
file, and can mix them with command-line arguments.
Note: This option can not be used from within a configuration
Hides all messages except errors.
Print extra information during the capture process.
Print the version number and exit.
-l, --loop <frequency>
Continually capture images. The time between images is specified
Default behaviour is to capture a single image and exit.
Note: The time to capture the next image is calculated relative
to the epoch, so an image will not be captured immediately when
the program is first started.
Sets the offset to use when calculating when the next image is
due in loop mode. Value can be positive or negative.
Run in the background. In this mode stdout and console logging
Saves the PID of the background process to the specified file.
Ignored when not using background mode.
Redirect log messages to a file or syslog. For example
--gmt Use GMT instead of the local timezone when formatting text with
-d, --device [<prefix>:]<device name>
Set the source or device to use. The source module is selected
automatically unless specified in the prefix.
Default is /dev/video0.
Available source modules, in order of preference:
V4L2 - Capture images from a V4L2 compatible video device.
V4L1 - Capture images from a V4L1 compatible video device.
FILE - Capture an image from a JPEG or PNG image file.
RAW - Reads images straight from a device or file.
TEST - Draws colour bars.
-i, --input <input number or name>
Set the input to use. You may select an input by either it’s
number or name.
Default is "0".
List available inputs for the selected source or device.
fswebcam -d v4l2:/dev/video1 --list-inputs
-t, --tuner <tuner number>
Set the tuner to use.
-f, --frequency <frequency>
Set the frequency of the selected input or tuner. The value may
be read as KHz or MHz depending on the input or tuner.
-p, --palette <name>
Try to use the specified image format when capturing the image.
Default is to select one automatically.
-r, --resolution <dimensions>
Set the image resolution of the source or device. The actual
resolution used may differ if the source or device cannot
capture at the specified resolution.
Default is "384x288".
Lists the supported resolutions for the selected source.
Lists the supported frame rates for the selected source and
-F, --frames <number>
Set the number of frames to capture. More frames mean less noise
in the final image, however capture times will be longer and
moving objects may appear blurred.
Default is "1".
-S, --skip <number>
Set the number of frames to skip. These frames will be captured
but won’t be use. Use this option if your camera sends some bad
or corrupt frames when it first starts capturing.
Default is "0".
-D, --delay <delay>
Inserts a delay after the source or device has been opened and
initialised, and before the capture begins. Some devices need
this delay to let the image settle after a setting has changed.
The delay time is specified in seconds.
Use read() to capture images. This can be slower but more stable
with some devices.
Default is to use mmap(), falling back on read() if mmap() is
-s, --set <name=value>
Set a control. These are used by the source modules to control
image or device parameters. Numeric values can be expressed as a
percentage of there maximum range or a literal value, for
--set brightness=50% --set framerate=5
Non-numeric controls are also supported:
V4L2 features a type of control called a ’button’. These
controls do not take any value, but trigger an action. For
--set "Restore Factory Settings"
Control names and values are not case sensitive.
Note: Available controls will vary depending in the source
module and devices used. For more information see the
List available controls and their current values for the
selected source module and device. For example:
fswebcam -d v4l2:/dev/video2 --list-controls
These options are performed in the order they appear on the command
line, only effecting images output later on the command line. For
fswebcam -r 640x480 output1.jpeg --scale 320x240 output2.jpeg
Will create two images, "output1.jpeg" containing a full
resolution copy of the captured image and "output2.jpeg"
containing the same captured image but scaled to half the size.
Disable the banner.
Position the banner at the top of the image.
Position the banner at the bottom of the image.
This is the default.
Set the colour of the banner. Uses the web-style hexadecimal
format (#RRGGBB) to describe the colour, and can support an
alpha channel (#AARRGGBB). Examples:
"#FF0000" is pure red.
"#80000000" is semi-transparent black.
"#FF000000" is invisible (alpha channel is at maximum).
Default is "#40263A93".
Set the colour of the divider line. See --banner-colour for more
Default is "#00FF0000".
Set the colour of the text. See --banner-colour for more
Default is "#00FFFFFF".
--font <[file or font name]:[font size]>
Set the font used in the banner. If no path is specified the
path in the GDFONTPATH environment variable is searched for the
If no font size is specified the default of "10" will be used.
Default is "luxisr:10".
Disable the text shadow.
Enable the text shadow.
This is the default behaviour.
Set the main text, located in the top left of the banner.
Clear the main text.
Set the sub-title text, located in the bottom left of the
Clear the sub-title text.
Set the timestamp text, located in the top right of the banner.
This string is formatted by strftime.
Default is "%Y-%m-%d %H:%M (%Z)".
Clear the timestamp text.
Set the info text, located in the bottom right of the banner.
Clear the info text.
Load a PNG image and overlay it on the image, below the banner.
The image is aligned to the top left.
Note: The underlay is only applied when saving an image and is
not modified by any of the image options or effects.
Clear the underlay image.
Load a PNG image and overlay on the image, above the banner. The
image is aligned to the top left.
Note: The overlay is only applied when saving an image and is
not modified by any of the image options or effects.
Remove the overlay image.
Set JPEG as the output image format. The compression factor is a
value between 0 and 95, or -1 for automatic.
This is the default format, with a factor of "-1".
Set PNG as the output image format. The compression factor can
be a value between 0 and 9, or -1 for automatic.
Saves the image to the specified filename.
Note: This isn’t necessary on the command-line where a filename
alone is enough to save an image.
Revert to the original captured image and resolution. This
undoes all previous effects on the image.
Note: This only reverts the image itself, and not options such
as font, colours and overlay.
Flips the image. Direction can be (h)orizontal or (v)ertical.
--flip h Flips the image horizontally.
--flip h,v Flips the image both horizontally and vertically.
Crop the image. With no offset the cropped area will be the
center of the image. Example:
--crop 320x240 Crops the center 320x240 area of the image.
--crop 10x10,0x0 Crops the 10x10 area at the top left corner of
Scale the image.
Example: "--scale 640x480" scales the image up or down to
Note: The aspect ratio of the image is not maintained.
Rotate the image in right angles (90, 180 and 270 degrees).
Note: Rotating the image 90 or 270 degrees will swap the
Apply a simple deinterlacer to the image.
Invert all the colours in the image, creating a negative.
Executes the specified command and waits for it to complete
before continuing. The command line is formatted by strftime.
If you liked this article, subscribe to the feed by clicking the image below to keep informed about new contents of the blog: