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 🙏

© 2025 – Pkg Stats / Ryan Hefner

hls-motion-detect

v1.0.3

Published

Motion detection based on Apple HTTP Live Stream

Downloads

7

Readme

Motion Detection Server

Watch Apple HTTP Live Stream (HLS) and record to disc mp4 files containing the captured motions.

Usage

const motion = require('hls-motion-detect');

let detectServer = new motion.DetectServer({
	ffmpegPath: 'ffmpeg', 
	ffprobePath: 'ffprobe', 
	recordingsPath: './recorded'
})
.listen(1336)
.on('source-added', (source) => {
	console.log(`New Source added [${source.systemName}] URL [${source.sourceURL}]`);
	
	source
	.on('start', (filepath) => {
		console.log(`Source [${source.systemName}] started`);
	})
	.on('stop', () => {
		console.log(`Source [${source.systemName}] stopped`);
	})
	.on('record-start', (filepath) => {
		console.log(`Source [${source.systemName}] started recording: ${filepath}`);
	})
	.on('record-stop', (filepath) => {
		console.log(`Source [${source.systemName}] stopped recording`);
	});
})
.on('source-removed', (systemName) => {
	console.log(`Source removed [${systemName}]`);
});

REST API

You can controll the detect server using REST API:

let apiServer = new motion.ApiServer(detectServer)
.listen(1337)
.on('listen', (port) => {
	console.log(`REST API server running at port ${port}`);
}).
on('debug', (msg) => {
	console.log(msg);
}).
on('error', (msg) => {
	console.error(msg);
});

API enables add, delete, start and stop.

http://localhost:1337/source/add

{
	"systemName": "test",
	"name": "test",
	"sourceURL": "http://myLiveServer/live/myStream/index.m3u8"
}

http://localhost:1337/source/delete

{
	"systemName": "test"
}

http://localhost:1337/source/start

{
	"systemName": "test",
	"interval": 3, // in seconds, if not specified default is one second.
	"x": 100, // not supported yet, defaults to 0.
	"y": 100, // not supported yet, defaults to 0.
	"width": 100, // not supported yet, defaults to 0.
	"height": 100, // not supported yet, defaults to 0.
	"threshold": 30, // (between 1 and 50) defaults to 35, use higher value to increase sensitivity and lower value to decrease sensitivity.
	"maxIdleTime": 60 // time to wait since last segment detected to raise idle event (Used by RabbitMQ to remove the source).
}

http://localhost:1337/source/stop

{
	"systemName": "test"
}

Web UI

You can controll the detect server using web UI:

let webServer = new motion.WebServer(detectServer)
.listen({
	port: 3888,
	path: './lib/plugins/web-server/web', // you can change that static path to your own web folder
})
.on('listen', (port) => {
	console.log(`Web server running at port ${port}`);
});

RabbitMQ Messages

You add sources through RabbitMQ:

let rabbitServer = new motion.RabbitServer(detectServer)
.on('listen', () => {
	console.log('Rabbit-MQ server running');
}).
on('error', (msg) => {
	console.error(msg);
})
.listen({
//	auth: 'guest:guest',
	host: 'localhost',
//	port: 5672,
	queue: 'stream-queue'
});

RabbitMQ plugins supports only adding new source, once the source is idle it will be removed automatically.

Kaltura Integration

Kaltura plugin will automatically upload recorded files to your Kaltura account.

let kaltura = new Kaltura(detectServer, {
	partnerId: 123, // replace with your Kaltura account id
	secret: 'your secret here'
})
.on('error', (msg) => {
	console.error(msg);
})
.on('entry-created', (entry) => {
	console.log(`New entry [${entry.id}] uploaded`);
});

Tools

To test Rabbit-MQ message, use utils/addRabbitMessage.js