Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
223 lines (200 loc) · 8.23 KB
/
Copy pathscript.js
File metadata and controls
223 lines (200 loc) · 8.23 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
const video1 = document.getElementById('video1');
const video2 = document.getElementById('video2');
const video2Label = document.getElementById('video2-text');
const startBtn = document.getElementById('start-stop-btn');
const reset = document.getElementById('restart-btn');
const mute = document.getElementById('mute-btn');
const videoSelect = document.getElementById('video-select');
const qualitySelect = document.getElementById('quality-select');
const comparisonSelect = document.getElementById('comparison-select');
const loadingText1 = document.getElementById('loading-text1');
const loadingText2 = document.getElementById('loading-text2');
// Video links
const videos = {
"bbb": {
qualities: {
20: {
//https://drive.google.com/file/d/1glgLM4dVw7O0ls3QI8R-CL69whL8HjLl/view?usp=share_link
spliced: "videos/bbb_qp20.mp4",
original: "videos/bbb_qp20.mp4"
},
30: {
//https://drive.google.com/file/d/1pGRzRtCWblD04Z83Qn2rvdwCnOrRaequ/view?usp=share_link
spliced: "videos/bbb_qp30_spliced.mp4",
//https://drive.google.com/file/d/1VO2Xq3XpvodYr9jJvbCAOdojQx8bo5na/view?usp=share_link
original: "videos/bbb_qp30.mp4"
},
40: {
//https://drive.google.com/file/d/1IW304QdZsViOE8uxEQXD6Xp_xageocZE/view?usp=share_link
spliced: "videos/bbb_qp40_spliced.mp4",
//https://drive.google.com/file/d/1FyMfwRycAaFLgn0j3IgweFTl0f0rVTE6/view?usp=share_link
original: "videos/bbb_qp40.mp4"
},
50: {
//https://drive.google.com/file/d/1utRTzQ5s5uUwURixQpGa795ZavRv_Xuq/view?usp=share_link
spliced: "videos/bbb_qp50_spliced.mp4",
//https://drive.google.com/file/d/1OemEqxGX_m71WCoYzqv_6TorxDO99lEL/view?usp=share_link
original: "videos/bbb_qp50.mp4"
}
}
},
"no-event": {
qualities: {
20: {
//https://drive.google.com/file/d/19cG8frcsRyzNzSobVJ1aGXlOEwpt8FN7/view?usp=share_link
spliced: "videos/no-event_qp20.mp4",
original: "videos/no-event_qp20.mp4"
},
30: {
//https://drive.google.com/file/d/1AuWz4_xvNnNoA-WjuDytLff4YNzPQ4Jd/view?usp=share_link
spliced: "videos/no-event_qp30_spliced.mp4",
//https://drive.google.com/file/d/1fKIW-GgKbYw5st4_dB7Bf-V30Xd5KnrL/view?usp=share_link
original: "videos/no-event_qp30.mp4"
},
40: {
//https://drive.google.com/file/d/1msfvrlDe_hr_zeB7jw4FF1r80Qeuh-kr/view?usp=share_link
spliced: "videos/no-event_qp40_spliced.mp4",
//https://drive.google.com/file/d/1BVFysXiC6P-frWTKtJkyk5o2ctBUJQ64/view?usp=share_link
original: "videos/no-event_qp40.mp4"
},
50: {
//https://drive.google.com/file/d/1CLDTfAKxZL81CN6SRTehDjT21yG13BON/view?usp=share_link
spliced: "videos/no-event_qp50_spliced.mp4",
//https://drive.google.com/file/d/1x7E5xCCGRzEZrV3RTAx4y4YcrzLYU68o/view?usp=share_link
original: "videos/no-event_qp50.mp4"
}
}
},
"motorbike": {
qualities: {
20: {
//https://drive.google.com/file/d/1_mu1-BS810uLxzuZrK67d1AQdWM-iVbg/view?usp=share_link
spliced: "videos/motorbike_qp20.mp4",
original: "videos/motorbike_qp20.mp4"
},
30: {
//https://drive.google.com/file/d/14Bhswv4_2E41C3BL-S20Si_X-YMbPy9L/view?usp=share_link
spliced: "videos/motorbike_qp30_spliced.mp4",
//https://drive.google.com/file/d/1MTdOnPBq7cnHr0emo1tNRX0jiN7ODsqf/view?usp=share_link
original: "videos/motorbike_qp30.mp4"
},
40: {
//https://drive.google.com/file/d/1eX_0qphgJQ_3CBH4xVKIqcBxMhd6oKFR/view?usp=share_link
spliced: "videos/motorbike_qp40_spliced.mp4",
//https://drive.google.com/file/d/1KDzFOMPe2jchQF3N_BqYbaLuMx50tbf0/view?usp=share_link
original: "videos/motorbike_qp40.mp4"
},
50: {
//https://drive.google.com/file/d/1cgmh0xR7qbDhAzP6NHi_P4GPdBZQnYy8/view?usp=share_link
spliced: "videos/motorbike_qp50_spliced.mp4",
//https://drive.google.com/file/d/1UPJHdmbaXmJ3u9JYSF33VynCIHKkztPK/view?usp=share_link
original: "videos/motorbike_qp50.mp4"
}
}
}
};
video1.src = videos[videoSelect.value].qualities[qualitySelect.value].spliced;
video2.src = videos[videoSelect.value].qualities[qualitySelect.value].original;
video2Label.textContent = `Reference Video: Unspliced Version (QP ${qualitySelect.value})`;
// Helpers
const resetVideos = () => {
// reset audio states
video1.muted = false;
video2.muted = false;
mute.textContent = 'Mute';
// reset playback states
video1.pause();
video2.pause();
video1.currentTime = 0;
video2.currentTime = 0;
startBtn.textContent = 'Start';
loadingText1.style.display = 'auto';
loadingText2.style.display = 'auto';
}
const pauseAll = () => {
video1.pause();
video2.pause();
startBtn.textContent = 'Start';
}
// Event Listeners
video1.addEventListener('loadeddata', () => {
loadingText1.style.display = 'none';
});
video2.addEventListener('loadeddata', () => {
loadingText2.style.display = 'none';
});
video1.addEventListener('stalled', () => {
video2.currentTime = video1.currentTime;
pauseAll();
});
video2.addEventListener('stalled', () => {
video1.currentTime = video2.currentTime;
pauseAll();
});
video1.addEventListener('readystatechange', () => {
if (video1.readyState >= 4 && video2.readyState >= 4) {
alert("Both videos are loaded")
}
});
video2.addEventListener('readystatechange', () => {
if (video1.readyState >= 4 && video2.readyState >= 4) {
alert("Both videos are loaded")
}
});
video1.addEventListener('ended', () => {
startBtn.textContent = 'Start';
});
video2.addEventListener('ended', () => {
startBtn.textContent = 'Start';
});
videoSelect.addEventListener('change', () => {
video1.src = videos[videoSelect.value].qualities[qualitySelect.value].spliced;
video2.src = videos[videoSelect.value].qualities[qualitySelect.value].original;
resetVideos();
});
qualitySelect.addEventListener('change', () => {
video1.src = videos[videoSelect.value].qualities[qualitySelect.value].spliced;
if (comparisonSelect.value !== 'reference') {
video2.src = videos[videoSelect.value].qualities[qualitySelect.value].original;
video2Label.textContent = `Reference Video: Unspliced Version (QP ${qualitySelect.value})`;
}
resetVideos();
});
comparisonSelect.addEventListener('change', () => {
if (comparisonSelect.value === 'reference') {
video2.src = videos[videoSelect.value].qualities[20].original;
video2Label.textContent = 'Reference Video: High Quality (QP 20)';
} else {
video2.src = videos[videoSelect.value].qualities[qualitySelect.value].original;
video2Label.textContent = `Reference Video: Unspliced Version (QP ${qualitySelect.value})`;
}
resetVideos();
});
startBtn.addEventListener('click', async () => {
if (video1.paused && video2.paused) {
if (video1.readyState >= 4 && video2.readyState >= 4) {
video1.play();
video2.play();
startBtn.textContent = 'Stop';
} else
alert("Please wait for both videos to finish loading")
} else {
pauseAll()
}
});
reset.addEventListener('click', () => {
video1.currentTime = 0;
video2.currentTime = 0;
video1.play();
video2.play();
startBtn.textContent = 'Stop';
});
mute.addEventListener('click', () => {
video1.muted = !video1.muted;
video2.muted = !video2.muted;
mute.textContent = video1.muted ? 'Unmute' : 'Mute';
});
video1.ontimeupdate = function(){
const percentage = ( video1.currentTime / video1.duration ) * 100;
document.querySelector("#custom-seekbar span").style.width = percentage+"%";
};