将时间戳 (如 "2m28s") 转换为总秒数
(self, timestamp)
| 25 | self.subtitles_dict = defaultdict(list) |
| 26 | |
| 27 | def parse_timestamp(self, timestamp): |
| 28 | """将时间戳 (如 "2m28s") 转换为总秒数""" |
| 29 | match = re.match(r'(\d+)m(\d+)s', timestamp) |
| 30 | if match: |
| 31 | minutes, seconds = map(int, match.groups()) |
| 32 | return minutes * 60 + seconds |
| 33 | return 0 |
| 34 | |
| 35 | def process_image(self, img_path): |
| 36 | """处理单个图像并提取文字""" |