videocr/api.py (view raw)
1
2from .video import Video
3
4
5def get_subtitles(video_path: str, lang='eng',
6 time_start='0:00', time_end='', use_fullframe=False) -> str:
7 v = Video(video_path)
8 v.run_ocr(lang, time_start, time_end, use_fullframe)
9 return v.get_subtitles()
10
11
12def save_subtitles_to_file(
13 video_path: str, file_path='subtitle.srt', lang='eng',
14 time_start='0:00', time_end='', use_fullframe=False) -> None:
15 with open(file_path, 'w+') as f:
16 f.write(get_subtitles(
17 video_path, lang, time_start, time_end, use_fullframe))