mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-02 17:25: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.end_time,
|
||||
Recordings.segment_size,
|
||||
Recordings.duration,
|
||||
Recordings.motion,
|
||||
Recordings.objects,
|
||||
)
|
||||
|
||||
@ -287,7 +287,7 @@ class RecordingMaintainer(threading.Thread):
|
||||
try:
|
||||
segment_size = float(os.path.getsize(file_path)) / 1000000
|
||||
except OSError:
|
||||
segment_size = -1
|
||||
segment_size = 0
|
||||
|
||||
rand_id = "".join(
|
||||
random.choices(string.ascii_lowercase + string.digits, k=6)
|
||||
|
||||
@ -23,10 +23,14 @@ class StorageMaintainer(threading.Thread):
|
||||
|
||||
def calculate_camera_segment_sizes(self):
|
||||
"""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():
|
||||
if not self.config.cameras[camera].record.enabled:
|
||||
continue
|
||||
|
||||
# get average of non-zero segment sizes to ignore segment with no value
|
||||
avg_segment_size = round(
|
||||
Recordings.select(fn.AVG(Recordings.segment_size))
|
||||
.where(Recordings.camera == camera)
|
||||
@ -34,14 +38,25 @@ class StorageMaintainer(threading.Thread):
|
||||
.scalar(),
|
||||
2,
|
||||
)
|
||||
|
||||
# get average of an hour using the average segment size
|
||||
segment_duration = int(
|
||||
Recordings.select(Recordings.duration)
|
||||
.where(Recordings.camera == camera)
|
||||
.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] = {
|
||||
"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):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user