-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
331 lines (293 loc) · 13 KB
/
index.html
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Welcome to Firebase Hosting</title>
<!-- update the version number as needed -->
<script defer src="/__/firebase/8.4.2/firebase-app.js"></script>
<!-- include only the Firebase features as you need -->
<script defer src="/__/firebase/8.4.2/firebase-auth.js"></script>
<script defer src="/__/firebase/8.4.2/firebase-database.js"></script>
<script defer src="/__/firebase/8.4.2/firebase-firestore.js"></script>
<script defer src="/__/firebase/8.4.2/firebase-functions.js"></script>
<script defer src="/__/firebase/8.4.2/firebase-messaging.js"></script>
<script defer src="/__/firebase/8.4.2/firebase-storage.js"></script>
<script defer src="/__/firebase/8.4.2/firebase-analytics.js"></script>
<script defer src="/__/firebase/8.4.2/firebase-remote-config.js"></script>
<script defer src="/__/firebase/8.4.2/firebase-performance.js"></script>
<script defer src="/__/firebase/init.js?useEmulator=true"></script>
<style media="screen">
body { background: #302f2c; color: rgba(0,0,0,0.87); font-family: Roboto, Helvetica, Arial, sans-serif; margin: 0; padding: 0;}
#message { background: white; max-width: 360px; margin: 100px auto 16px; padding: 32px 24px; border-radius: 3px; }
#message h2 { color: #0074b8; font-weight: bold; font-size: 16px; margin: 0 0 8px; }
#message h1 { font-size: 22px; font-weight: 300; color: rgba(0,0,0,0.6); margin: 0 0 16px;}
#message p { line-height: 140%; margin: 16px 0 24px; font-size: 14px; }
#message a { display: block; text-align: center; background: #039be5; text-transform: uppercase; text-decoration: none; color: white; padding: 16px; border-radius: 4px; }
#message, #message a { box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24); }
#load { color: rgba(0,0,0,0.4); text-align: center; font-size: 13px; }
#botones { background-color: #fafafa; margin: 1rem padding: 1rem; border: 2px solid #0074b8;text-align: center; margin-left: 20%; margin-right: 20%;}
#demo {font-family: "Times New Roman"; background-color: #fafafa; border: 2px solid #0074b8;text-align: center; margin-left: 20%; margin-right: 20%; padding: 32px 24px; border-radius: 3px;}
#demo2 {font-family: "Times New Roman"; background-color: #fafafa; border: 2px solid #0074b8;text-align: center; margin-left: 20%; margin-right: 20%; padding: 32px 24px; border-radius: 3px;}
#demo3 {font-family:"Times New Roman"; background-color: #fafafa; border: 2px solid #0074b8; text-align: center; padding: 32px 24px; margin-left: 20%; margin-right: 20%; border-radius: 3px;}
#demo5 {font-family: "Times New Roman"; background-color: #fafafa; border: 2px solid #0074b8; text-align: center; padding: 32px 24px; margin-left: 20%; margin-right: 20%; border-radius: 3px;}
#demo4 {font-family: "Times New Roman"; background-color: #fafafa; border: 2px solid #0074b8; text-align: center; padding: 32px 24px; margin-left: 20%; margin-right: 20%; border-radius: 3px;}
@media (max-width: 600px) {
body, #message { margin-top: 0; background: white; box-shadow: none; }
body { border-top: 16px solid #ffa100; }
}
</style>
</head>
<body>
</div>
<script>
//funció que carrega contingut html a partir de una crida a una funcio GCP
function loadDoc() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
//load the video-shots in "demo"
document.getElementById("demo").innerHTML =
this.responseText;
}
};
var file = document.getElementById('input').files[0];
//http-get call video-shots gcp function
xhttp.open("GET", "https://europe-west1-sm5-hackaton.cloudfunctions.net/function-1?video="+document.getElementById('input').files[0].name, true);
xhttp.send();
}
</script>
<script>
//funció que carrega contingut html a partir de una crida a una funcio GCP. Passem com a paràmetre el nom del arxiu.
function loadDoc2() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
//load the labbels in "demo2"
document.getElementById("demo2").innerHTML =
this.responseText;
}
};
var file = document.getElementById('input').files[0];
//http-get call video-labelling gcp function. Passem com a paràmetre el nom del arxiu.
xhttp.open("GET", "https://europe-west1-sm5-hackaton.cloudfunctions.net/function-3?video="+document.getElementById('input').files[0].name, true);
xhttp.send();
}
</script>
<script>
//funció que carrega contingut html a partir de una crida a una funcio GCP
function loadDoc3() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
//si obtenim resposta, confirmem que els subtítuls s'han generat correctament.
document.getElementById("demo3").innerHTML ="Los subtitulos se han generado correctamente";
}
};
var file = document.getElementById('input').files[0];
//crida a la funció speech2text de gcp per generar subtítols. Passem com a paràmetres el nom de l'arxiu i addicionalment l'idioma.
xhttp.open("GET", "https://europe-west1-sm5-hackaton.cloudfunctions.net/Speech2text?video="+document.getElementById('input').files[0].name+"&language="+document.getElementById('language').value, true);
xhttp.send();
return false;
}
</script>
<script>
//funció que carrega contingut html a partir de una crida a una funcio GCP
function loadDoc4() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("demo4").innerHTML =this.responseText;
}
};
var file = document.getElementById('input').files[0];
//crida a la funció2 que permet realitzar la fusió del video amb els subtítols.
xhttp.open("GET", "https://europe-west2-sm5-hackaton.cloudfunctions.net/function-2?video="+document.getElementById('input').files[0].name, true);
xhttp.send();
}
</script>
<script>
function loadDoc5() {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("demo5").innerHTML ="Los subtitulos se han traducido correctamente";
}
};
var file = document.getElementById('input').files[0];
//crida a la funció Translation de GCP. Passem com a paràmetre l'arxiu i l'idioma de traducció
xhttp.open("GET", "https://us-central1-sm5-hackaton.cloudfunctions.net/Translation?video="+document.getElementById('input').files[0].name+"&language="+document.getElementById('languagetrad').value, true);
xhttp.send();
return false;
}
</script>
<div id="message">
<h2>Welcome to Video Modifiers</h2>
<h1>Tratamiento de vídeo via Google VideoIntelligence API2</h1>
</div>
<script src="https://www.gstatic.com/firebasejs/8.4.2/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.4.2/firebase-storage.js"></script>
<div id="botones">
<input type="file" id="input" multiple />
<button id="b1" onclick="upload()">Subir archivo para ser analizado </button>
</div>
<div id="botones">
<p>Mostrar los frames claves del video:</p>
<button type="button" onclick="loadDoc()">Mostrar frames</button>
</div>
<div id="demo">
<h1></h1>
</div>
<div id="botones">
<p>Etiquetar el video segun su contenido:</p>
<button type="button" onclick="loadDoc2()">Etiquetas del vídeo</button>
</div>
<div id="demo2">
<h1></h1>
</div>
<div id="botones">
<p>Selecciona el idioma del video para generar subtitulos (Puede tardar algunos minutos):</p>
<select id="language" name="language">
<option value="en-GB" selected = "selected">Ingles</option>
<option value="es-US">Español</option>
<option value="it-IT">Italiano</option>
<option value="de-DE">Aleman</option>
<option value="fr-FR">Francés</option>
</select>
<button type="button" onclick="loadDoc3()">Generar subtítulos</button>
</div>
<div id="demo3">
<h1></h1>
</div>
<div id="botones">
<p>Selecciona el idioma al que traducir los subtitulos del video:</p>
<select id="languagetrad" name="languagetrad">
<option value="en-GB" selected = "selected">Ingles</option>
<option value="es-US">Español</option>
<option value="it-IT">Italiano</option>
<option value="de-DE">Aleman</option>
<option value="fr-FR">Francés</option>
</select>
<button type="button" onclick="loadDoc5()">Traducir subtítulos</button>
</div>
<div id="demo5">
<h1></h1>
</div>
<div id="botones">
<p>Generar video con subtitulos (Puede tardar algunos minutos):</p>
<button type="button" onclick="loadDoc4()">Fusionar subtítulos y video</button>
</div>
<div id="demo4">
<h1></h1>
</div>
<div id="botones">
<button type="button" onclick="update_vid()">Actualizar vídeo</button>
</div>
<div id="botones">
<h1></h1>
<video id="myVideo" width="320" height="240" controls>
<source src="" type="video/mp4">
<track default id="mytrack" src="" />
Your browser does not support the video tag.
</video>
<script>
//funció per actualitzar el video una vegada s'han efectuat els canvis, com per exemple la fusió de subtítols amb el v
function update_vid()
{
file=document.getElementById('input').files[0].name
name=file.substr(0, file.lastIndexOf('.'))
document.getElementById("myVideo").src = 'https://firebasestorage.googleapis.com/v0/b/sm5-hackaton.appspot.com/o/video%2F'+name+"_subs.mp4?alt=media";
document.getElementById("myVideo").load();
}
</script>
<script>
document.addEventListener('DOMContentLoaded', function() {
try {
let app = firebase.app();
let features = [
'auth',
'database',
'firestore',
'functions',
'messaging',
'storage',
'analytics',
'remoteConfig',
'performance',
].filter(feature => typeof app[feature] === 'function');
} catch (e) {
console.error(e);
loadEl.textContent = 'Error loading the Firebase SDK, check the console.';
}
});
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "AIzaSyBX8Fh-1PyWPbj2s4lqr5IpODigldwsXZ0",
authDomain: "sm5-hackaton.firebaseapp.com",
projectId: "sm5-hackaton",
storageBucket: "sm5-hackaton.appspot.com",
messagingSenderId: "499343893697",
appId: "1:499343893697:web:a1d26eba4101031bca2040"
};
</script>
<script>
function upload(){
// Get a reference to the storage service, which is used to create references in your storage bucket
var storage = firebase.storage();
// Create a root reference
//var storageRef = firebase.storage().ref('me/' + file.name);
var storageRef = firebase.storage().ref();
var file = document.getElementById('input').files[0];
console.log(file);
// Create a reference to 'mountains.jpg'
var thisRef = storageRef.child(file.name);
// Create a reference to 'images/mountains.jpg'
//var mountainImagesRef = storageRef.child('images/mountains.jpg');
//console.log(file);
var metadata = {
contentType: 'video/mpeg-4'
};
// Upload file and metadata to the object 'images/mountains.jpg'
var uploadTask = storageRef.child('video/' + file.name).put(file, metadata);
// Listen for state changes, errors, and completion of the upload.
uploadTask.on(firebase.storage.TaskEvent.STATE_CHANGED, // or 'state_changed'
function(snapshot) {
// Get task progress, including the number of bytes uploaded and the total number of bytes to be uploaded
var progress = (snapshot.bytesTransferred / snapshot.totalBytes) * 100;
console.log('Upload is ' + progress + '% done');
switch (snapshot.state) {
case firebase.storage.TaskState.PAUSED: // or 'paused'
console.log('Upload is paused');
break;
case firebase.storage.TaskState.RUNNING: // or 'running'
console.log('Upload is running');
break;
}
},
function(error) {
// A full list of error codes is available at
// https://firebase.google.com/docs/storage/web/handle-errors
switch (error.code) {
case 'storage/unauthorized':
// User doesn't have permission to access the object
break;
case 'storage/canceled':
// User canceled the upload
break;
case 'storage/unknown':
// Unknown error occurred, inspect error.serverResponse
break;
}
},
function() {
// Upload completed successfully, now we can get the download URL
uploadTask.snapshot.ref.getDownloadURL().then(function(downloadURL) {
console.log('File available at', downloadURL);
document.getElementById("myVideo").src = downloadUrl;
});
});
}
</script>
</div>
</body>
</html>