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)