forked from Github/frigate
Cache camera stream info to speed up future config generations (#11614)
* Cache camera stream info to speed up future config generations * Formatting * fix
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"""configuration utils."""
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
@@ -8,6 +9,7 @@ from typing import Optional, Union
|
||||
from ruamel.yaml import YAML
|
||||
|
||||
from frigate.const import CONFIG_DIR, EXPORT_DIR
|
||||
from frigate.util.services import get_video_properties
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -194,3 +196,16 @@ def get_relative_coordinates(
|
||||
return mask
|
||||
|
||||
return mask
|
||||
|
||||
|
||||
class StreamInfoRetriever:
|
||||
def __init__(self) -> None:
|
||||
self.stream_cache: dict[str, tuple[int, int]] = {}
|
||||
|
||||
def get_stream_info(self, path: str) -> str:
|
||||
if path in self.stream_cache:
|
||||
return self.stream_cache[path]
|
||||
|
||||
info = asyncio.run(get_video_properties(path))
|
||||
self.stream_cache[path] = info
|
||||
return info
|
||||
|
||||
Reference in New Issue
Block a user