mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-03 17:55:21 +03:00
Add vainfo endpoint
This commit is contained in:
parent
9f1d2b998a
commit
82e9b345bb
@ -31,7 +31,7 @@ from frigate.const import CLIPS_DIR
|
|||||||
from frigate.models import Event, Recordings
|
from frigate.models import Event, Recordings
|
||||||
from frigate.object_processing import TrackedObject
|
from frigate.object_processing import TrackedObject
|
||||||
from frigate.stats import stats_snapshot
|
from frigate.stats import stats_snapshot
|
||||||
from frigate.util import clean_camera_user_pass, ffprobe_stream
|
from frigate.util import clean_camera_user_pass, ffprobe_stream, vainfo
|
||||||
from frigate.version import VERSION
|
from frigate.version import VERSION
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -1035,3 +1035,19 @@ def ffprobe():
|
|||||||
)
|
)
|
||||||
|
|
||||||
return jsonify(output)
|
return jsonify(output)
|
||||||
|
|
||||||
|
|
||||||
|
@bp.route("/vainfo", methods=["GET"])
|
||||||
|
def vainfo():
|
||||||
|
vainfo_output = vainfo()
|
||||||
|
return jsonify(
|
||||||
|
{
|
||||||
|
"return_code": vainfo_output.returncode,
|
||||||
|
"stderr": json.loads(vainfo_output.stderr.decode("unicode_escape").strip())
|
||||||
|
if vainfo_output.stderr.decode()
|
||||||
|
else {},
|
||||||
|
"stdout": json.loads(vainfo_output.stdout.decode("unicode_escape").strip())
|
||||||
|
if vainfo_output.stdout.decode()
|
||||||
|
else {},
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|||||||
@ -766,21 +766,6 @@ def get_cpu_stats() -> dict[str, dict]:
|
|||||||
return usages
|
return usages
|
||||||
|
|
||||||
|
|
||||||
def ffprobe_stream(path: str) -> sp.CompletedProcess:
|
|
||||||
"""Run ffprobe on stream."""
|
|
||||||
ffprobe_cmd = [
|
|
||||||
"ffprobe",
|
|
||||||
"-print_format",
|
|
||||||
"json",
|
|
||||||
"-show_entries",
|
|
||||||
"stream=codec_long_name,width,height,bit_rate,duration,display_aspect_ratio,avg_frame_rate",
|
|
||||||
"-loglevel",
|
|
||||||
"quiet",
|
|
||||||
path,
|
|
||||||
]
|
|
||||||
return sp.run(ffprobe_cmd, capture_output=True)
|
|
||||||
|
|
||||||
|
|
||||||
def get_amd_gpu_stats() -> dict[str, str]:
|
def get_amd_gpu_stats() -> dict[str, str]:
|
||||||
"""Get stats using radeontop."""
|
"""Get stats using radeontop."""
|
||||||
radeontop_command = ["radeontop", "-d", "-", "-l", "1"]
|
radeontop_command = ["radeontop", "-d", "-", "-l", "1"]
|
||||||
@ -880,6 +865,27 @@ def get_nvidia_gpu_stats() -> dict[str, str]:
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
def ffprobe_stream(path: str) -> sp.CompletedProcess:
|
||||||
|
"""Run ffprobe on stream."""
|
||||||
|
ffprobe_cmd = [
|
||||||
|
"ffprobe",
|
||||||
|
"-print_format",
|
||||||
|
"json",
|
||||||
|
"-show_entries",
|
||||||
|
"stream=codec_long_name,width,height,bit_rate,duration,display_aspect_ratio,avg_frame_rate",
|
||||||
|
"-loglevel",
|
||||||
|
"quiet",
|
||||||
|
path,
|
||||||
|
]
|
||||||
|
return sp.run(ffprobe_cmd, capture_output=True)
|
||||||
|
|
||||||
|
|
||||||
|
def vainfo() -> sp.CompletedProcess:
|
||||||
|
"""Run vainfo."""
|
||||||
|
ffprobe_cmd = ["vainfo"]
|
||||||
|
return sp.run(ffprobe_cmd, capture_output=True)
|
||||||
|
|
||||||
|
|
||||||
class FrameManager(ABC):
|
class FrameManager(ABC):
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def create(self, name, size) -> AnyStr:
|
def create(self, name, size) -> AnyStr:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user