diff --git a/frigate/http.py b/frigate/http.py index 22d96f2d6..48fb614f6 100644 --- a/frigate/http.py +++ b/frigate/http.py @@ -26,6 +26,7 @@ from flask import ( from peewee import SqliteDatabase, operator, fn, DoesNotExist from playhouse.shortcuts import model_to_dict +from frigate.config import CameraConfig from frigate.const import CLIPS_DIR from frigate.models import Event, Recordings from frigate.object_processing import TrackedObject @@ -612,6 +613,40 @@ def stats(): return jsonify(stats) +@bp.route("//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("/") def mjpeg_feed(camera_name): fps = int(request.args.get("fps", "3"))