新增传入camera_id获取最新n个分片方法

This commit is contained in:
zqc
2026-03-04 19:12:55 +08:00
parent 741056a25b
commit 6d9a663120

View File

@@ -1,6 +1,8 @@
import os import os
import glob import glob
from common import constants
def get_latest_n_segments(camera_root_dir: str, n: int) -> list: 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:] return all_segments[-n:]
else: else:
return all_segments 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)