-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscripts.py
34 lines (25 loc) · 999 Bytes
/
scripts.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
import datetime
import cv2
class Value:
all_time = ''
now_time = ''
def get_seconds(time_str: str):
time_list = time_str.strip().split(':')
time_list = [float(i) for i in time_list]
seconds = 0
for i, num in enumerate(time_list[::-1]):
seconds = seconds + 60 ** i * num
return seconds
def get_extract_voice_progress(input_str: str)->int:
if 'Duration:' in input_str:
Value.all_time = input_str[10:21]
index = input_str.index('Duration:')
Value.all_time = input_str[index + 10:index + 21]
if input_str[:5] == 'size=':
Value.now_time = input_str[21:32]
# print(Value.now_time, Value.all_time)
progress = get_seconds(Value.now_time) / get_seconds(Value.all_time) * 100
return int(progress)
def get_data_time(str_time):
return datetime.timedelta(hours=int(str_time[0:2]), minutes=int(str_time[3:5]),
seconds=int(str_time[6:8]), milliseconds=int(str_time[9:]))