Skip to content

Commit

Permalink
meteor & rtsp-video-recorder lib upgrade (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
boonya authored Nov 1, 2021
1 parent dbda7c1 commit 3da5999
Show file tree
Hide file tree
Showing 27 changed files with 1,583 additions and 506 deletions.
10 changes: 3 additions & 7 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 120

[*.md]
indent_style = space

[*.yml]
[{*.yml,*.yaml,*.md,*.json}]
indent_style = space
indent_size = 2

[package.json]
indent_style = space
indent_size = 2
[*.md]
trim_trailing_whitespace = false
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
RECORDER_FOLDER="~/Movies"
RECORDER_DIR_SIZE_THRESHOLD='1G'
RECORDER_SEGMENT_TIME=600
DEBUG=true
5 changes: 2 additions & 3 deletions .env.recorder.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ TZ='Europe/Kiev'
ROOT_URL='http://hostname'
PORT=3000
RECORDER_FOLDER='/media/Recorder'
RECORDER_DIR_SIZE_THRESHOLD='450G'
RECORDER_SEGMENT_TIME=300
RECORDER_AUTO_CLEAR=true
RECORDER_DIR_SIZE_THRESHOLD='50G'
RECORDER_SEGMENT_TIME=600
MONGO_URL='mongodb://dbusername:dbusername-password@localhost:27017/dbname'
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module.exports = {
extends: [
'bluedrop',
'bluedrop/config/node',
// 'bluedrop/config/babel',
],
globals: {
NODE_ENV: true,
Expand Down
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ on:
types: [published]

env:
NODE: '12.20.1'
METEOR: '2.0'
NODE: '14.18.1'
METEOR: '2.5'
METEOR_BUNDLE: 'meteor-bundle.tar.gz'

jobs:
Expand Down Expand Up @@ -75,13 +75,13 @@ jobs:
docker-compose.yaml
.env.mongo.template
.env.recorder.template
meteor-ip-cam-recorder.service
meteor-recorder.service
README.md
LICENCE
LICENSE
if-no-files-found: error

release:
name: Release atrifacts
name: Release artifacts
runs-on: ubuntu-20.04
needs: [build-meteor-bundle]
steps:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ name: Verification

on:
push:
# tags-ignore: ['v*']
paths-ignore: ['**.md', 'LICENCE']
tags-ignore: ['v*']
paths-ignore: ['**.md', 'LICENSE']
branches: [main]
pull_request:
types: [opened]
paths-ignore: ['**.md', 'LICENCE']
paths-ignore: ['**.md', 'LICENSE']

env:
NODE: '12.20.1'
METEOR: '2.0'
NODE: '14.18.1'
METEOR: '2.5'

jobs:
lint:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules/
.env.*
*.log
!.env.*.template
*.tar.gz
bundle/
16 changes: 8 additions & 8 deletions .meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.

meteor-base@1.4.0 # Packages every Meteor app needs to have
meteor-base@1.5.1 # Packages every Meteor app needs to have
mobile-experience@1.1.0 # Packages for a great mobile UX
mongo@1.10.1 # The database Meteor supports right now
mongo@1.13.0 # The database Meteor supports right now
reactive-var@1.0.11 # Reactive variable for tracker

standard-minifier-css@1.7.2 # CSS minifier run for production mode
standard-minifier-js@2.6.0 # JS minifier run for production mode
standard-minifier-css@1.7.4 # CSS minifier run for production mode
standard-minifier-js@2.7.1 # JS minifier run for production mode
es5-shim@4.8.0 # ECMAScript 5 compatibility for older browsers
ecmascript@0.15.0 # Enable ECMAScript2015+ syntax in app code
typescript@4.1.2 # Enable TypeScript syntax in .ts and .tsx modules
ecmascript@0.16.0 # Enable ECMAScript2015+ syntax in app code
typescript@4.4.0 # Enable TypeScript syntax in .ts and .tsx modules
shell-server@0.5.0 # Server-side component of the `meteor shell` command
hot-module-replacement@0.2.0 # Update client in development without reloading the page
hot-module-replacement@0.4.0 # Update client in development without reloading the page

autopublish@1.0.7 # Publish all data to the clients (for prototyping)
insecure@1.0.7 # Allow all DB writes from clients (for prototyping)
static-html # Define static page content in .html files
static-html@1.3.2 # Define static page content in .html files
react-meteor-data # React higher-order component for reactively tracking Meteor data
2 changes: 1 addition & 1 deletion .meteor/release
Original file line number Diff line number Diff line change
@@ -1 +1 @@
METEOR@2.0
METEOR@2.5
84 changes: 41 additions & 43 deletions .meteor/versions
Original file line number Diff line number Diff line change
@@ -1,75 +1,73 @@
allow-deny@1.1.0
autopublish@1.0.7
autoupdate@1.7.0
babel-compiler@7.6.0
autoupdate@1.8.0
babel-compiler@7.7.0
babel-runtime@1.5.0
base64@1.0.12
binary-heap@1.0.11
blaze-tools@1.0.10
blaze-tools@1.1.2
boilerplate-generator@1.7.1
caching-compiler@1.2.2
caching-html-compiler@1.1.3
callback-hook@1.3.0
caching-html-compiler@1.2.1
callback-hook@1.4.0
check@1.3.1
ddp@1.4.0
ddp-client@2.4.0
ddp-client@2.5.0
ddp-common@1.4.0
ddp-server@2.3.2
deps@1.0.12
ddp-server@2.5.0
diff-sequence@1.1.1
dynamic-import@0.6.0
ecmascript@0.15.0
ecmascript-runtime@0.7.0
ecmascript-runtime-client@0.11.0
ecmascript-runtime-server@0.10.0
dynamic-import@0.7.2
ecmascript@0.16.0
ecmascript-runtime@0.8.0
ecmascript-runtime-client@0.12.1
ecmascript-runtime-server@0.11.0
ejson@1.1.1
es5-shim@4.8.0
fetch@0.1.1
geojson-utils@1.0.10
hot-code-push@1.0.4
hot-module-replacement@0.2.0
html-tools@1.0.11
htmljs@1.0.11
id-map@1.1.0
hot-module-replacement@0.4.0
html-tools@1.1.2
htmljs@1.1.1
id-map@1.1.1
insecure@1.0.7
inter-process-messaging@0.1.1
launch-screen@1.2.0
livedata@1.0.18
logging@1.2.0
meteor@1.9.3
meteor-base@1.4.0
minifier-css@1.5.3
minifier-js@2.6.0
minimongo@1.6.1
launch-screen@1.3.0
logging@1.3.1
meteor@1.10.0
meteor-base@1.5.1
minifier-css@1.6.0
minifier-js@2.7.1
minimongo@1.7.0
mobile-experience@1.1.0
mobile-status-bar@1.1.0
modern-browsers@0.1.5
modules@0.16.0
modern-browsers@0.1.7
modules@0.17.0
modules-runtime@0.12.0
modules-runtime-hot@0.13.0
mongo@1.10.1
modules-runtime-hot@0.14.0
mongo@1.13.0
mongo-decimal@0.1.2
mongo-dev-server@1.1.0
mongo-id@1.0.7
npm-mongo@3.8.1
mongo-id@1.0.8
npm-mongo@3.9.1
ordered-dict@1.1.0
promise@0.11.2
promise@0.12.0
random@1.2.0
react-fast-refresh@0.1.0
react-meteor-data@2.1.4
react-fast-refresh@0.2.0
react-meteor-data@2.3.3
reactive-var@1.0.11
reload@1.3.1
retry@1.1.0
routepolicy@1.1.0
routepolicy@1.1.1
shell-server@0.5.0
socket-stream-client@0.3.1
spacebars-compiler@1.1.3
standard-minifier-css@1.7.2
standard-minifier-js@2.6.0
static-html@1.2.2
templating-tools@1.1.2
socket-stream-client@0.4.0
spacebars-compiler@1.3.0
standard-minifier-css@1.7.4
standard-minifier-js@2.7.1
static-html@1.3.2
templating-tools@1.2.1
tracker@1.2.0
typescript@4.1.2
typescript@4.4.0
underscore@1.0.10
webapp@1.10.0
webapp@1.13.0
webapp-hashing@1.1.0
3 changes: 1 addition & 2 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
12.20.1

14.18.1
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM node:12-alpine as builder
FROM node:14.18.1-alpine as builder

ARG BUNDLE=meteor-ip-cam-recorder.tar.gz
ARG BUNDLE=meteor-recorder.tar.gz
COPY $BUNDLE meteor-bundle.tar.gz

RUN apk add --no-cache --virtual .gyp python make g++ \
Expand All @@ -9,8 +9,7 @@ RUN apk add --no-cache --virtual .gyp python make g++ \
&& (cd bundle/programs/server && npm install) \
&& apk del .gyp


FROM node:12-alpine
FROM node:14.18.1-alpine

WORKDIR /usr/src/app
COPY --from=builder bundle .
Expand Down
2 changes: 1 addition & 1 deletion LICENCE → LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MIT License
# MIT License

Copyright (c) 2021 Serhii [boonya] Buinytskyi

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Video Recorder application that captures IP Web Cams RTSP streams

![Verification](https://github.com/boonya/meteor-ip-cam-recorder/workflows/Verification/badge.svg)
![Release](https://github.com/boonya/meteor-ip-cam-recorder/workflows/Build%20and%20release%20bundle%20and%20docker%20image/badge.svg)
![Verification](https://github.com/boonya/meteor-recorder/workflows/Verification/badge.svg)
![Release](https://github.com/boonya/meteor-recorder/workflows/Build%20and%20release%20bundle%20and%20docker%20image/badge.svg)

## Run application in dev mode

Expand Down
2 changes: 1 addition & 1 deletion client/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
</head>

<body>
<div id="react-target"></div>
<div id="root"></div>
</body>
2 changes: 1 addition & 1 deletion client/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import React from 'react';
import {render} from 'react-dom';

Meteor.startup(() => {
render(<App />, document.getElementById('react-target'));
render(<App />, document.getElementById('root'));
});
4 changes: 2 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: '3'
services:
recorder:
container_name: meteor-ip-cam-recorder
image: boonya/meteor-ip-cam-recorder:latest
container_name: meteor-recorder
image: boonya/meteor-recorder:latest
depends_on:
- mongo
network_mode: host
Expand Down
32 changes: 23 additions & 9 deletions imports/api/recorder.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import {RECORDER} from '../config';
import {RECORDER, ENV} from '../config';
import {CAMERA_STATE} from '../constants';
import {logInfo, logError} from '../utils/logger';
import {getStream} from './camera';
import {EventEmitter} from 'events';
import RtspRecorder, {RecorderEvents} from 'rtsp-video-recorder';

const log = (event) => (...args) => {
logInfo('Recorder Event', event, 'at', new Date().toString())(...args);
logInfo(`Recorder Event "${event}" at`, new Date().toString())(...args);
};

const logProgress = log(RecorderEvents.PROGRESS);

export const Events = {
INIT: 'init',
INITIALIZED: 'initialized',
Expand Down Expand Up @@ -41,28 +43,40 @@ export default class Recorder {
}

_createRecorder(_id, uri, title) {
const prefix = title.replace(/ /ug, '_');
const recorder = new RtspRecorder(uri, RECORDER.FOLDER, {
title,
filePattern: title && `${title.replace(/%/ug, '%%').replace(/ /ug, '_')}/%Y.%m.%d/%H.%M.%S`,
playlistName: prefix && `${prefix}-$(date +%Y.%m.%d-%H.%M.%S)`,
filePattern: prefix && `${prefix.replace(/%/ug, '%%')}-%Y.%m.%d/%H.%M.%S`,
segmentTime: RECORDER.SEGMENT_TIME,
dirSizeThreshold: RECORDER.DIR_SIZE_THRESHOLD,
autoClear: RECORDER.AUTO_CLEAR,
});

recorder
.on(RecorderEvents.STARTED, (...args) => this.eventEmitter.emit(Events.STARTED, _id, ...args))
.on(RecorderEvents.STOPPED, (...args) => this.eventEmitter.emit(Events.STOPPED, _id, ...args));

recorder
.on(RecorderEvents.START, log(RecorderEvents.START))
.on(RecorderEvents.STARTED, log(RecorderEvents.STARTED))
.on(RecorderEvents.STOP, log(RecorderEvents.STOP))
.on(RecorderEvents.STOPPED, log(RecorderEvents.STOPPED))
.on(RecorderEvents.ERROR, log(RecorderEvents.ERROR))
.on(RecorderEvents.SEGMENT_STARTED, log(RecorderEvents.SEGMENT_STARTED))
.on(RecorderEvents.FILE_CREATED, log(RecorderEvents.FILE_CREATED))
.on(RecorderEvents.STOP, log(RecorderEvents.STOP))
// .on(RecorderEvents.PROGRESS, log(RecorderEvents.PROGRESS))
.on(RecorderEvents.SPACE_FULL, log(RecorderEvents.SPACE_FULL))
.on(RecorderEvents.SPACE_WIPED, log(RecorderEvents.SPACE_WIPED));
.on(RecorderEvents.SPACE_FULL, log(RecorderEvents.SPACE_FULL));

if (ENV.DEBUG_PROGRESS) {
recorder.on(RecorderEvents.PROGRESS, logProgress);
}
else {
recorder
.on(RecorderEvents.STARTED, () => {
recorder.removeListener(RecorderEvents.PROGRESS, logProgress);
})
.on(RecorderEvents.STOP, () => {
recorder.on(RecorderEvents.PROGRESS, logProgress);
});
}

return recorder;
}
Expand Down
Loading

0 comments on commit 3da5999

Please sign in to comment.