mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 01:35:22 +03:00
Keep track of total segment and hour averages
This commit is contained in:
parent
384595f5e6
commit
1284e3edaa
BIN
config/rockchip.rknn
Normal file
BIN
config/rockchip.rknn
Normal file
Binary file not shown.
@ -752,7 +752,6 @@ def recordings(camera_name):
|
|||||||
Recordings.start_time,
|
Recordings.start_time,
|
||||||
Recordings.end_time,
|
Recordings.end_time,
|
||||||
Recordings.segment_size,
|
Recordings.segment_size,
|
||||||
Recordings.duration,
|
|
||||||
Recordings.motion,
|
Recordings.motion,
|
||||||
Recordings.objects,
|
Recordings.objects,
|
||||||
)
|
)
|
||||||
|
|||||||
@ -287,7 +287,7 @@ class RecordingMaintainer(threading.Thread):
|
|||||||
try:
|
try:
|
||||||
segment_size = float(os.path.getsize(file_path)) / 1000000
|
segment_size = float(os.path.getsize(file_path)) / 1000000
|
||||||
except OSError:
|
except OSError:
|
||||||
segment_size = -1
|
segment_size = 0
|
||||||
|
|
||||||
rand_id = "".join(
|
rand_id = "".join(
|
||||||
random.choices(string.ascii_lowercase + string.digits, k=6)
|
random.choices(string.ascii_lowercase + string.digits, k=6)
|
||||||
|
|||||||
@ -23,10 +23,14 @@ class StorageMaintainer(threading.Thread):
|
|||||||
|
|
||||||
def calculate_camera_segment_sizes(self):
|
def calculate_camera_segment_sizes(self):
|
||||||
"""Calculate the size of each cameras recording segments."""
|
"""Calculate the size of each cameras recording segments."""
|
||||||
|
total_avg_segment = 0.0
|
||||||
|
total_avg_hour = 0.0
|
||||||
|
|
||||||
for camera in self.config.cameras.keys():
|
for camera in self.config.cameras.keys():
|
||||||
if not self.config.cameras[camera].record.enabled:
|
if not self.config.cameras[camera].record.enabled:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# get average of non-zero segment sizes to ignore segment with no value
|
||||||
avg_segment_size = round(
|
avg_segment_size = round(
|
||||||
Recordings.select(fn.AVG(Recordings.segment_size))
|
Recordings.select(fn.AVG(Recordings.segment_size))
|
||||||
.where(Recordings.camera == camera)
|
.where(Recordings.camera == camera)
|
||||||
@ -34,16 +38,27 @@ class StorageMaintainer(threading.Thread):
|
|||||||
.scalar(),
|
.scalar(),
|
||||||
2,
|
2,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# get average of an hour using the average segment size
|
||||||
segment_duration = int(
|
segment_duration = int(
|
||||||
Recordings.select(Recordings.duration)
|
Recordings.select(Recordings.duration)
|
||||||
.where(Recordings.camera == camera)
|
.where(Recordings.camera == camera)
|
||||||
.scalar()
|
.scalar()
|
||||||
)
|
)
|
||||||
|
avg_hour_size = round((3600 / segment_duration) * avg_segment_size, 2)
|
||||||
|
|
||||||
|
total_avg_segment += avg_segment_size
|
||||||
|
total_avg_hour += avg_hour_size
|
||||||
self.avg_segment_sizes[camera] = {
|
self.avg_segment_sizes[camera] = {
|
||||||
"segment": avg_segment_size,
|
"segment": avg_segment_size,
|
||||||
"hour": (3600 / segment_duration) * avg_segment_size,
|
"hour": avg_hour_size,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.avg_segment_sizes["total"] = {
|
||||||
|
"segment": total_avg_segment,
|
||||||
|
"hour": total_avg_hour,
|
||||||
|
}
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
# Check storage consumption every 5 minutes
|
# Check storage consumption every 5 minutes
|
||||||
while not self.stop_event.wait(20):
|
while not self.stop_event.wait(20):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user