Skip to content

Commit

Permalink
v1.1.12
Browse files Browse the repository at this point in the history
  • Loading branch information
seydx committed Apr 23, 2022
1 parent 36fd5c8 commit 9fdd3ff
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 45 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
# Changelog
All notable changes to this project will be documented in this file.

# v1.1.12 - 2022-04-23

## Other Changes
- Improved probe stream
- Minor improvements
- Bump dependencies

## Bugfixes
- Fixed an issue where recording information such as motion label was not correctly saved in the image data
- Fixed an issue where prebuffering and/or video analysis was started for disabled cameras anyway
- Minor bugfixes

# v1.1.11 - 2022-04-23

## Notable Changes
Expand Down
41 changes: 10 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "camera.ui",
"version": "1.1.11",
"version": "1.1.12-beta.1",
"description": "NVR like user interface for RTSP capable cameras.",
"author": "SeydX (https://github.com/SeydX/camera.ui)",
"scripts": {
Expand All @@ -27,7 +27,7 @@
"connect-history-api-fallback": "^1.6.0",
"cors": "^2.8.5",
"express": "^4.17.3",
"ffmpeg-for-homebridge": "^0.0.9",
"ffmpeg-for-homebridge": "0.0.9",
"fs-extra": "^10.1.0",
"ftp-srv": "^4.6.0",
"got": "^12.0.3",
Expand Down Expand Up @@ -65,7 +65,7 @@
"eslint": "^8.13.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^26.1.4",
"eslint-plugin-jest": "^26.1.5",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-unicorn": "^42.0.0",
"jest": "^27.5.1",
Expand Down
7 changes: 3 additions & 4 deletions src/api/components/notifications/notifications.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,12 @@ export const createNotification = async (data) => {
const cameraSetting = camerasSettings.find((cameraSetting) => cameraSetting && cameraSetting.name === camera.name);

const id = data.id || (await nanoid());
const cameraName = camera.name;
const room = cameraSetting ? cameraSetting.room : 'Standard';
const timestamp = data.timestamp || moment().unix();
const time = moment.unix(timestamp).format('YYYY-MM-DD HH:mm:ss');

const fileName =
cameraName.replace(/\s+/g, '_') +
camera.name.replace(/\s+/g, '_') +
'-' +
id +
'-' +
Expand All @@ -124,7 +123,7 @@ export const createNotification = async (data) => {

const notification = {
id: id,
camera: cameraName,
camera: camera.name,
fileName: `${fileName}.${extension}`,
name: fileName,
extension: extension,
Expand All @@ -139,7 +138,7 @@ export const createNotification = async (data) => {

const notify = {
...notification,
title: cameraName,
title: camera.name,
message: `${data.trigger} - ${time}`,
subtxt: room,
mediaSource: data.storing ? `/files/${fileName}.${extension}` : false,
Expand Down
5 changes: 3 additions & 2 deletions src/api/components/recordings/recordings.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export const createRecording = async (data, fileBuffer) => {
const cameraSetting = camerasSettings.find((cameraSetting) => cameraSetting && cameraSetting.name === camera.name);

const id = data.id || (await nanoid());
const room = cameraSetting ? cameraSetting.room : 'Standard';
const timestamp = data.timestamp || moment().unix();
const time = moment.unix(timestamp).format('YYYY-MM-DD HH:mm:ss');

Expand All @@ -137,15 +138,15 @@ export const createRecording = async (data, fileBuffer) => {
recordStoring: true,
recordType: data.type,
trigger: data.trigger,
room: cameraSetting.room,
room: room,
time: time,
timestamp: timestamp,
label: label,
};

if (fileBuffer) {
await storeVideoBuffer(camera, fileBuffer, data.path, fileName);
await storeSnapshotFromVideo(camera, data.path, fileName);
await storeSnapshotFromVideo(camera, data.path, fileName, label);
} else {
const isPlaceholder = data.type === 'Video';
const externRecording = false;
Expand Down
4 changes: 2 additions & 2 deletions src/api/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ export default class Database {
let extension = isPlaceholder ? 'mp4' : 'jpeg';
let id = rec.match(/(?<=-)([\dA-z]{10})(?=-)/)[0];
let timestamp = rec.match(/(?<=-)(\d{10})(?=_)/)[0];
let cameraName = rec.match(/(.*?)(?=-[\dA-z]{10})/)[0];
let cameraName = rec.match(/(.*?)(?=-[\dA-z]{10})/)[0]?.replace(/_/g, ' ');
let cameraSetting = cameras.find((camera) => camera?.name === cameraName);

const jpeg = fs.readFileSync(filePath);
Expand All @@ -327,7 +327,7 @@ export default class Database {

return {
id: id,
camera: cameraName.replace(/_/g, ' '),
camera: cameraName,
fileName: `${fileName}.${extension}`,
name: fileName,
extension: extension,
Expand Down
5 changes: 4 additions & 1 deletion src/common/ffmpeg.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export const getAndStoreSnapshot = (
});
};

export const storeSnapshotFromVideo = async (camera, recordingPath, fileName) => {
export const storeSnapshotFromVideo = async (camera, recordingPath, fileName, label) => {
return new Promise((resolve, reject) => {
const videoProcessor = ConfigService.ui.options.videoProcessor;
const videoName = `${recordingPath}/${fileName}.mp4`;
Expand Down Expand Up @@ -282,6 +282,9 @@ export const storeSnapshotFromVideo = async (camera, recordingPath, fileName) =>
reject(new Error(errors.join(' - ')));
} else {
log.debug('FFmpeg snapshot process exited (expected)', camera.name, 'ffmpeg');

replaceJpegWithExifJPEG(camera.name, destination, label);

resolve();
}
});
Expand Down
10 changes: 9 additions & 1 deletion src/controller/camera/camera.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ export default class CameraController {

await controller.media.probe();

if (controller.options?.disable) {
return;
}

if (controller.options?.prebuffering) {
await controller.prebuffer.start();
}
Expand All @@ -87,7 +91,7 @@ export default class CameraController {
await controller.videoanalysis.start();
}

await controller.stream.configureStreamOptions();
//await controller.stream.configureStreamOptions();
}

static async reconfigureController(cameraName) {
Expand All @@ -97,6 +101,10 @@ export default class CameraController {
throw new Error(`Can not reconfigure controller, controller for ${cameraName} not found!`);
}

if (camera.disable) {
return;
}

const camera = ConfigService.ui.cameras.find((camera) => camera.name === cameraName);

if (!camera) {
Expand Down
11 changes: 11 additions & 0 deletions src/controller/camera/services/media.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export default class MediaService {
timedout: false,
audio: [],
video: [],
bitrate: '? kb/s',
mapvideo: '',
mapaudio: '',
};
}

Expand Down Expand Up @@ -67,16 +70,24 @@ export default class MediaService {
ConfigService.ffmpegVersion = line.split(' ')[2];
}

const bitrateLine = line.includes('start: ') && line.includes('bitrate: ') ? line.split('bitrate: ')[1] : false;

if (bitrateLine) {
this.codecs.bitrate = bitrateLine;
}

const audioLine = line.includes('Audio: ') ? line.split('Audio: ')[1] : false;

if (audioLine) {
this.codecs.audio = audioLine.split(', ');
this.codecs.mapaudio = line.split('Stream #')[1]?.split(': Audio')[0];
}

const videoLine = line.includes('Video: ') ? line.split('Video: ')[1] : false;

if (videoLine) {
this.codecs.video = videoLine.split(', ');
this.codecs.mapvideo = line.split('Stream #')[1]?.split(': Video')[0];
}

lines++;
Expand Down
6 changes: 5 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ export default class Interface extends EventEmitter {

await controller[1].media.probe();

if (controller[1].options?.disable) {
return;
}

if (controller[1].options.prebuffering) {
await controller[1].prebuffer.start();
}
Expand All @@ -79,7 +83,7 @@ export default class Interface extends EventEmitter {
await controller[1].videoanalysis.start();
}

await controller[1].stream.configureStreamOptions();
//await controller[1].stream.configureStreamOptions();
})
);

Expand Down

0 comments on commit 9fdd3ff

Please sign in to comment.