Add ffprobe endpoint

This commit is contained in:
Nick Mowen 2022-11-09 14:36:33 -07:00
parent 68248cc274
commit aadc8a8d3d

View File

@ -26,6 +26,7 @@ from flask import (
from peewee import SqliteDatabase, operator, fn, DoesNotExist from peewee import SqliteDatabase, operator, fn, DoesNotExist
from playhouse.shortcuts import model_to_dict from playhouse.shortcuts import model_to_dict
from frigate.config import CameraConfig
from frigate.const import CLIPS_DIR 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
@ -612,6 +613,40 @@ def stats():
return jsonify(stats) return jsonify(stats)
@bp.route("/<camera_name>/ffprobe")
def ffprobe(camera_name):
if camera_name not in current_app.frigate_config.cameras:
return jsonify(
{"success": False, "message": f"Camera name {camera_name} not found"}, "404"
)
config: CameraConfig = current_app.frigate_config.cameras[camera_name]
if len(config.ffmpeg.inputs) > 1:
# user has multiple streams
ffprobe_cmd = [
"ffprobe",
"-rtsp_transport",
"tcp",
config.ffmpeg.inputs[0].path,
]
else:
# user has single stream
ffprobe = ffprobe_stream(config.ffmpeg.inputs[0].path)
if not ffprobe:
return jsonify(
{
"success": False,
"message": f"ffprobe unable to get info for {camera_name}",
},
"500",
)
else:
return jsonify(
{"success": True, "message": ffprobe}, "200"
)
@bp.route("/<camera_name>") @bp.route("/<camera_name>")
def mjpeg_feed(camera_name): def mjpeg_feed(camera_name):
fps = int(request.args.get("fps", "3")) fps = int(request.args.get("fps", "3"))