npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nvr-js

v2.0.0

Published

A simple, lightweight, but very functional NVR aimed at 24/7 recording using nodejs

Downloads

28

Readme

Image

nvr-js

NPM npm Language grade: JavaScript npms.io (maintenance) Libraries.io dependency status for latest release

NVR JS is a simple, very lightweight and efficient CCTV NVR based on Node JS.
it's primarily aimed for 24/7 recording and live viewing.

Under the hood it uses ffmpeg, node js, websockets and sqlite, all wrapped in a web based user interface. The NVR has an API that allows to create events and timestamp them on the 24/7 recordings.

The 24/7 recordings can be reviewed using a timeline UI where the events are also time aligned on that same timeline.

Image

Inspired by shinobi.video

Shinobi is a fully featured, jam packed NVR, also built using Node JS. I was using Shinobi and thought it was amazing! - however, it had sooo much to it, and was too overkill for my needs.

You can think of NVR-JS as a very slimed down version of shinobi video, built from the ground up.
the table below, shows how slimmed down it is.

| Feature | Shinobi | NVR JS | |-------------------|---------|---------------------| | Motion Dectection | ✓ | | | Object Detection | ✓ | | | 24/7 Recording | ✓ | ✓ | | Event Creation | ✓ | ✓ (API Only) | | Notifications | ✓ | | | Live Streaming | ✓ | ✓ (Websocket) | | Configuration UI | ✓ | Manual Editing | | Mobile Support | ✓ | |

As you can see, NVR JS does not pack the same features as Shinobi Video, but that's the intention.
NVR JS is designed for 24/7 recording with access to live footage, and the 24/7 recordings.

Configuration.

The first time you start NVR JS, it will create a config file at /%home%/nvrjs.config.js,
it will then terminate allowing you to start adjusting your system, before starting it up again.

module.exports = {
	/* System Settings */
	system: {
		/* Username */
		username: "admin",
		/* bcrypt password (default: admin) */
		password: '$2a$10$CnOx/6vFY2ehRDf68yqd..aLlv0UM.zeBLKnRjuU8YykCsC2Ap3iG',
		/* bcrypt API Key (default: x7Te9m38JHQq6ddv) */
		apiKey: '$2a$10$N53ci.EIQ7JCu6u1HlOjoO//W0Bmp3GrRruyK1Jysr01CQ1rDrVQK',
		/* Any random string */
		cookieKey: 'f3gi6FLhIPVV31d1TBQUPEAngrI3wAoP',
		interfacePort: 7878,
		/* location used for 24/7 recording and database generation */
		/* This should be the root of a mount point i.e a dedicated HDD for 24/7 recordings */
		storageVolume: '/Volumes/CCTV',
		/* Continuous recording settings */
		ffmpegLocation: 'ffmpeg',
		continuousSegTimeMinutes: 15,
		continuousDays: 14,
		continuousPurgeIntervalHours: 24,
		/* event throttle per sensorId */
		eventSensorIdCoolOffSeconds: 60
	},
	/* Cameras */
	cameras: {
		'66e39d21-72c4-405c-a838-05a8e8fe0742': {
			name: 'Garage',
			/* Input Source Config */
			/* The keys and values represent the ffmpeg options */
			inputConfig: {
				use_wallclock_as_timestamps: '1',
				fflags: '+igndts',
				analyzeduration: '1000000',
				probesize: '1000000',
				rtsp_transport: 'tcp',
				stimeout: '30000000'
			},
			/* Input Address */
			input: 'rtsp://user:password@ip:port/live0',
			/* Recording 24/7 */
			/* Disabling continuous recording, will disable the ability to create events */
			continuous: true,
			/* Live streaming config */
			/* These settings should be good enough for a low delay live stream, providing your camera produces h264 frames */
			/* streaming is achieved with websockets and MP4 fragments */
			liveConfig: {
				codecString: 'video/mp4; codecs="avc1.64001f"',
				streamConfig: {
					an: '',
					vcodec: 'copy',
					f: 'mp4',
					movflags: '+frag_keyframe+empty_moov+default_base_moof',
					reset_timestamps: '1'
				}
			}
		}
	}
};

The Event API.

To create events one only needs to send the following JSON payload.

The view here, is that you create events from various sensors in your setup, this effectively acts as your motion detector or some other key event - It's really up to you.

{
     "name": "Motion Detected" | "Door Opened" | "Some Other Event" | "Of Your Choice",
     "sensorId": "HUEN849",
     "date": 1636194611
}

You POST this payload to the API as follows:
http://IP:7878/api/{APIKey}/event/{camera-id}
Example: http://IP:7878/api/x7Te9m38JHQq6ddv/event/66e39d21-72c4-405c-a838-05a8e8fe0742

Anyway

I built this for my needs, it's very DIY and will likely have some faults in some places.
But if you want to use it, change it, build on it, feel free - I welcome PR's.

npm install nvr-js
cd ./node_modules/nvr-js
pm2 start NVRJS.js
pm2 save

Change Log