From 6d9a663120fa7a85b575da5f06988417e77ca4dd Mon Sep 17 00:00:00 2001 From: zqc <835569504@qq.com> Date: Wed, 4 Mar 2026 19:12:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E4=BC=A0=E5=85=A5camera=5Fid?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=9C=80=E6=96=B0n=E4=B8=AA=E5=88=86?= =?UTF-8?q?=E7=89=87=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/hls_utils.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/utils/hls_utils.py b/utils/hls_utils.py index d75b08c..e6b79c3 100644 --- a/utils/hls_utils.py +++ b/utils/hls_utils.py @@ -1,6 +1,8 @@ import os import glob +from common import constants + def get_latest_n_segments(camera_root_dir: str, n: int) -> list: """ @@ -50,3 +52,18 @@ def get_latest_n_segments(camera_root_dir: str, n: int) -> list: return all_segments[-n:] else: return all_segments + + +def get_latest_n_segments_by_camera_id(camera_id: str, n: int) -> list: + """ + 根据摄像头ID获取最新的n个TS分片 + + Args: + camera_id: 摄像头ID + n: 获取的分片数量 + + Returns: + 最新的n个分片路径list + """ + camera_root_dir = os.path.join(constants.HLS_ROOT_PATH, camera_id) + return get_latest_n_segments(camera_root_dir, n)