A very lightweight promise based Node.js wrapper for the native Raspberry Pi Camera CLI tools.
Note: This was written with the intent of NOT being a hand holding library, but rather just give you access to execute commands on the camera in a flexible way.
Want to Contribute or Help Out?
Feel free to head over to the GitHub page for Pi-Camera and submit comments, issues, pulls, and whatever else you'd like. I plan on adding features as I need them for my own projects so if something isn't happening fast enough for you why not fix it? (:
// NPM 5npm install pi-camera// Older NPM versionsnpm install pi-camera --save
Raspistill (Image Capture)
const PiCamera = ;const myCamera =mode: 'photo'output: `/test.jpg`width: 640height: 480nopreview: true;myCamera;
You may use the snapDataUrl method for capturing a photo in Data-URL format (i.e. for embedding it in a website) without saving it to disk.
const PiCamera = ;const myCamera =mode: 'photo'width: 640height: 480nopreview: true;myCamera;
Raspivid (Video Capture)
const PiCamera = ;const myCamera =mode: 'video'output: `/video.h264`width: 1920height: 1080timeout: 5000 // Record for 5 secondsnopreview: true;myCamera;
Something worth considering is that the Camera module captures videos in a .h264 format, which is raw and uncompressed. Most players do not support this format so you might want to convert your files into something like .mp4. You can read more about it here.
Flags and Options
The Raspistill and Raspivid commands support a good number of parameters and options.
Currently they're all stored in the same files, so you'll need to do your do diligence and make sure you're using the correct options and flags for what you're trying to do. A good list of them can be found here
What's the difference between Flags and Options?
Flags are portions of the
Raspivid commands that are passed and require no additional input to fuction like so:
# NOTE: Not a working commandraspistill --nopreview --raw --hflip --vflip
Options are portions of the
Raspivid commands that are passed and require additional input to fuction like so:
# NOTE: Not a working commandraspistill --output some/path/here --width 1080 --height 720
While the command line tools support many flags and options they're not all configured in this lib. If you discover one that you need but isn't supported, consider testing it, adding it and making a PR.