all repos — videocr @ bd6f15978b905d9e6c72fe6f8c2b43e80e0d44ab

Extract hardcoded subtitles from videos using machine learning

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))