Showing
3 changed files
with
5 additions
and
18 deletions
| @@ -72,7 +72,7 @@ class FootballReplayMatch: | @@ -72,7 +72,7 @@ class FootballReplayMatch: | ||
| 72 | else: | 72 | else: |
| 73 | # mp4_name = os.path.basename(os.path.dirname(os.path.dirname(os.path.dirname(video_url)))) | 73 | # mp4_name = os.path.basename(os.path.dirname(os.path.dirname(os.path.dirname(video_url)))) |
| 74 | mp4_name = os.path.basename(os.path.dirname(os.path.dirname(video_url))) | 74 | mp4_name = os.path.basename(os.path.dirname(os.path.dirname(video_url))) |
| 75 | - 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)) | 75 | + 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)) |
| 76 | 76 | ||
| 77 | def replay_match_event(self, data): | 77 | def replay_match_event(self, data): |
| 78 | """ | 78 | """ |
| @@ -207,17 +207,7 @@ class FootballReplayMatchLive: | @@ -207,17 +207,7 @@ class FootballReplayMatchLive: | ||
| 207 | end_time = time.time() | 207 | end_time = time.time() |
| 208 | logger.info(f"match_once_invoke_cost_time:{end_time-start_time:.2f}seconds") | 208 | logger.info(f"match_once_invoke_cost_time:{end_time-start_time:.2f}seconds") |
| 209 | 209 | ||
| 210 | - # print(100*"3") | ||
| 211 | - # logger.info(f"match once invoke result: {result}") | ||
| 212 | - # print(100*"4") | ||
| 213 | - # try: | ||
| 214 | - # result_json = json.loads(result) | ||
| 215 | - # except json.JSONDecodeError: | ||
| 216 | - # try: | ||
| 217 | - # result_json = json.loads(result.replace("```json", "").replace("```", "")) | ||
| 218 | - # except Exception as e: | ||
| 219 | - # print("JSON解析失败:", result) | ||
| 220 | - # raise e | 210 | + |
| 221 | if result.strip() == "null": | 211 | if result.strip() == "null": |
| 222 | result_json = {"video_id": None} | 212 | result_json = {"video_id": None} |
| 223 | else: | 213 | else: |
| @@ -270,10 +260,8 @@ class FootballReplayMatchLive: | @@ -270,10 +260,8 @@ class FootballReplayMatchLive: | ||
| 270 | with open(cache_path, 'r', encoding='utf-8') as f: | 260 | with open(cache_path, 'r', encoding='utf-8') as f: |
| 271 | return json.loads(f.read()) | 261 | return json.loads(f.read()) |
| 272 | 262 | ||
| 273 | - # 按照max_parallel对live_videos进行分组 | ||
| 274 | - live_videos_groups = [live_videos[i::max_parallel] for i in range(max_parallel)] | ||
| 275 | - # 过滤掉空的分组 | ||
| 276 | - live_videos_groups = [g for g in live_videos_groups if g] | 263 | + # 将 live_videos 按照每 max_parallel 个进行顺序划分 |
| 264 | + live_videos_groups = [live_videos[i:i + max_parallel] for i in range(0, len(live_videos), max_parallel)] | ||
| 277 | # 如果group 大于1 并且最后一个group 只有一个元素,将其唯一元素放入倒数第二个group,并删除最后一个group | 265 | # 如果group 大于1 并且最后一个group 只有一个元素,将其唯一元素放入倒数第二个group,并删除最后一个group |
| 278 | if len(live_videos_groups) > 1 and len(live_videos_groups[-1]) == 1: | 266 | if len(live_videos_groups) > 1 and len(live_videos_groups[-1]) == 1: |
| 279 | live_videos_groups[-2].append(live_videos_groups[-1][0]) | 267 | live_videos_groups[-2].append(live_videos_groups[-1][0]) |
| @@ -101,7 +101,6 @@ class Video2Frame: | @@ -101,7 +101,6 @@ class Video2Frame: | ||
| 101 | 101 | ||
| 102 | if cache_name.exists(): | 102 | if cache_name.exists(): |
| 103 | logger.info(f"use_cache: {cache_name}") | 103 | logger.info(f"use_cache: {cache_name}") |
| 104 | - # return json.load(cache_name.open('r')) | ||
| 105 | with cache_name.open('r', encoding='utf-8') as f: | 104 | with cache_name.open('r', encoding='utf-8') as f: |
| 106 | return json.load(f) | 105 | return json.load(f) |
| 107 | else: | 106 | else: |
| @@ -137,7 +136,7 @@ class Video2Frame: | @@ -137,7 +136,7 @@ class Video2Frame: | ||
| 137 | # json.dump(data, cache_name.open('w'), indent=4) | 136 | # json.dump(data, cache_name.open('w'), indent=4) |
| 138 | with cache_name.open('w', encoding='utf-8') as f: | 137 | with cache_name.open('w', encoding='utf-8') as f: |
| 139 | json.dump(data, f, indent=4) | 138 | json.dump(data, f, indent=4) |
| 140 | - logger.info(f"save_cache: {cache_name}") | 139 | + logger.info(f"save_cache:{cache_name}") |
| 141 | end_time = time.time() | 140 | end_time = time.time() |
| 142 | logger.info(f"to_frames_cost_time:{end_time - start_time:.2f}seconds") | 141 | logger.info(f"to_frames_cost_time:{end_time - start_time:.2f}seconds") |
| 143 | return data | 142 | return data |
-
Please register or login to post a comment