From e1c1d343b1b686b0ff1f0d4ac9ec37b80e7c9f5c Mon Sep 17 00:00:00 2001 From: zqc <835569504@qq.com> Date: Sat, 28 Feb 2026 12:10:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Ehls=20root=20path=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/contants.py | 5 ++++- config.yaml | 3 ++- test_cam.py | 55 +++++++++++++++++++++++++++------------------- 3 files changed, 39 insertions(+), 24 deletions(-) diff --git a/common/contants.py b/common/contants.py index 6986cdd..8a8413f 100644 --- a/common/contants.py +++ b/common/contants.py @@ -1,9 +1,11 @@ - import yaml + +import yaml from utils.logger import get_logger logger = get_logger(__name__) ALERT_PUSH_URL = "" +HLS_ROOT_PATH = "" def init_config(config_path: str = "config.yaml"): @@ -20,6 +22,7 @@ def init_config(config_path: str = "config.yaml"): cfg = yaml.safe_load(f) ALERT_PUSH_URL = cfg.get("alert_push_url", "") + HLS_ROOT_PATH = cfg.get("hls_root_path", "") logger.info(f"[INFO] Config initialized from {config_path}, alert_push_url={ALERT_PUSH_URL}") except Exception as e: diff --git a/config.yaml b/config.yaml index 0ae4856..b375589 100644 --- a/config.yaml +++ b/config.yaml @@ -34,13 +34,14 @@ database: # debug_mode: True=前台运行(适合PyCharm调试),False=后台运行(适合生产部署) debug_mode: true alert_push_url: "http://123.57.151.210:10000/picenter/websocket/test/process" +hls_root_path: "D:/ProjectDoc/Police/data/hls" service_groups: - name: "kadian_group" # 服务组名称 video_source_type: "hls" ws_host: "0.0.0.0" # WebSocket 服务地址 ws_port: 8765 # WebSocket 服务端口 - algorithm: "kadian" # 算法类型 + algorithm: "supervision_room" # 算法类型 cameras: # 该组下的摄像头列表 - id: 1 index: testindexcode diff --git a/test_cam.py b/test_cam.py index 4c0d4ca..87161a3 100644 --- a/test_cam.py +++ b/test_cam.py @@ -13,30 +13,41 @@ signer = HikvisionOpenAPISigner( headers={'tagId': '0'} # 根据平台要求设置 ) -def get_camera_preview_url(camera_index_code): - # 签名一个请求 - request = signer.sign( - 'POST', - '/api/video/v1/cameras/previewURLs', - jsons={'cameraIndexCode': camera_index_code, 'protocol': 'rtsp', 'expand': 'streamform=rtp'}, - accept='application/json' - ) - method, url, headers, body = request - # 发送请求 - response = requests.request(method, url, headers=headers, data=body, verify=False) - return response.json() - -# # for test # def get_camera_preview_url(camera_index_code): -# """测试用的方法,直接返回固定结果""" -# return { -# "code": "0", -# "msg": "SUCCESS", -# "data": { -# "url": "rtsp://localhost:8554/test" -# } -# } +# # 签名一个请求 +# request = signer.sign( +# 'POST', +# '/api/video/v1/cameras/previewURLs', +# jsons={'cameraIndexCode': camera_index_code, 'protocol': 'rtsp', 'expand': 'streamform=rtp'}, +# accept='application/json' +# ) +# method, url, headers, body = request +# # 发送请求 +# response = requests.request(method, url, headers=headers, data=body, verify=False) +# return response.json() +# for test +def get_camera_preview_url(camera_index_code): + """测试用的方法,直接返回固定结果""" + return { + "code": "0", + "msg": "SUCCESS", + "data": { + # "url": "rtsp://192.168.110.139:8554/test" + "url": "rtsp://192.168.43.33:8554/test" + # "url": "rtsp://localhost:8554/test" + } + } + +def get_camera_hls_url(camera_index_code): + """测试用的方法,直接返回固定结果""" + return { + "code": "0", + "msg": "SUCCESS", + "data": { + "url": "https://demo.unified-streaming.com/k8s/live/scte35.isml/.m3u8" + } + } # # 读取 config.yaml # with open('config.yaml', 'r', encoding='utf-8') as f: