CommandCam is a simple and easy to use command line webcam image grabber for Windows. It captures a single image from a webcam and stores it in a bitmap file. CommandCam is ideal for use in batch files and other situations where you want a very simple way to automate image capture. CommandCam uses Microsoft’s DirectShow API to access webcams, so it should work with most USB cameras.
Several useful options can be specified using command line arguments.
To specify a time delay between the camera being turned on and the image being grabbed, use the "/delay" option to specify a time delay in milliseconds. For example, to add a 5 second delay,
CommandCam /delay 5000
The default output filename for the grabbed image is "image.bmp". To specify a different filename, use the "/filename" option. If the filename contains any spaces, enclose it in inverted commas. For example, to save the image as "face.bmp":
CommandCam /filename face.bmp
By default, the first available video capture device will be used. To specify a particular device (if you have more than one), use the "/devnum" option. For example, to open the second video capture device:
CommandCam /devnum 2
Alternatively, to specify a capture device by name, use the "/devname" option. If the device name contains any spaces, it should be enclosed in inverted commas. For example, to select a device called “USB Video Device”:
CommandCam /devname "USB Video Device"
To specify a capture device by serial number (for example if you wish to select between two cameras of the same model), use the "/devserial" option. For example, to select a device with the serial number “314159265”:
CommandCam /devserial 314159265
By default, CommandCam does not display any video on the screen before capturing the image. However, you can enable a video preview window using the "/preview" option.
To list the available capture devices, for example to check which device number corresponds to which device, use the "/devlist" option.
To list the available capture devices with extra detail (currently just the DevicePath for each camera), use the "/devlistdetail" option.
More than one command line option can be specified at once. For example, to capture an image from the second video capture device to a file called "output.bmp" after a 10 second delay, the following command would be used:
CommandCam /filename output.bmp /delay 10000 /devnum 2
To suppress the text normally printed to the console by CommandCam (welcome message and other information), use the "/quiet" option.
CommandCam error codes
If CommandCam exits due to an error, it returns one of the following error code values:
- “Error: no filename specified”
- “Error: invalid delay specified”
- “Error: invalid device number”
- “Error: invalid device name”
- “Error: invalid device serial number”
- “Unrecognised command line argument”
- “Could not initialise COM”
- “Could not create filter graph”
- “Could not create capture graph builder”
- “Could not attach capture graph builder to graph”
- “Could not create system device enumerator”
- “No video devices found”
- “No devices found”
- “Video capture device not found”
- “Error getting device name and DevicePath”
- “Could not create capture filter”
- “Could not add capture filter to graph”
- “Could not create Sample Grabber filter”
- “Could not get ISampleGrabber interface to sample grabber filter”
- “Could not enable sample buffering in the sample grabber”
- “Could not set media type in sample grabber”
- “Could not add Sample Grabber to filter graph”
- “Could not create Null Renderer filter”
- “Could not add Null Renderer to filter graph”
- “Could not render capture video stream”
- “Could not render preview video stream”
- “Could not get media control interface”
- “Could not run filter graph”
- “Could not get buffer size”
- “Could not allocate data buffer for image”
- “Could not get buffer data from sample grabber”
- “Could not get media type”
- “Error opening output file”
- “Wrong media type”
Download in the .git repository.