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

Can nvr-js support Windows? #19

Open 94maldini opened 6 months ago

94maldini commented 6 months ago

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:admin@192.168.22.234: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:admin@192.168.22.234: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?

marcus-j-davies commented 6 months ago

It's never been tested on windows, but sadly I struggle for time these days to keep it maintained, if changes were requied.

With that said, your error is with the ffmpeg location

ffmpegLocation: 'C://ffmpeg/bin', should be ffmpegLocation: 'C://ffmpeg/bin/ffmpeg.exe', (or wherever the executable is)

94maldini commented 6 months ago

Thanks for the problem on ffmpeg but Now I get this error

 - 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!
 - Starting purge interval.
 - Purging data.
undefined:0

[Error: SQLITE_ERROR: no such table: Segments
Emitted 'error' event on Statement instance at:
] {
  errno: 1,
  code: 'SQLITE_ERROR'
}