Add option for enabling sync recordings (#7169)

This commit is contained in:
Nicolas Mowen 2023-07-15 07:38:21 -06:00 committed by GitHub
parent d0873631cc
commit 8e584cf844
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 2 deletions

View File

@ -341,6 +341,8 @@ record:
# Optional: Number of minutes to wait between cleanup runs (default: shown below) # Optional: Number of minutes to wait between cleanup runs (default: shown below)
# This can be used to reduce the frequency of deleting recording segments from disk if you want to minimize i/o # This can be used to reduce the frequency of deleting recording segments from disk if you want to minimize i/o
expire_interval: 60 expire_interval: 60
# Optional: Sync recordings with disk on startup (default: shown below).
sync_on_startup: False
# Optional: Retention settings for recording # Optional: Retention settings for recording
retain: retain:
# Optional: Number of days to retain recordings regardless of events (default: shown below) # Optional: Number of days to retain recordings regardless of events (default: shown below)

View File

@ -84,3 +84,18 @@ record:
## How do I export recordings? ## How do I export recordings?
The export page in the Frigate WebUI allows for exporting real time clips with a designated start and stop time as well as exporting a timelapse for a designated start and stop time. These exports can take a while so it is important to leave the file until it is no longer in progress. The export page in the Frigate WebUI allows for exporting real time clips with a designated start and stop time as well as exporting a timelapse for a designated start and stop time. These exports can take a while so it is important to leave the file until it is no longer in progress.
## Syncing Recordings With Disk
In some cases the recordings files may be deleted but Frigate will not know this has happened. Sync on startup can be enabled which will tell Frigate to check the file system and delete any db entries for files which don't exist.
```yaml
record:
sync_on_startup: True
```
:::warning
The sync operation uses considerable CPU resources and in most cases is not needed, only enable when necessary.
:::

View File

@ -193,6 +193,9 @@ class RecordRetainConfig(FrigateBaseModel):
class RecordConfig(FrigateBaseModel): class RecordConfig(FrigateBaseModel):
enabled: bool = Field(default=False, title="Enable record on all cameras.") enabled: bool = Field(default=False, title="Enable record on all cameras.")
sync_on_startup: bool = Field(
default=False, title="Sync recordings with disk on startup."
)
expire_interval: int = Field( expire_interval: int = Field(
default=60, default=60,
title="Number of minutes to wait between cleanup runs.", title="Number of minutes to wait between cleanup runs.",

View File

@ -222,8 +222,9 @@ class RecordingCleanup(threading.Thread):
logger.debug("End sync recordings.") logger.debug("End sync recordings.")
def run(self) -> None: def run(self) -> None:
# on startup sync recordings with disk # on startup sync recordings with disk if enabled
self.sync_recordings() if self.config.record.sync_on_startup:
self.sync_recordings()
# Expire tmp clips every minute, recordings and clean directories every hour. # Expire tmp clips every minute, recordings and clean directories every hour.
for counter in itertools.cycle(range(self.config.record.expire_interval)): for counter in itertools.cycle(range(self.config.record.expire_interval)):