210 Commits
Author SHA1 Message Date
Scott Lamb 5944f2bba7 v0.7.31 with retina v0.4.19
Fixes #352
2026-03-13 11:55:44 -07:00
Scott Lamb ffc8bd6b98 v0.7.30: fix severe timestamp drift
* reset local start time at each recording boundary
* include the final frame's time when converting from wall to media time

Together at 30 fps these caused about 15 seconds of drift over 4 hours.
2026-02-19 15:47:00 -08:00
Scott Lamb 10e48265cf v0.7.29: fix garbage collection
As noted in the changelog, this problem caused restarts to take a long
time, and the SQLite database to (slowly) grow without bound.

The problem was simple: the directory worker incorrectly aborted
`collect_garbage` if nothing was watching the result. For some
operations (e.g. reading from sample files) this is the correct
behavior, but in this case it contradicts the `Pool::collect_garbage`
contract.
2026-02-19 10:11:17 -08:00
Scott Lamb 3c8fc6b63a v0.7.28 2026-02-19 09:35:14 -08:00
Scott Lamb 30e8d8a5c2 prep v0.7.27 2026-02-18 12:19:34 -08:00
Scott Lamb a36457cd9f prep v0.7.26 2026-02-17 11:55:55 -08:00
Scott Lamb fd7ae68657 overhaul streams!
This puts a lot of state into a new `LockedStream` that was formerly
guarded more coarsely by the recording lock or more granularly by
`RecordingToInsert` locks. And it restructures `LockedDatabase::flush`
to avoid holding this lock while performing SQLite operations.

Streamers write only into a recent frames buffer in RAM, which the
directory pool workers asynchronously write to disk approximately once
per GOP, where formerly there was a write call per frame.

Before, streamers could fall behind due to slow sample file directory
disk I/O calls or if writing got stuck in a retry loop, for example if
out of disk space. If Moonfire falls too far behind in receiving,
cameras tend to disconnect or (sadly) mis-frame messages because they do
not handle this case well. This removes a confusing potential cause of
such errors.

In the new model, streamers never wait for disk I/O. Frames are buffered
up to a limit. Recordings are aborted if the I/O pool falls too far
behind. There's no retry loop.

This roughly halves CPU usage as thread hand-offs and syscalls are less
common. It also enables several desirable future changes:

* audio recording (which radically increases the number of frames and
  thus would otherwise significantly increase CPU usage).
* "monitor mode" (allowing live view without recording to disk),
* further CPU reductions for live view (by skipping all SQLite ops and
  disk I/O).

In the new model, streamers also rarely wait for SQLite database
operations either—now only on video parameter changes. That might go
away in an upcoming change too.

The "syncer" (which synced files/dirs and kept track of what has to be
flushed into the SQLite database when) has mostly gone away too. The
directory pool workers handle the syncing now, and then they notify
a new "flusher" for the latter portion.

I'd like to go further still and have the database as a whole be owned
by a dedicated thread, the only one that uses the SQLite connection.
This prevents the tokio threads from blocking on SQLite operations.
I tried out doing so before making the streamers less dependent on the
db, but the extra thread handoffs were awful for performance.
2026-02-17 11:55:55 -08:00
Scott Lamb 0dc285b159 move all sample file dir I/O to pool
Now, all IO happens on each directory's two-thread pool with threads
named `dir-<PATH>`. Formerly, IO could happen on the per-stream writer
threads, per-directory reader threads, and occasional on even the tokio
worker threads.

The recording path uses more CPU than before due to extra thread
hand-offs. That will change in the next commit, which will radically
change the approach to writing.
2026-02-17 11:17:28 -08:00
Scott Lamb 424d61f2b5 small tweaks to Docker experience
* add `/var/tmp` to the image so it doesn't have to be mounted
* remove obsolete `version: 3` from compose snippet
* mention `/usr/share/zoneinfo` in error msg and troubleshooting guide
2026-02-16 08:25:19 -08:00
Scott Lamb 10bc1c6fc1 fix release workflow error 2026-02-14 13:24:00 -08:00
Scott Lamb 26e8448e46 prep v0.7.24 2026-02-14 13:09:59 -08:00
Scott Lamb 1cc422bf0d update node versions
...to:

* 20 (maintenance LTS)
* 22 (maintenance LTS)
* 24 (active LTS release)
* 25 (current non-LTS release)

And address some "realm mismatch" problems in tests:

* It was using `AbortSignal` from `jsdom`'s realm, `fetch` from the Node
  native `fetch`. Node 24 upgraded to undici v7 with stricter Fetch spec
  compliance, which complained about this.
* It was doing `instanceof` checks from `myfetch` which failed for
  similar reasons.

by updating vitest (see <https://github.com/vitest-dev/vitest/issues/8374>) and simplifying the `api.ts` checking.

Along the way, give error messages like `POST /api/login failed; see browser console` rather than the unhelpful `TypeError: Failed to fetch`.
2026-02-14 12:29:25 -08:00
Scott Lamb ff383147e4 prep v0.7.23
I'd actually intended the things here to be in v0.7.22, but I tagged
the wrong revision. Embarrassing, but version numbers are free.
2025-10-03 15:42:34 -07:00
Scott Lamb 5cc93349fc prep v0.7.22
...with dependency updates, notably including Retina.
2025-10-03 14:48:12 -07:00
Scott Lamb 239256e2ba prep v0.7.21 2025-04-04 11:49:47 -07:00
Scott Lamb dd30d5bcf8 update Rust dependencies
This pulls in a duplicate version of `thiserror` for now, but oh well.
2025-01-25 10:40:21 -08:00
Scott Lamb cbb2c30b56 use jiff crate 2025-01-22 14:16:31 -08:00
Scott Lamb 9256561362 fix a couple clippy errors
...with Rust 1.82.
2024-12-11 15:03:31 -08:00
Scott Lamb dad664c244 upgrade to retina 0.4.9
This is a step toward H.265 recording support (#33) by using Retina
for the `VisualSampleEncoding` instead of the prior H.264-specific
logic. The only further change to Moonfire itself needed for H.265 is to
add `| "h265"` to the check for the right video stream.

This also adds support for recording MJPEG, although browser playback
almost certainly won't work.
2024-08-19 08:13:32 -07:00
Scott Lamb 9acb095a5d prep v0.7.14 2024-04-16 21:07:34 -07:00
michioxd 9ede361b25 switch to pnpm 2024-04-13 21:53:59 -07:00
michioxd 3f4cee7ead Switch to pnpm 2024-04-13 21:53:59 -07:00
Scott Lamb 9592fe24e8 small tweaks to docker instructions
* strongly encourage the single-binary approach and say why.
* fix a broken link in troubleshooting guide (and regenerate toc).
* add a couple more comments to the docker compose snippet
2024-01-31 20:15:11 -08:00
Scott Lamb 6f472256ab mention ui development proxy too 2024-01-31 17:12:44 -08:00
Scott Lamb d1c033b46d fix docs to mention UI bundling
see #305
2024-01-31 17:07:11 -08:00
Scott Lamb 2da459dae2 address SQLITE_IOERR_GETTEMPPATH from docker 2023-12-29 16:23:38 -08:00
Scott Lamb cca430b701 prep 0.7.11 2023-12-29 15:37:58 -08:00
Scott Lamb 24880a5c2d switch from create-react-app to vite
create-react-app is apparently deprecated, so the cool kids use vite,
I guess.
2023-12-18 17:08:09 -08:00
Scott Lamb f493ad94eb typo fix 2023-12-05 09:11:41 -08:00
Scott Lamb 672647730d typo fix 2023-12-05 09:08:30 -08:00
Scott Lamb 1013c35791 adjust table layout
The wide command reference caused the whole table around the `<details>`
to have a scroll bar, which was confusing.
2023-12-05 09:03:56 -08:00
Scott Lamb c5f5bd39ee improve docs a bit
* use a more recent screenshot for selecting tag on github UI, and
  put in a `<details>` because it's annoyingly large.
* put a border around `<details>` so it's easy to see where it
  starts/ends
* add troubleshooting info for docker setup, to help with e.g. #296.
2023-12-05 08:55:38 -08:00
Scott Lamb 882596c7f6 prep v0.7.10 2023-11-28 10:37:23 -08:00
Scott Lamb 8efea4526d build docker images again 2023-11-28 10:32:10 -08:00
Leandro Silva 5e00217784 Fix TimeoutStartSec invalid parsing in moonfire-nvr.service Systemd config
Systemd syntax expects comment in a single line, hence the parsing failure
https://www.freedesktop.org/software/systemd/man/latest/systemd.syntax.html

Before;
```
[leandro@nuc ~]$ sudo systemd-analyze verify /etc/systemd/system/moonfire-nvr.service
/etc/systemd/system/moonfire-nvr.service:16: Failed to parse TimeoutStartSec= parameter, ignoring: 300 # large installations take a while to scan the sample file dirs
[leandro@nuc ~]$
```

After;
```
[leandro@nuc ~]$ sudo systemd-analyze verify /etc/systemd/system/moonfire-nvr.service
[leandro@nuc ~]$
```
2023-10-23 20:18:50 -07:00
Scott Lamb 89ee2d0269 systemd Ready/Stopping notification 2023-10-20 11:51:55 -07:00
Scott Lamb ee98bf5236 no more Docker!
* use `termion` rather than `ncurses` to limit runtime deps
* cross-compile with `cross` instead of our own dockerfiles/scripts
* update instructions
* update release procedure and GitHub actions to match
* prep changelog for `v0.7.8`

Fixes #160
Closes #265
2023-10-18 21:55:47 -07:00
Scott Lamb a76483a912 stop using cargo pkg version
One fewer thing to manage at release time.
2023-10-17 09:44:30 -07:00
Scott Lamb ef62ebfc6c Merge remote-tracking branch 'origin/release-0.7.7' 2023-10-16 22:05:54 -07:00
Scott Lamb 9820bf8883 tweak ui dev server's websocket situation
* fix the automatic reload
* document that live view doesn't work with `PROXY_TARGET`;
  link to fresh issue
2023-09-30 16:02:52 -07:00
Scott Lamb cff832e646 prep v0.7.7 2023-08-03 14:03:48 -07:00
Leandro Silva ed7ab5dddf Add hyperink to the latest release in installation instructions 2023-07-08 17:18:59 -07:00
Scott Lamb 4ad627b997 prep 0.7.6 release 2023-07-08 10:22:04 -07:00
Scott Lamb ebcdd76084 switch from log to tracing
I think this is a big improvement in readability.

I removed the `lnav` config, which is a little sad, but I don't think it
supports this structured logging format well. Still seems worthwhile on
balance.
2023-07-04 16:51:22 -07:00
Skye db2e0f1d39 Bump minimum Rust version to 1.65 2023-07-04 16:37:36 -07:00
Scott Lamb 438de38202 rework WebSocket error return protocol
This gives much better information to the UI layer, getting rid of a
whole troubleshooting guide entry. See #119 #132 #218 #219

I also restructured the code in anticipation of a new WebSocket event
stream (#40).
2023-02-15 17:26:40 -08:00
Tim Small ad48cf2e10 Fix chown in build instructions.
The build instructions currently fail if the user doesn't have a group
matching their user name (not a universally adopted convention).  Update
the command to use the following functionality of the `chown` command:

"If a colon but no group name follows the user name, that user is made
the owner of the files and the group of the files is changed to that
user's login group."
2023-02-15 08:03:02 -08:00
Scott Lamb 9060dbfe14 adjust supported node versions 2023-01-11 19:38:47 -08:00
Scott Lamb 50fa5ce6fe update moonfire-nvr.toml desc in build.md 2023-01-11 19:35:37 -08:00
Scott Lamb 6ed23e90e8 improve docker cross-compilation
* support cross-compiling an x86-64 target on an arm64 host. This
  it turns out is a matter of *removing* an unnecessary dependency.
  (aarch64-linux-gnu-pkg-config exists but x86_64-linux-gnu-pkg-config
  doesn't. Turns out neither is necessary.) Added a comment explaining
  where ${gcc_target}-pkg-config comes from now.
* documentation tweaks
* improve debug output a bit
2023-01-11 19:35:37 -08:00