支持设置时间选区

支持方向键快进快退(ctrl + -> or shirft + -> or ->)
This commit is contained in:
Jason
2025-05-19 09:54:21 +08:00
parent 7cf4e882cd
commit e26e23ad6a
15 changed files with 488 additions and 91 deletions

View File

@@ -300,5 +300,25 @@ def expand_frame_ranges(frame_ranges, backward_frame_count, forward_frame_count)
return expanded_ranges
def is_frame_number_in_ab_sections(frame_no, ab_sections):
"""
检查给定的帧号是否在指定的A/B区间内。
Args:
frame_no: 要检查的帧号
ab_sections: 包含A/B区间的列表格式为[range(start, end), ...]
Returns:
如果帧号在A/B区间内返回True否则返回False。
"""
if ab_sections is None:
return True
if len(ab_sections) <= 0:
return True
for section in ab_sections:
if frame_no in section:
return True
return False
if __name__ == '__main__':
multiprocessing.set_start_method("spawn")

View File

@@ -12,6 +12,7 @@ from .ocr import get_coordinates
from backend.config import config, tr
from backend.scenedetect import scene_detect
from backend.scenedetect.detectors import ContentDetector
from backend.tools.inpaint_tools import is_frame_number_in_ab_sections
class SubtitleDetect:
"""
@@ -73,6 +74,9 @@ class SubtitleDetect:
break
# 读取视频帧成功
current_frame_no += 1
if not is_frame_number_in_ab_sections(current_frame_no - 1, sub_remover.ab_sections):
tbar.update(1)
continue
temp_list = self.detect_subtitle(frame)
if len(temp_list) > 0:
subtitle_frame_no_box_dict[current_frame_no] = temp_list