lizhengwei

jira:NYJ-1656 desc: modified live_videos_groups

... ... @@ -72,7 +72,7 @@ class FootballReplayMatch:
else:
# mp4_name = os.path.basename(os.path.dirname(os.path.dirname(os.path.dirname(video_url))))
mp4_name = os.path.basename(os.path.dirname(os.path.dirname(video_url)))
return self.videoMatchLive.match_batch(replay, events, max_parallel=2, cache_dir=os.path.join(self.cache_dir, mp4_name, "events"), task_log_dir=os.path.join(self.task_log_dir, mp4_name, task_id))
return self.videoMatchLive.match_batch(replay, events, max_parallel=3, cache_dir=os.path.join(self.cache_dir, mp4_name, "events"), task_log_dir=os.path.join(self.task_log_dir, mp4_name, task_id))
def replay_match_event(self, data):
"""
... ...
... ... @@ -207,17 +207,7 @@ class FootballReplayMatchLive:
end_time = time.time()
logger.info(f"match_once_invoke_cost_time:{end_time-start_time:.2f}seconds")
# print(100*"3")
# logger.info(f"match once invoke result: {result}")
# print(100*"4")
# try:
# result_json = json.loads(result)
# except json.JSONDecodeError:
# try:
# result_json = json.loads(result.replace("```json", "").replace("```", ""))
# except Exception as e:
# print("JSON解析失败:", result)
# raise e
if result.strip() == "null":
result_json = {"video_id": None}
else:
... ... @@ -270,10 +260,8 @@ class FootballReplayMatchLive:
with open(cache_path, 'r', encoding='utf-8') as f:
return json.loads(f.read())
# 按照max_parallel对live_videos进行分组
live_videos_groups = [live_videos[i::max_parallel] for i in range(max_parallel)]
# 过滤掉空的分组
live_videos_groups = [g for g in live_videos_groups if g]
# 将 live_videos 按照每 max_parallel 个进行顺序划分
live_videos_groups = [live_videos[i:i + max_parallel] for i in range(0, len(live_videos), max_parallel)]
# 如果group 大于1 并且最后一个group 只有一个元素,将其唯一元素放入倒数第二个group,并删除最后一个group
if len(live_videos_groups) > 1 and len(live_videos_groups[-1]) == 1:
live_videos_groups[-2].append(live_videos_groups[-1][0])
... ...
... ... @@ -101,7 +101,6 @@ class Video2Frame:
if cache_name.exists():
logger.info(f"use_cache: {cache_name}")
# return json.load(cache_name.open('r'))
with cache_name.open('r', encoding='utf-8') as f:
return json.load(f)
else:
... ... @@ -137,7 +136,7 @@ class Video2Frame:
# json.dump(data, cache_name.open('w'), indent=4)
with cache_name.open('w', encoding='utf-8') as f:
json.dump(data, f, indent=4)
logger.info(f"save_cache: {cache_name}")
logger.info(f"save_cache:{cache_name}")
end_time = time.time()
logger.info(f"to_frames_cost_time:{end_time - start_time:.2f}seconds")
return data
... ...