mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-11-28 05:04:15 -05:00
mass markdown reformatting
Add tables of contents (using the VS Code Markdown All-In-One extension) and reformat lists to consistently use 4-space indents. No content changes.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Building Moonfire NVR
|
||||
# Building Moonfire NVR <!-- omit in toc -->
|
||||
|
||||
This document has notes for software developers on building Moonfire NVR from
|
||||
source code for development. If you just want to install precompiled
|
||||
@@ -10,13 +10,12 @@ tracker](https://github.com/scottlamb/moonfire-nvr/issues) or
|
||||
[mailing list](https://groups.google.com/d/forum/moonfire-nvr-users) when
|
||||
stuck. Please also send pull requests to improve this doc.
|
||||
|
||||
* [Building Moonfire NVR](#building-moonfire-nvr)
|
||||
* [Downloading](#downloading)
|
||||
* [Docker builds](#docker-builds)
|
||||
* [Release procedure](#release-procedure)
|
||||
* [Non-Docker setup](#non-docker-setup)
|
||||
* [Running interactively straight from the working copy](#running-interactively-straight-from-the-working-copy)
|
||||
* [Running as a `systemd` service](#running-as-a-systemd-service)
|
||||
* [Downloading](#downloading)
|
||||
* [Docker builds](#docker-builds)
|
||||
* [Release procedure](#release-procedure)
|
||||
* [Non-Docker setup](#non-docker-setup)
|
||||
* [Running interactively straight from the working copy](#running-interactively-straight-from-the-working-copy)
|
||||
* [Running as a `systemd` service](#running-as-a-systemd-service)
|
||||
|
||||
## Downloading
|
||||
|
||||
@@ -151,19 +150,19 @@ Linux VM and filesystem overlay.
|
||||
|
||||
To build the server, you will need the following C libraries installed:
|
||||
|
||||
* [ffmpeg](http://ffmpeg.org/) version 2.x or 3.x, including `libavutil`,
|
||||
`libavcodec` (to inspect H.264 frames), and `libavformat` (to connect to RTSP
|
||||
servers and write `.mp4` files).
|
||||
* [ffmpeg](http://ffmpeg.org/) version 2.x or 3.x, including `libavutil`,
|
||||
`libavcodec` (to inspect H.264 frames), and `libavformat` (to connect to
|
||||
RTSP servers and write `.mp4` files).
|
||||
|
||||
Note ffmpeg library versions older than 55.1.101, along with all versions of
|
||||
the competing project [libav](http://libav.org), don't support socket
|
||||
timeouts for RTSP. For reliable reconnections on error, it's strongly
|
||||
recommended to use ffmpeg library versions >= 55.1.101.
|
||||
Note ffmpeg library versions older than 55.1.101, along with all versions of
|
||||
the competing project [libav](http://libav.org), don't support socket
|
||||
timeouts for RTSP. For reliable reconnections on error, it's strongly
|
||||
recommended to use ffmpeg library versions >= 55.1.101.
|
||||
|
||||
* [SQLite3](https://www.sqlite.org/).
|
||||
* [SQLite3](https://www.sqlite.org/).
|
||||
|
||||
* [`ncursesw`](https://www.gnu.org/software/ncurses/), the UTF-8 version of
|
||||
the `ncurses` library.
|
||||
* [`ncursesw`](https://www.gnu.org/software/ncurses/), the UTF-8 version of
|
||||
the `ncurses` library.
|
||||
|
||||
To build the UI, you'll need [node and npm](https://nodejs.org/en/download/).
|
||||
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
# Working on UI development
|
||||
# Working on UI development <!-- omit in toc -->
|
||||
|
||||
* [Getting started](#getting-started)
|
||||
* [Overriding defaults](#overriding-defaults)
|
||||
* [A note on `https`](#a-note-on-https)
|
||||
|
||||
The UI is presented from a single HTML page (index.html) and any number
|
||||
of Javascript files, css files, images, etc. These are "packed" together
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
# Downloading, installing, and configuring Moonfire NVR with Docker
|
||||
# Installing Moonfire NVR <!-- omit in toc -->
|
||||
|
||||
* [Downloading, installing, and configuring Moonfire NVR with Docker](#downloading-installing-and-configuring-moonfire-nvr-with-docker)
|
||||
* [Dedicated hard drive setup](#dedicated-hard-drive-setup)
|
||||
* [Completing configuration through the UI](#completing-configuration-through-the-ui)
|
||||
* [Starting it up](#starting-it-up)
|
||||
|
||||
## Downloading, installing, and configuring Moonfire NVR with Docker
|
||||
|
||||
This document describes how to download, install, and configure Moonfire NVR
|
||||
via the prebuilt Docker images available for x86-64, arm64, and arm. If you
|
||||
@@ -102,7 +109,7 @@ $ nvr init
|
||||
This will create a directory `/var/lib/moonfire-nvr/db` with a SQLite3 database
|
||||
within it.
|
||||
|
||||
## Dedicated hard drive setup
|
||||
### Dedicated hard drive setup
|
||||
|
||||
If a dedicated hard drive is available, set up the mount point:
|
||||
|
||||
@@ -139,7 +146,7 @@ mount lines. It will look similar to this:
|
||||
--mount=type=bind,source=/media/nvr/sample,destination=/media/nvr/sample
|
||||
```
|
||||
|
||||
## Completing configuration through the UI
|
||||
### Completing configuration through the UI
|
||||
|
||||
Once your system is set up, it's time to initialize an empty database
|
||||
and add the cameras and sample directories. You can do this
|
||||
@@ -159,28 +166,28 @@ In the user interface,
|
||||
|
||||
2. add cameras under "Cameras and streams".
|
||||
|
||||
* See the [wiki](https://github.com/scottlamb/moonfire-nvr/wiki) for notes
|
||||
about specific camera models.
|
||||
* See the [wiki](https://github.com/scottlamb/moonfire-nvr/wiki) for notes
|
||||
about specific camera models.
|
||||
|
||||
* There's a "Test" button to verify your settings directly from the add/edit
|
||||
camera dialog.
|
||||
* There's a "Test" button to verify your settings directly from the add/edit
|
||||
camera dialog.
|
||||
|
||||
* Be sure to assign each stream you want to capture to a sample file
|
||||
directory and check the "record" box.
|
||||
* Be sure to assign each stream you want to capture to a sample file
|
||||
directory and check the "record" box.
|
||||
|
||||
* `flush_if_sec` should typically be 120 seconds. This causes the database to
|
||||
be flushed when the first instant of one of this stream's completed
|
||||
recordings is 2 minutes old. A "recording" is a segment of a video
|
||||
stream that is 60–120 seconds when first establishing the stream, about
|
||||
60 seconds midstream, and shorter when an error or server shutdown
|
||||
terminates the stream. Thus, a value just below 60 will cause the
|
||||
database to be flushed once per minute per stream in the steady state. A
|
||||
value around 180 will cause the database to be once every 3 minutes per
|
||||
stream, or less frequently if other streams cause flushes first. Lower
|
||||
values cause less video to be lost on power loss. Higher values reduce
|
||||
wear on the SSD holding the SQLite database, particularly when you have
|
||||
many cameras and when you record both the "main" and "sub" streams of
|
||||
each camera.
|
||||
* `flush_if_sec` should typically be 120 seconds. This causes the database to
|
||||
be flushed when the first instant of one of this stream's completed
|
||||
recordings is 2 minutes old. A "recording" is a segment of a video
|
||||
stream that is 60–120 seconds when first establishing the stream,
|
||||
about 60 seconds midstream, and shorter when an error or server
|
||||
shutdown terminates the stream. Thus, a value just below 60 will
|
||||
cause the database to be flushed once per minute per stream in the
|
||||
steady state. A value around 180 will cause the database to be once
|
||||
every 3 minutes per stream, or less frequently if other streams cause
|
||||
flushes first. Lower values cause less video to be lost on power
|
||||
loss. Higher values reduce wear on the SSD holding the SQLite
|
||||
database, particularly when you have many cameras and when you record
|
||||
both the "main" and "sub" streams of each camera.
|
||||
|
||||
3. Assign disk space to your cameras back in "Directories and retention".
|
||||
Leave a little slack between the total limit and the filesystem capacity,
|
||||
@@ -202,7 +209,7 @@ In the user interface,
|
||||
4. Add a user for yourself (and optionally others) under "Users". You'll need
|
||||
this to access the web UI once you enable authentication.
|
||||
|
||||
## Starting it up
|
||||
### Starting it up
|
||||
|
||||
Note that at this stage, Moonfire NVR's web interface is **insecure**: it
|
||||
doesn't use `https` and doesn't require you to authenticate
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
# Moonfire NVR Schema Guide
|
||||
# Moonfire NVR Schema Guide <!-- omit in toc -->
|
||||
|
||||
* [Upgrading](#upgrading)
|
||||
* [Procedure](#procedure)
|
||||
* [Unversioned to version 0](#unversioned-to-version-0)
|
||||
* [Version 0 to version 1](#version-0-to-version-1)
|
||||
* [Version 1 to version 2 to version 3](#version-1-to-version-2-to-version-3)
|
||||
* [Version 3 to version 4 to version 5](#version-3-to-version-4-to-version-5)
|
||||
* [Version 6](#version-6)
|
||||
|
||||
This document has notes about the Moonfire NVR storage schema. As described in
|
||||
[README.md](../README.md), this consists of two kinds of state:
|
||||
@@ -26,42 +34,46 @@ read-only mode prior to deleting the old database.
|
||||
First ensure there is sufficient space available for four copies of the
|
||||
SQLite database:
|
||||
|
||||
* copy 1: the copy to upgrade
|
||||
* copy 2: a backup you manually create so that you can restore if you
|
||||
discover a problem while running the new software against the upgraded
|
||||
database in read-only mode. If disk space is tight, you can save this
|
||||
to a different filesystem than the primary copy.
|
||||
* copies 3 and 4: internal copies made and destroyed by Moonfire NVR and
|
||||
SQLite during the upgrade:
|
||||
* copy 1: the copy to upgrade
|
||||
* copy 2: a backup you manually create so that you can restore if you
|
||||
discover a problem while running the new software against the upgraded
|
||||
database in read-only mode. If disk space is tight, you can save this
|
||||
to a different filesystem than the primary copy.
|
||||
* copies 3 and 4: internal copies made and destroyed by Moonfire NVR and
|
||||
SQLite during the upgrade:
|
||||
|
||||
* during earlier steps, possibly duplicate copies of tables, which
|
||||
may occupy space both in the main database and the journal
|
||||
* during the final vacuum step, a complete database copy
|
||||
* during earlier steps, possibly duplicate copies of tables, which
|
||||
may occupy space both in the main database and the journal
|
||||
* during the final vacuum step, a complete database copy
|
||||
|
||||
If disk space is tight, and you are _very careful_, you can skip these
|
||||
copies with the `--preset-journal=off --no-vacuum` arguments to
|
||||
the updater. If you aren't confident in your ability to do this, *don't
|
||||
do it*. If you are confident, take additional safety precautions anyway:
|
||||
If disk space is tight, and you are _very careful_, you can skip these
|
||||
copies with the `--preset-journal=off --no-vacuum` arguments to
|
||||
the updater. If you aren't confident in your ability to do this, *don't
|
||||
do it*. If you are confident, take additional safety precautions anyway:
|
||||
|
||||
* double-check you have the full backup described above. Without the
|
||||
journal any problems during the upgrade will corrupt your database
|
||||
and you will need to restore.
|
||||
* ensure you re-enable journalling via `pragma journal_mode = wal;`
|
||||
before using the upgraded database, or any problems after the
|
||||
upgrade will corrupt your database. The upgrade procedure should do
|
||||
this automatically, but you will want to verify by hand that you are
|
||||
no longer in the dangerous mode.
|
||||
* double-check you have the full backup described above. Without the
|
||||
journal any problems during the upgrade will corrupt your database
|
||||
and you will need to restore.
|
||||
* ensure you re-enable journalling via `pragma journal_mode = wal;`
|
||||
before using the upgraded database, or any problems after the
|
||||
upgrade will corrupt your database. The upgrade procedure should do
|
||||
this automatically, but you will want to verify by hand that you are
|
||||
no longer in the dangerous mode.
|
||||
|
||||
Next ensure Moonfire NVR is not running and does not automatically restart if
|
||||
the system is rebooted during the upgrade. If you followed the Docker
|
||||
instructions, you can do this as follows:
|
||||
|
||||
$ nvr stop
|
||||
```
|
||||
$ nvr stop
|
||||
```
|
||||
|
||||
Then back up your SQLite database. If you are using the default path, you can
|
||||
do so as follows:
|
||||
|
||||
$ sudo -u moonfire-nvr cp /var/lib/moonfire-nvr/db/db{,.pre-upgrade}
|
||||
```
|
||||
$ sudo -u moonfire-nvr cp /var/lib/moonfire-nvr/db/db{,.pre-upgrade}
|
||||
```
|
||||
|
||||
By default, the upgrade command will reset the SQLite `journal_mode` to
|
||||
`delete` prior to the upgrade. This works around a problem with
|
||||
@@ -112,17 +124,17 @@ $ nvr run
|
||||
Hopefully your system is functioning correctly. If not, there are two options
|
||||
for restore; neither are easy:
|
||||
|
||||
* go back to your old database. There will be two classes of problems:
|
||||
* If the new system deleted any recordings, the old system will
|
||||
incorrectly believe they are still present. You could wait until all
|
||||
existing files are rotated away, or you could try to delete them
|
||||
manually from the database.
|
||||
* if the new system created any recordings, the old system will not
|
||||
know about them and will not delete them. Your disk may become full.
|
||||
You should find some way to discover these files and manually delete
|
||||
them.
|
||||
* undo the changes by hand. There's no documentation on this; you'll need
|
||||
to read the code and come up with a reverse transformation.
|
||||
* go back to your old database. There will be two classes of problems:
|
||||
* If the new system deleted any recordings, the old system will
|
||||
incorrectly believe they are still present. You could wait until all
|
||||
existing files are rotated away, or you could try to delete them
|
||||
manually from the database.
|
||||
* If the new system created any recordings, the old system will not
|
||||
know about them and will not delete them. Your disk may become full.
|
||||
You should find some way to discover these files and manually delete
|
||||
them.
|
||||
* undo the changes by hand. There's no documentation on this; you'll need
|
||||
to read the code and come up with a reverse transformation.
|
||||
|
||||
The `nvr check` command will show you what problems exist on your system.
|
||||
|
||||
@@ -136,9 +148,9 @@ will also accept a version 0 database.
|
||||
|
||||
Version 0 makes two changes:
|
||||
|
||||
* it adds schema versioning, as described above.
|
||||
* it adds a column (`video_sync_samples`) to a database index to speed up
|
||||
certain operations.
|
||||
* it adds schema versioning, as described above.
|
||||
* it adds a column (`video_sync_samples`) to a database index to speed up
|
||||
certain operations.
|
||||
|
||||
There's a special procedure for this upgrade. The good news is that a backup
|
||||
is unnecessary; there's no risk with this procedure.
|
||||
@@ -150,8 +162,10 @@ Then use `sqlite3` to manually edit the database. The default
|
||||
path is `/var/lib/moonfire-nvr/db/db`; if you've specified a different
|
||||
`--db_dir`, use that directory with a suffix of `/db`.
|
||||
|
||||
$ sudo -u moonfire-nvr sqlite3 /var/lib/moonfire-nvr/db/db
|
||||
sqlite3>
|
||||
```
|
||||
$ sudo -u moonfire-nvr sqlite3 /var/lib/moonfire-nvr/db/db
|
||||
sqlite3>
|
||||
```
|
||||
|
||||
At the prompt, run the following commands:
|
||||
|
||||
|
||||
@@ -1,4 +1,16 @@
|
||||
# Securing Moonfire NVR and exposing it to the Internet
|
||||
# Securing Moonfire NVR and exposing it to the Internet <!-- omit in toc -->
|
||||
|
||||
* [The problem](#the-problem)
|
||||
* [VPN or port forwarding?](#vpn-or-port-forwarding)
|
||||
* [Overview](#overview)
|
||||
* [1. Install a webserver](#1-install-a-webserver)
|
||||
* [2. Configure a static internal IP](#2-configure-a-static-internal-ip)
|
||||
* [3. Set up port forwarding](#3-set-up-port-forwarding)
|
||||
* [4. Configure a public DNS name](#4-configure-a-public-dns-name)
|
||||
* [5. Install a TLS certificate](#5-install-a-tls-certificate)
|
||||
* [6. Reconfigure Moonfire NVR](#6-reconfigure-moonfire-nvr)
|
||||
* [7. Configure the webserver](#7-configure-the-webserver)
|
||||
* [Verify it works](#verify-it-works)
|
||||
|
||||
## The problem
|
||||
|
||||
|
||||
@@ -1,27 +1,26 @@
|
||||
# Troubleshooting
|
||||
# Troubleshooting <!-- omit in toc -->
|
||||
|
||||
Here are some tips for diagnosing various problems with Moonfire NVR. Feel free
|
||||
to open an [issue](https://github.com/scottlamb/moonfire-nvr/issues) if you
|
||||
need more help.
|
||||
|
||||
* [Troubleshooting](#troubleshooting)
|
||||
* [Viewing Moonfire NVR's logs](#viewing-moonfire-nvrs-logs)
|
||||
* [Flushes](#flushes)
|
||||
* [Panic errors](#panic-errors)
|
||||
* [Slow operations](#slow-operations)
|
||||
* [Camera stream errors](#camera-stream-errors)
|
||||
* [Problems](#problems)
|
||||
* [Server errors](#server-errors)
|
||||
* [`Error: pts not monotonically increasing; got 26615520 then 26539470`](#error-pts-not-monotonically-increasing-got-26615520-then-26539470)
|
||||
* [Out of disk space](#out-of-disk-space)
|
||||
* [Database or filesystem corruption errors](#database-or-filesystem-corruption-errors)
|
||||
* [Configuration interface problems](#configuration-interface-problems)
|
||||
* [`moonfire-nvr config` displays garbage](#moonfire-nvr-config-displays-garbage)
|
||||
* [Browser user interface problems](#browser-user-interface-problems)
|
||||
* [Live stream always fails with `ws close: 1006`](#live-stream-always-fails-with-ws-close-1006)
|
||||
* [Errors in kernel logs](#errors-in-kernel-logs)
|
||||
* [UAS errors](#uas-errors)
|
||||
* [Filesystem errors](#filesystem-errors)
|
||||
* [Viewing Moonfire NVR's logs](#viewing-moonfire-nvrs-logs)
|
||||
* [Flushes](#flushes)
|
||||
* [Panic errors](#panic-errors)
|
||||
* [Slow operations](#slow-operations)
|
||||
* [Camera stream errors](#camera-stream-errors)
|
||||
* [Problems](#problems)
|
||||
* [Server errors](#server-errors)
|
||||
* [`Error: pts not monotonically increasing; got 26615520 then 26539470`](#error-pts-not-monotonically-increasing-got-26615520-then-26539470)
|
||||
* [Out of disk space](#out-of-disk-space)
|
||||
* [Database or filesystem corruption errors](#database-or-filesystem-corruption-errors)
|
||||
* [Configuration interface problems](#configuration-interface-problems)
|
||||
* [`moonfire-nvr config` displays garbage](#moonfire-nvr-config-displays-garbage)
|
||||
* [Browser user interface problems](#browser-user-interface-problems)
|
||||
* [Live stream always fails with `ws close: 1006`](#live-stream-always-fails-with-ws-close-1006)
|
||||
* [Errors in kernel logs](#errors-in-kernel-logs)
|
||||
* [UAS errors](#uas-errors)
|
||||
* [Filesystem errors](#filesystem-errors)
|
||||
|
||||
## Viewing Moonfire NVR's logs
|
||||
|
||||
|
||||
Reference in New Issue
Block a user