This repository has been archived by the owner on Oct 13, 2023. It is now read-only.
forked from HenryLulu/video-to-text-ocr-demo
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathindex.py
91 lines (66 loc) · 2.14 KB
/
index.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# -*- coding: UTF-8 -*-
import os
import sys
import time
import getframe
import getsubtitle
from config import Config
def clear():
if sys.platform.find("win") > -1:
os.system("cls")
else:
print()
def main():
Config.set_path()
if not (os.path.exists(Config.get_value('video_dir'))):
os.mkdir(Config.get_value('video_dir'))
if not (os.path.exists(Config.get_value('video_frames'))):
os.mkdir(Config.get_value('video_frames'))
if not (os.path.exists(Config.get_value('output_dir'))):
os.mkdir(Config.get_value('output_dir'))
video_name = ""
video_suffix = ""
while True:
clear()
print("----------Select Video----------")
video_list = os.listdir(Config.get_value('video_dir'))
if len(video_list) < 1:
print("Nothing found\n\n")
print("Process finished")
input()
return
for video in video_list:
print("%d.%s" % (video_list.index(video) + 1, video))
try:
index = int(input("\nInput index: "))
except ValueError:
continue
if 0 < index <= len(video_list):
video_name = video_list[index - 1][: video_list[index - 1].rfind(".")]
video_suffix = video_list[index - 1][video_list[index - 1].rfind("."):]
break
Config.set_path(video_name, video_suffix)
start = time.time()
print("\n----------Video Division----------")
print("Start video division")
if not getframe.main():
print("Video division FAILED!")
print("Process finished")
input()
return
print("Video division finished")
print("Time: %.2fs\n" % (time.time() - start))
start2 = time.time()
print("----------Subtitle Analysis----------")
print("Start subtitle analysis")
if not getsubtitle.main():
print("\nSubtitle analysis FAILED!")
else:
print("\nSubtitle analysis finished")
print("Time: %.2fs\n" % (time.time() - start2))
print("Process finished")
print("Time: %.2fs" % (time.time() - start))
input()
return
if __name__ == "__main__":
main()