forked from torsrex/jumpcutter
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.py
110 lines (92 loc) · 3.65 KB
/
test.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
103
104
105
106
107
108
109
110
from pytube import YouTube
import os
import subprocess
testfiles = ["30fps.mp4", "60 fps.mp4",
"15fps.mp4", "soundless.mp4", "music.mp4"]
def downloadFile(url):
sep = os.path.sep
originalPath = YouTube(url).streams.first().download()
filepath = originalPath.split(sep)
filepath[-1] = filepath[-1].replace(' ', '_')
filepath = sep.join(filepath)
os.rename(originalPath, filepath)
return filepath
def downloadTestdata():
p = downloadFile("https://www.youtube.com/watch?v=aqz-KE-bpKQ")
command = ["ffmpeg", "-i", p, "-r", "15", "-t", "00:01:00", testfiles[2]]
subprocess.run(command)
command = ["ffmpeg", "-i", p, "-r", "60", "-t", "00:01:00", testfiles[1]]
subprocess.run(command)
command = ["ffmpeg", "-i", p, "-t", "00:01:00", testfiles[0]]
subprocess.run(command)
command = ["ffmpeg", "-i", testfiles[0], "-an", testfiles[3]]
subprocess.run(command)
command = ["ffmpeg", "-i", testfiles[0], "-vn", testfiles[4]]
subprocess.run(command)
os.remove(p)
# prepare testdata if missing
for src in testfiles:
if(not os.path.isfile(src)):
print("missing "+src)
downloadTestdata()
print("15fps autodetection test")
command = ["python3", "jumpcutter.py", "--input_file",
testfiles[2], "--output_file", "t.mp4"]
subprocess.run(command)
assert(os.path.getsize("t.mp4") == 8443196)
os.remove("t.mp4")
print("30fps autodetection test")
command = ["python3", "jumpcutter.py", "--input_file",
testfiles[0], "--output_file", "t.mp4"]
subprocess.run(command)
assert(os.path.getsize("t.mp4") == 8571040)
os.remove("t.mp4")
print("60fps autodetection test + space test")
command = ["python3", "jumpcutter.py", "--input_file",
testfiles[1], "--output_file", "t t.mp4"]
subprocess.run(command)
assert(os.path.getsize("t t.mp4") == 8113359)
os.remove("t t.mp4")
print("soundless test")
command = ["python3", "jumpcutter.py", "--input_file",
testfiles[3], "--output_file", "t.mp4"]
subprocess.run(command)
print("music test")
command = ["python3", "jumpcutter.py", "--input_file",
testfiles[4], "--output_file", "t.mp4"]
subprocess.run(command)
print("audio_only music test")
command = ["python3", "jumpcutter.py", "--input_file",
testfiles[4], "--output_file", "t.mp4", "--audio_only"]
subprocess.run(command)
assert(os.path.getsize("t.mp4") == 565547)
os.remove("t.mp4")
print("audio_only video test")
command = ["python3", "jumpcutter.py", "--input_file",
testfiles[2], "--output_file", "t.mp4", "--audio_only"]
subprocess.run(command)
assert(os.path.getsize("t.mp4") == 408510)
print("slowdown test + force test")
command = ["python3", "jumpcutter.py", "--input_file",
testfiles[2], "--output_file", "t.mp4", "--force", "--sounded_speed", "0.5", "--silent_speed", "0.9"]
subprocess.run(command)
assert(os.path.getsize("t.mp4") == 22962113)
os.remove("t.mp4")
print("low quality test")
command = ["python3", "jumpcutter.py", "--input_file",
testfiles[2], "--output_file", "t.mp4", "--frame_quality", "31", "--crf", "50", "--preset", "ultrafast"]
subprocess.run(command)
assert(os.path.getsize("t.mp4") == 796732)
os.remove("t.mp4")
print("phasevocoder test")
command = ["python3", "jumpcutter.py", "--input_file",
testfiles[2], "--output_file", "t.mp4", "--stretch_algorithm", "phasevocoder", "--sounded_speed", "0.5"]
subprocess.run(command)
assert(os.path.getsize("t.mp4") == 19991295)
os.remove("t.mp4")
print("edl test")
command = ["python3", "jumpcutter.py", "--input_file",
testfiles[2], "--output_file", "t.edl", "--edl"]
subprocess.run(command)
assert(os.path.getsize("t.edl") == 1464)
os.remove("t.edl")