marcus-j-davies / nvr-js

A simple, lightweight, but very functional NVR aimed at 24/7 recording using nodejs.
MIT License
25 stars 13 forks source link

Some basic question #15

Closed lafar6502 closed 1 year ago

lafar6502 commented 1 year ago

Hi, many thanks for creating NVRJS, i like how small and simple it is, and was able to run it without much hassle. It's great that it doesn't require 5 different programming languages, docker, and half of the Internet to run. However, i have some basic questions

  1. Does it automatically overwrite the oldest recordings when it runs out of disk space?
  2. Is there an option to set the maximum size of recordings to keep? Or does it take the whole partition?
  3. I'm using a hdd for storage and it keeps spinning all the time. However, i was thinking, maybe it would be possible to spin it down periodically to save power and keep the temperature lower. I know the streams need to be written continuously, but maybe there could be an option to write them to a scratch location (on an ssd drive, for example), and only when whole file is complete move it to the hdd. This way hdd would need to wake up every few minutes only. Not sure if this idea makes sense, just putting it here for discussion.

Best regards RG

marcus-j-davies commented 1 year ago

Hi @lafar6502

1. It does not, the storage volume set in the config, is expected to meet space requirements, this is also covered in point 2.

2. Yes, there are 3 config options, one for maximum days, one for how often to delete old recordings (based on when they exceed the maximum days), and the segment time of each video file.

3. This will require some overhaul, and isn't something I can commit to at this time (PRs are welcome 😁) - base them on the 3.0 branch if you do.

There is a PR to release V3 (which has some breaking changes), but sadly finding time is impossible currently.

I do like the idea, of using a scratch volume - but can't provide any meaningful input at this. 😇

lafar6502 commented 1 year ago

Thanks for quick reply, same problem with free time here. But i'll try to understand the nvrjs code a bit better. For now i have one issue, something fails when i tried to add a second camera stream (the first camera works ok, only the second one seems to fail):


 - Camera: dahu2 was terminated, respawning after 10 seconds...
disk name invalid, using / as default
disk name invalid, using / as default
(node:908) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [Server]. Use emitter.setMaxListeners() to increase limit
(node:908) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 listening listeners added to [Server]. Use emitter.setMaxListeners() to increase limit
(node:908) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 upgrade listeners added to [Server]. Use emitter.setMaxListeners() to increase limit
 - Camera: dahu2 was terminated, respawning after 10 seconds...
disk name invalid, using / as default
disk name invalid, using / as default
 - Camera: dahu2 was terminated, respawning after 10 seconds...
disk name invalid, using / as default
disk name invalid, using / as default
disk name invalid, using / as default
 - Camera: dahu2 was terminated, respawning after 10 seconds...
disk name invalid, using / as default

the rtsp stream has been verified to be working (can see the preview in VLC) but something fails in nvrjs. Maybe it's something simple/stupid but for now i can't tell. And btw where does this 'disk name invalid, using / as default' message come from - is it from ffmpeg? Maybe there is an option to see more detailed/debug output from ffmpeg?

I'll try switching to v3 but not today..

marcus-j-davies commented 1 year ago

The disk name invalid can be ignored - usually it's because the storage location you have set, is not at the root mount point of the volume.

The storage volume, should be a root volume, /media/cctv for example, but if using a sub folder, the disc space check (for the UI), wants the name of the mount point, and it's not expecting to hit a sub folder.

As for the second camera, ffmpeg is not happy about something, is it using a different codec to the first?

marcus-j-davies commented 1 year ago

V3 allows more control of the encoding chain - I.e if the camera is using libx265 for example.

The input chain, can be modified to work with different setups already.

I think sometimes, some codecs are not suitable to convert to fMP4 (which is used in the UI)

lafar6502 commented 1 year ago

heh, found it! - collected messages from ffmpeg stderr and there it was: ffmpeg didn't like the audio codec (pcm_alaw) used by the camera. So i added this option to the camera config:

postInput: { audioEncoder: 'aac' }

And now it works. BTW switched to v3 too. Thanks!

marcus-j-davies commented 1 year ago

Nice work, I really need to publish v3 at some point.

It's used in a large corporate setup (not by me) but does need more testing. So let me know how it goes.

marcus-j-davies commented 1 year ago

I don't think there is anymore todo here, but ill make a note of the Scratch disk request.