LinuxCommandLibrary

fswebcam

Capture images from a webcam

TLDR

Take a picture

$ fswebcam [filename]
copy

Take a picture with custom resolution
$ fswebcam [[-r|--resolution]] [width]x[height] [filename]
copy

Take a picture from selected device(Default is /dev/video0)
$ fswebcam [[-d|--device]] [device] [filename]
copy

Take a picture with timestamp(timestamp string is formatted by strftime)
$ fswebcam --timestamp [timestamp] [filename]
copy

SYNOPSIS

fswebcam [options...] output-filename

PARAMETERS

-d, --device <dev>
    Video device to use (default: /dev/video0)

-r, --resolution <WxH>
    Set capture resolution (e.g., 640x480)

-p, --pixels <WxH>
    Capture specific pixel count from larger frame

-g, --crop <WxH[+X+Y]>
    Crop input image to specified region

-S, --skip <N>
    Skip N frames before capture for stability

-D, --delay <secs>
    Wait N seconds before capturing

-t, --timestamp <format>
    Overlay timestamp using strftime format

-T, --text <text[:x:y:w:h:font:size]>
    Overlay custom text with position/font options

-l, --list-devices
    List all available V4L devices

-L, --list-formats
    List formats for current device

--jpeg <0-100>
    JPEG quality level (default: 75)

--png <0-9>
    PNG compression level (default: 6)

-R, --rotate <value>
    Rotate image (0,90,180,270)

--set <control>=<value>
    Set V4L control (e.g., brightness=128)

--get <control>
    Get V4L control value

--list-controls
    List available V4L controls

-i, --info
    Display camera information

-q, --quiet
    Suppress non-error messages

--no-banner
    Skip startup banner

-h, --help
    Show usage help

-v, --version
    Print version info

DESCRIPTION

fswebcam is a simple, efficient command-line tool for capturing still images from USB webcams and other Video4Linux (V4L1/V4L2) devices on Linux. Designed for minimalism, it supports output in multiple formats like JPEG, PNG, GIF, PBM, PGM, PPM, PNM, and PAM, determined by the filename extension. Key features include resolution control, frame skipping for stability, delays, image rotation, cropping, and overlays for timestamps or custom text with font/size options. It exposes V4L controls for brightness, contrast, and more via --set and --get. Ideal for automation, scripts, headless servers, or embedded systems due to low resource use and few dependencies (libjpeg, libpng). Unlike complex tools like ffmpeg, fswebcam prioritizes speed and ease for basic snapshots, automatically handling palette conversions and device detection.

CAVEATS

Relies on V4L1/V4L2; limited support for modern USB3/h.264 cameras without modules. Requires /dev/video* permissions. No video recording or advanced streaming.

SUPPORTED FORMATS

JPEG, PNG, GIF, PBM, PGM, PPM, PNM, PAM
Auto-detected from output filename extension.

BASIC EXAMPLE

fswebcam -r 1280x720 --jpeg 90 -D 2 -S 10 snapshot.jpg
720p capture, 90% quality, 2s delay, skip 10 frames.

HISTORY

Created by Philip Heron in 2007 as a lightweight V4L grabber. Open-source (GPL), hosted on SourceForge; actively used in scripts and embedded Linux for over 15 years due to stability and simplicity.

SEE ALSO

v4l2-ctl(1), ffmpeg(1), motion(8), mplayer(1)

Copied to clipboard