node-libcamera
Version:
A Node.js wrapper for the Raspberry Pi libcamera API
62 lines (44 loc) • 1.89 kB
Markdown
//img.shields.io/npm/v/node-libcamera)




A set of wrapper functions for the native [Raspberry Pi `libcamera` API](https://www.raspberrypi.com/documentation/accessories/camera.html).
_Open to any and all contributions!_
```bash
npm install node-libcamera
```
Capture an image!
```js
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) => /* 🐛 */ )
```
Record a video!
```js
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`.
```bash
mkvmerge -o test.mkv --timecodes 0:timestamps.txt test.h264
```
![npm](https: