-
Notifications
You must be signed in to change notification settings - Fork 44
/
run_osu.py
executable file
·103 lines (82 loc) · 2.66 KB
/
run_osu.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
92
93
94
95
96
97
98
99
100
101
102
import inspect
import os
import sys
import time
import traceback
class Dummy: pass
#
# def fixpath():
# newpath = ['']
# for i in sys.path:
# if os.path.dirname(sys.executable) in i:
# newpath.append(i)
# print(sys.path, "\n", newpath)
# return newpath
def update_progress(framecount, deltatime, videotime):
abspath = os.path.dirname(os.path.abspath(inspect.getsourcefile(Dummy)))
nframe = videotime[1] - videotime[0]
curprogress = min(99, framecount/nframe * 100)
fprogress = open(os.path.join(abspath, "progress.txt"), "w")
fprogress.write(str(curprogress))
fprogress.close()
print(curprogress)
def run():
import osr2mp4
from osr2mp4.osr2mp4 import Osr2mp4
osr2mp4.VideoProcess.CreateFrames.update_progress = update_progress
abspath = os.path.dirname(os.path.abspath(inspect.getsourcefile(Dummy)))
execpath = sys.argv[1]
logpath = os.path.join(execpath, "Logs/")
fprogress = open(os.path.join(abspath, "progress.txt"), "w")
fprogress.write("0")
fprogress.close()
logpath = os.path.join(logpath, "core.log")
config = os.path.join(abspath, "config.json")
settings = os.path.join(abspath, "settings.json")
ppsettings = os.path.join(abspath, "ppsettings.json")
if not os.path.isfile(ppsettings):
ppsettings = None
converter = Osr2mp4(filedata=config, filesettings=settings, filepp=ppsettings, logtofile=True, logpath=logpath)
converter.startall()
curprogress = 0
while curprogress < 99:
curprogress = converter.getprogress()
a = False
if converter.writers is None:
break
for i in range(len(converter.writers)):
if converter.writers[i].is_alive():
a = True
if converter.writers[i].exitcode is not None and converter.writers[i].exitcode != 0:
return
if converter.drawers[i].exitcode is not None and converter.drawers[i].exitcode != 0:
return
if converter.audio is not None:
if converter.audio.exitcode is not None and converter.audio.exitcode != 0:
return
if not a:
curprogress = 99
fprogress = open(os.path.join(abspath, "progress.txt"), "w")
fprogress.write(str(curprogress))
fprogress.close()
print(curprogress)
time.sleep(1)
converter.joinall()
fprogress = open(os.path.join(abspath, "progress.txt"), "w")
# fprogress.write("100")
time.sleep(0.5)
fprogress.write("done")
fprogress.close()
if __name__ == "__main__":
try:
# sys.path = fixpath()
run()
except Exception as e:
tb = traceback.format_exc()
abspath = os.path.dirname(os.path.abspath(inspect.getsourcefile(Dummy)))
ferror = open(os.path.join( "error.txt"), "w")
ferror.write(repr(e) + str(e) + " " + tb)
ferror.close()
fprogress = open(os.path.join(abspath, "progress.txt"), "w")
fprogress.write("error")
fprogress.close()