Skip to content

Commit

Permalink
Space limiter (#2)
Browse files Browse the repository at this point in the history
* Auto clear if threshold is reached
* Upgrade dependencies
* getSpaceOccupied helper function and APPROXIMATION_PERCENTAGE term
* Unit testing
* node 8 build is redundant
* Readme, example and github actions
* Do not need TravisCI anymore
  • Loading branch information
boonya authored Apr 4, 2020
1 parent 6a9cae2 commit 59a8607
Show file tree
Hide file tree
Showing 15 changed files with 2,653 additions and 2,326 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: On push workflow
on: [push]
jobs:
job:
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- uses: actions/checkout@v1
- name: Prepare
run: npm ci
- name: TS Lint
uses: mooyoul/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
pattern: "*.ts"
- name: Test
uses: stefanoeb/[email protected]
17 changes: 17 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Publish
on:
release:
types: [published]
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
- run: npm install
- run: npm test
- uses: JS-DevTools/npm-publish@v1
with:
token: ${{ secrets.NPM_TOKEN }}
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ yarn-debug.log*
yarn-error.log*

# Coverage directory used by tools like istanbul
coverage
coverage/

# Dependency directories
node_modules/

# Optional npm cache directory
.npm

dist
dist/
24 changes: 0 additions & 24 deletions .travis.yml

This file was deleted.

38 changes: 32 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

[![build status](https://img.shields.io/travis/com/boonya/rtsp-video-recorder?label=build%20status)](https://travis-ci.com/boonya/rtsp-video-recorder)
[![npm](https://img.shields.io/npm/v/rtsp-video-recorder)](https://www.npmjs.com/package/rtsp-video-recorder)
[![maintainability](https://img.shields.io/codeclimate/maintainability-percentage/boonya/rtsp-video-recorder?label=Maintainability)](https://codeclimate.com/github/boonya/rtsp-video-recorder/maintainability)
[![maintainability](https://img.shields.io/codeclimate/maintainability-percentage/boonya/rtsp-video-recorder?label=maintainability)](https://codeclimate.com/github/boonya/rtsp-video-recorder/maintainability)
![bundle size](https://img.shields.io/bundlephobia/min/rtsp-video-recorder)
![dependencies](https://img.shields.io/librariesio/release/npm/rtsp-video-recorder)

Expand All @@ -25,7 +25,7 @@ If you prefer different package manager or work on different linux distro use ap
Installation process of this lib as simple as it can be. Just run

```bash
npm i rtsp-video-recorder
npm i --save rtsp-video-recorder
```

And after that you can use is as on example below
Expand All @@ -37,7 +37,6 @@ import Recorder, { RecorderEvents } from "rtsp-video-recorder";

const recorder = new Recorder("rtsp://username:password@host/path", "/media/Recorder", {
title: "Test Camera",
segmentTime: 60
});

// Start recording
Expand All @@ -55,14 +54,26 @@ recorder.on(RecorderEvents.ERROR, () => {
/** Do what you need in case of recording error */
});

recorder.on(RecorderEvents.SEGMENT_STARTED, () => {
/** Do what you need in case of new segment started */
});

recorder.on(RecorderEvents.DIRECTORY_CREATED, () => {
/** Do what you need in case of new daily directory created */
/** Do what you need in case of new directory created */
});

recorder.on(RecorderEvents.FILE_CREATED, () => {
/** Do what you need in case of new file created */
});

recorder.on(RecorderEvents.SPACE_FULL, () => {
/** Do what you need in case of space is full */
});

recorder.on(RecorderEvents.SPACE_WIPED, () => {
/** Do what you need in case of space wiped */
});

// Stop recording
recorder.stop();
```
Expand Down Expand Up @@ -94,9 +105,24 @@ _Accepts C++ strftime specifiers:_ http://www.cplusplus.com/reference/ctime/strf

#### segmentTime

Duration of one video file (seconds).
Duration of one video file (in seconds).
600 seconds or 10 minutes by default if not defined.
It can be a number of seconds or string xs, xm or xh what means amount of seconds, minutes or hours respectively.

#### title

Title of video file
Title of video file. Used as metadata of video file.

#### dirSizeThreshold

In case you have this option specified you will have ability to catch `SPACE_FULL` event whent threshold is reached. It can be a number of bytes or string xM, xG or xT what means amount of Megabytes, Gigabytes or Terrabytes respectively.

#### autoClear

This option is `false` bu default. So, if you reach a threshold your `Recorder` emits `SPACE_FULL` event and stops. But if you specify this option as `true` it will remove the oldest directory in case threshold reached out. Also it does emit `SPACE_WIPED` event in case of some directory removed.

_NOTE that option does not make sence if `dirSizeThreshold` option is not specified._

#### ffmpegBinary

In case you need to specify a path to ffmpeg binary you can do it usin this argument.
Loading

0 comments on commit 59a8607

Please sign in to comment.