Code Monkey home page Code Monkey logo

nvr-js's People

Contributors

marcus-j-davies avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

nvr-js's Issues

FFMPEG stderr

Hi,

is it possible to see somewhere stderr from ffmpeg or at least the final ffmpeg command used to capture the camera?

I'm getting an error " - Camera: Domek was terminated, respawning after 10 seconds..." over and over but I'm able to copy stream from camera manually by ffmpeg (e.g.: ffmpeg -i "rtsp://192.168.1.84:5544/live0.264" -c:v copy /mnt/md0/test.mp4)
So there should be something ffmpeg is complaining about and I need to know what.

Thanks

Some basic question

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

[Enhancement]: Review Storage mechanics PLUS!

Hello!

Firstly, I would like to commend you on the work you've done here. It's precisely what I need for a very important project for my city as well.

I am creating a fork of the repository now to begin diving into the codebase and attempt to determine what may be happening on our end, so please know I plan on rolling up my sleeves and helping contribute to a solution, NOT just log the bug :P

Anyhow, please see below:

ISSUE: Many hours after starting PM2 service for NVRJS, the timeline does not show video segments on the timeline.
Context:
We are looking to use NVRJS for the camera systems we've built utilizing Raspberry Pi's, PoE cams + switch, and USB harddrives.

We are so very close thanks to your work here. But after testing for roughly a week, we see timeline issues.

We DO see that it is properly restarting the ffmpeg processes and the files are logging to disk.

So everything seems to be working (ffmpeg, UI), except for some reason the segments stored to disk.

Also, NVRJS runs rock solid (haven't seen it rebooting over and over or anything for days at a time).

Once I DO end up restarting NVRJS, the timeline begins working normally, though is missing files that are definitely on disk.

I'll log here if I make progress on it!

Thank you for any insight you can help with though :)

Question

I had a problem but I managed to solve it myself.

Camera: xxx was terminated, respawning after 10 seconds

I got 2 errors, one is ''Camera: Garage was terminated, respawning after 10 seconds...",
the other one is "disk name invalid, using / as default"
i checked the .mp4 files, the size all is 0 byte.
I run the code on ubuntu18.04, node versoin v16.15.1.

it's my log.

Checking config.
Config loaded: /home/trc/nvrjs.config.js
Checking volumes and ffmpeg.
Creating db structure.
Starting data write queue.
Creating express application.
Compiling pages.
Configuring camera: Garage
NVR JS is Ready!
Connecting to db.
Starting purge interval.
Purging data.
Camera: Garage was terminated, respawning after 10 seconds...
disk name invalid, using / as default
disk name invalid, using / as default
Camera: Garage was terminated, respawning after 10 seconds...
disk name invalid, using / as default
disk name invalid, using / as default

I modified the config file like this:

module.exports = {
	/* System Settings */
	system: {
		/* Username */
		username: "admin",
		/* bcrypt password (default: admin) */
		password: '$2a$10$CnOx/6vFY2ehRDf68yqd..aLlv0UM.zeBLKnRjuU8YykCsC2Ap3iG',
		/* bcrypt API Key (default: x7Te9m38JHQq6ddv) */
		apiKey: '$2a$10$N53ci.EIQ7JCu6u1HlOjoO//W0Bmp3GrRruyK1Jysr01CQ1rDrVQK',
		/* Any random string */
		cookieKey: 'f3gi6FLhIPVV31d1TBQUPEAngrI3wAoP',
		interfacePort: 7878,
		/* location used for 24/7 recording and database generation */
		/* This should be the root of a mount point i.e a dedicated HDD for 24/7 recordings */
		storageVolume: '/home/trc/',
		/* Continuous recording settings */
		ffmpegLocation: '/usr/bin/ffmpeg',
		continuousSegTimeMinutes: 15,
		continuousDays: 14,
		continuousPurgeIntervalHours: 24,
		/* event throttle per sensorId */
		eventSensorIdCoolOffSeconds: 60
	},
	/* Cameras */
	cameras: {
		'66e39d21-72c4-405c-a838-05a8e8fe0742': {
			name: 'Garage',
			/* Input Source Config */
			/* The keys and values represent the ffmpeg options */
			inputConfig: {
				use_wallclock_as_timestamps: '1',
				fflags: '+igndts',
				analyzeduration: '1000000',
				probesize: '1000000',
				rtsp_transport: 'tcp',
				stimeout: '30000000'
			},
			/* Input Address */
			input: 'rtsp://admin:[email protected]:554?channel=1&subtype=0',
			/* Recording 24/7 */
			/* Disabling continuous recording, will disable the ability to create events */
			continuous: true,
			/* Live streaming config */
			/* These settings should be good enough for a low delay live stream, providing your camera produces h264 frames */
			/* streaming is achieved with websockets and MP4 fragments */
			liveConfig: {
				codecString: 'video/mp4; codecs="avc1.64001f"',
				streamConfig: {
					an: '',
					vcodec: 'copy',
					f: 'mp4',
					movflags: '+frag_keyframe+empty_moov+default_base_moof',
					reset_timestamps: '1'
				}
			}
		}
	}
};

if i use the rtsp url on VLC player, i can see the rtsp stream.
but the viewer could not show anything about camera data.

Selection_001

Does anyone know the reason?

Can nvr-js support Windows?

I have a problem in my windows 10

C:\node\nvr-js-main>node NVRJS.js
 - Checking config.
 - Config loaded: C:\Users\Maldini\nvrjs.config.js
 - Checking volumes and ffmpeg.
 - Connecting to db.
 - Starting data write queue.
 - Creating express application.
 - Compiling pages.
 - Configuring camera: Garage
 - NVR JS is Ready!
node:events:505
      throw er; // Unhandled 'error' event
      ^

Error: spawn C://ffmpeg/bin ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'spawn C://ffmpeg/bin',
  path: 'C://ffmpeg/bin',
  spawnargs: [
    '-use_wallclock_as_timestamps',
    '1',
    '-fflags',
    '+igndts',
    '-analyzeduration',
    '1000000',
    '-probesize',
    '1000000',
    '-rtsp_transport',
    'tcp',
    '-stimeout',
    '30000000',
    '-i',
    'rtsp://admin:[email protected]:8554/Streaming/Channels/101',
    '-c:v',
    'copy',
    '-c:a',
    'copy',
    '-f',
    'segment',
    '-movflags',
    '+faststart',
    '-segment_atclocktime',
    '1',
    '-reset_timestamps',
    '1',
    '-strftime',
    '1',
    '-segment_list',
    'pipe:4',
    '-segment_time',
    900,
    'F:\\cctv\\NVRJS_CAMERA_RECORDINGS\\66e39d21-72c4-405c-a838-05a8e8fe0742\\%Y-%m-%dT%H-%M-%S.mp4',
    '-an',
    '-vcodec',
    'copy',
    '-f',
    'mp4',
    '-movflags',
    '+frag_keyframe+empty_moov+default_base_moof',
    '-reset_timestamps',
    '1',
    '-metadata',
    'title="NVR JS Stream"',
    'pipe:3'
  ]
}

I get this error when I run it for the first time and this is my config

module.exports = {
	/* System Settings */
	system: {
		/* Username */
		username: "admin",
		/* bcrypt password (default: admin) */
		password: '$2a$10$CnOx/6vFY2ehRDf68yqd..aLlv0UM.zeBLKnRjuU8YykCsC2Ap3iG',
		/* bcrypt API Key (default: x7Te9m38JHQq6ddv) */
		apiKey: '$2a$10$N53ci.EIQ7JCu6u1HlOjoO//W0Bmp3GrRruyK1Jysr01CQ1rDrVQK',
		/* Any random string */
		cookieKey: 'f3gi6FLhIPVV31d1TBQUPEAngrI3wAoP',
		interfacePort: 7878,
		/* location used for 24/7 recording and database generation */
		/* This should be the root of a mount point i.e a dedicated HDD for 24/7 recordings */
		storageVolume: 'F://cctv',
		/* Continuous recording settings */
		ffmpegLocation: 'C://ffmpeg/bin',
		continuousSegTimeMinutes: 15,
		continuousDays: 7,
		continuousPurgeIntervalHours: 24,
		/* event throttle per sensorId */
		eventSensorIdCoolOffSeconds: 60
	},
	/* Cameras */
	cameras: {
		'66e39d21-72c4-405c-a838-05a8e8fe0742': {
			name: 'Garage',
			/* Input Source Config */
			/* The keys and values represent the ffmpeg options */
			inputConfig: {
				use_wallclock_as_timestamps: '1',
				fflags: '+igndts',
				analyzeduration: '1000000',
				probesize: '1000000',
				rtsp_transport: 'tcp',
				stimeout: '30000000'
			},
			/* Input Address */
			input: 'rtsp://admin:[email protected]:8554/Streaming/Channels/101',
			/* Recording 24/7 */
			/* Disabling continuous recording, will disable the ability to create events */
			continuous: true,
			/* Live streaming config */
			/* These settings should be good enough for a low delay live stream, providing your camera produces h264 frames */
			/* streaming is achieved with websockets and MP4 fragments */
			liveConfig: {
				codecString: 'video/mp4; codecs="avc1.64001f"',
				streamConfig: {
					an: '',
					vcodec: 'copy',
					f: 'mp4',
					movflags: '+frag_keyframe+empty_moov+default_base_moof',
					reset_timestamps: '1'
				}
			}
		}
	}
};

Is this nvr-js not support for windows?

Event emitter memory leak when a camera fails leads to no data being saved to disk

We have been seeing an issue on the v3.0.0 branch where, if one camera fails (i.e. due to actual hardware failure), NVR-JS very quickly stops writing any new metadata for the other still-functioning cameras, and after a few hours usually stops writing new video files for the still functioning cameras as well. The live streams still work, just that the actual persistent storage is no longer being written. Restarting NVRJS gets video files to work again for a short period but it always stops within a few hours.

When this happens, we get errors like this:

(node) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [Server]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)
(node) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 listening listeners added to [Server]. Use emitter.setMaxListeners() to increase limit
(node) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 upgrade listeners added to [Server]. Use emitter.setMaxListeners() to increase limit

and

Error: ENOENT: no such file or directory, open '<path>/camera2/<timestamp>.mp4'
    at Object.openSync (fs.js:498:3)
    at Object.readFileSync (fs.js:394:35)
    at CreateMeta (<path>/nvr-js/NVRJS.js:447:24)
    at Socket.<anonymous> (<path>/nvr-js/NVRJS.js:627:4)
    at Socket.emit (events.js:376:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at Socket.Readable.push (internal/streams/readable.js:223:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:188:23) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: <path>/NVRJS_SYSTEM/camera2/<timestamp>.mp4'
}

Tracing the emitter leak led to the const Socket = io(HTTP, IOptions); line in respawn at around line 605 in NVRJS.js.

I attempted to close the socket in the .on('close' handler a few lines later (to match the other cleanup), but that led the the entire web server being stopped, which obviously isn't ideal.

After a little digging, I came up with a work-around that seems to fix our issue (patch attached). This might not be the best fix, and I am not familiar enough with the codebase to be sure if this has any other unintended side effects. But we've been running it for about 18 hours on half a dozen systems with camera failures and they are properly writing metadata and video files now, and we're not seeing any issues on healthy systems either. I realize that's not a particularly long time to test for stability, but I figured it was worth writing up the issue quickly just in case there was a better fix, and I can report back on longer-term stability later.

Obviously the best fix is to repair or replace the broken cameras, but that isn't always something that can be done immediately, so continuing to write out data from the still working cameras while in that state is important.

FFMPEG missing?

Hi!
Like your project here - I think it suits me perfect. However, I am getting following error when trying to start:

0|NVRJS  |  - Checking volumes and ffmpeg.
0|NVRJS  | ffmpeg not found in specifed location: ffmpeg

I am running on a Ubuntu Server 20.04 with ffmpeg installed (apt install ffmpeg). Anything else I need to do?

How to add other cameras

Very simple nrv script, good. Don’t know how to add a new camera?
I tried to modify nvrjs.config, but it couldn't start.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.