node-libcamera
v1.0.6
Published
A Node.js wrapper for the Raspberry Pi libcamera API
Downloads
45
Maintainers
Readme
node-libcamera 📷
A set of wrapper functions for the native Raspberry Pi libcamera
API.
Open to any and all contributions!
Installation
npm install node-libcamera
Usage
libcamera-still
Capture an image!
const libcamera = require('node-libcamera')
// basic example
libcamera.still({ output: 'test.jpg' })
.then((result) => /* 📸 */ )
.catch((error) => /* 🐛 */ )
// example with options
libcamera.still({
output: 'images/test.jpg', // output file path
timeout: 2000, // timeout before taking the picture
width: 640, // image width
height: 480, // image height
})
.then((result) => /* 📸 */ )
.catch((error) => /* 🐛 */ )
libcamera-vid
Record a video!
const libcamera = require('node-libcamera')
// record a 10s video
libcamera.vid({ output: 'test.h264', timeout: 10000, 'save-pts': 'timestamps.txt' })
.then((result) => /* 🎥 */ )
.catch((error) => /* 🐛 */ )
Note: this will result in an unpackaged video bistream, it is not wrapped in any kind of container format (such as an mp4 file). The save-pts
option can be used to output frame timestamps so that the bitstream can subsequently be converted into an appropriate format using a tool like mkvmerge
.
mkvmerge -o test.mkv --timecodes 0:timestamps.txt test.h264