Commit 45250ccd5487fb2d45bffab5c06e7cf378c338e2
1 parent
bf6e1b73
Exists in
master
and in
2 other branches
Remove acoplamento com a web. Transcodifica para MP4. Gera thumbnail.
Showing
11 changed files
with
142 additions
and
251 deletions
Show diff stats
main.cpp
... | ... | @@ -35,12 +35,7 @@ void help(); |
35 | 35 | void fail(string msg); |
36 | 36 | void hasFailed(); |
37 | 37 | void hasInvalid(); |
38 | -string createFileToResponse(char* id); | |
39 | -void updateRequestStatus(const char* filename, char* id, char* status); | |
40 | -string createFileToRespWeb(char* id); | |
41 | -void updateRequestStatusWeb(const char* filename, char* id, char* status); | |
42 | 38 | |
43 | -string filename; | |
44 | 39 | bool isFailed; |
45 | 40 | bool isInvalid; |
46 | 41 | |
... | ... | @@ -158,8 +153,6 @@ void serviceCC(){ |
158 | 153 | void serviceREC(char* path_video, char* sublanguage, |
159 | 154 | char* position, char* size, char* transparency, char* id, char* rate){ |
160 | 155 | |
161 | - filename = createFileToResponse(id); | |
162 | - | |
163 | 156 | ServiceWindowGenerationFromREC * service_rec; |
164 | 157 | service_rec = new ServiceWindowGenerationFromREC( |
165 | 158 | path_video, |
... | ... | @@ -179,15 +172,12 @@ void serviceREC(char* path_video, char* sublanguage, |
179 | 172 | while(service_rec->isRunning()){ |
180 | 173 | sleep(2); |
181 | 174 | } |
182 | - updateRequestStatus(filename.c_str(), id, "true"); | |
183 | 175 | delete service_rec; |
184 | 176 | } |
185 | 177 | |
186 | 178 | void serviceREC(char* path_video, char* sublanguage, |
187 | 179 | char* position, char* size, char* transparency, char* id){ |
188 | 180 | |
189 | - filename = createFileToResponse(id); | |
190 | - | |
191 | 181 | ServiceWindowGenerationFromREC * service_rec; |
192 | 182 | service_rec = new ServiceWindowGenerationFromREC( |
193 | 183 | path_video, |
... | ... | @@ -207,14 +197,12 @@ void serviceREC(char* path_video, char* sublanguage, |
207 | 197 | while(service_rec->isRunning()){ |
208 | 198 | sleep(2); |
209 | 199 | } |
210 | - updateRequestStatus(filename.c_str(), id, "true"); | |
211 | 200 | delete service_rec; |
212 | 201 | } |
213 | 202 | |
214 | 203 | void serviceSRT(char* path_in, char* path_srt, char* sublanguage, |
215 | 204 | char* position, char* size, char* transparency, char* id){ |
216 | 205 | |
217 | - filename = createFileToResponse(id); | |
218 | 206 | |
219 | 207 | ServiceWindowGenerationFromSRT * service_srt; |
220 | 208 | service_srt = new ServiceWindowGenerationFromSRT( |
... | ... | @@ -233,14 +221,12 @@ void serviceSRT(char* path_in, char* path_srt, char* sublanguage, |
233 | 221 | sleep(5); |
234 | 222 | } |
235 | 223 | |
236 | - updateRequestStatus(filename.c_str(), id, "true"); | |
237 | 224 | delete service_srt; |
238 | 225 | |
239 | 226 | } |
240 | 227 | |
241 | 228 | void serviceText(char* path_text, char* transparency, char* id, char* client_type){ |
242 | 229 | |
243 | - //filename = createFileToRespWeb(id); | |
244 | 230 | if (strcmp(client_type, (char*)"WEB") == 0) { |
245 | 231 | ServiceWindowGenerationFromText *service_text; |
246 | 232 | service_text = new ServiceWindowGenerationFromText(path_text, id, (int) atoi(transparency), 4, client_type); |
... | ... | @@ -255,11 +241,10 @@ void serviceText(char* path_text, char* transparency, char* id, char* client_typ |
255 | 241 | while (service_text->isAlive()) { |
256 | 242 | usleep(100000); //100ms |
257 | 243 | } |
258 | - //updateRequestStatusWeb(filename.c_str(), id, "true"); | |
259 | 244 | delete service_text; |
260 | 245 | |
261 | 246 | } else { |
262 | - printf("ServicoIOS\n"); | |
247 | + | |
263 | 248 | ServiceWindowGenerationFromText *service_text; |
264 | 249 | service_text = new ServiceWindowGenerationFromText(path_text, id, (int) atoi(transparency), 4, (char*)"IOS"); |
265 | 250 | try{ |
... | ... | @@ -273,16 +258,13 @@ void serviceText(char* path_text, char* transparency, char* id, char* client_typ |
273 | 258 | while (service_text->isAlive()) { |
274 | 259 | usleep(100000); //100ms |
275 | 260 | } |
276 | - //updateRequestStatusWeb(filename.c_str(), id, "true"); | |
277 | 261 | delete service_text; |
278 | - | |
279 | 262 | } |
280 | 263 | |
281 | 264 | } |
282 | 265 | |
283 | 266 | void serviceOnlySRT(char* path_file, char* transparency, char* id){ |
284 | 267 | |
285 | - //filename = createFileToRespWeb(id); | |
286 | 268 | |
287 | 269 | ServiceWindowGenerationFromSRT * service_srt; |
288 | 270 | service_srt = new ServiceWindowGenerationFromSRT(path_file, (int) atoi(transparency), id, 5); |
... | ... | @@ -382,72 +364,3 @@ void help() { |
382 | 364 | |
383 | 365 | } |
384 | 366 | |
385 | - | |
386 | -string createFileToRespWeb(char* id) { | |
387 | - | |
388 | - FILE* file; | |
389 | - string filename = "web-content/"; | |
390 | - filename += id; | |
391 | - filename += ".xml"; | |
392 | - file = fopen(filename.c_str(), "w+"); | |
393 | - string content_file = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<request>\n\t<id>"; | |
394 | - content_file += id; | |
395 | - content_file += "</id>\n\t<finished>false</finished>\n</request>"; | |
396 | - const char *textchar = content_file.c_str(); | |
397 | - fwrite(textchar, 1, content_file.size(), file); | |
398 | - fclose(file); | |
399 | - return filename; | |
400 | - | |
401 | -} | |
402 | - | |
403 | -void updateRequestStatusWeb(const char* filename, char* id, char* status){ | |
404 | - | |
405 | - //printf("\nupdateRequestStatusWeb: id = %s\n", id); | |
406 | - | |
407 | - FILE *file = fopen(filename, "w+"); | |
408 | - string content = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<request>\n\t<id>"; | |
409 | - content += id; | |
410 | - content += "</id>\n\t<finished>"; | |
411 | - content += status; | |
412 | - content += "</finished>\n</request>"; | |
413 | - const char *textchar = content.c_str(); | |
414 | - fwrite(textchar, 1, content.size(), file); | |
415 | - fclose(file); | |
416 | - | |
417 | -} | |
418 | - | |
419 | -string createFileToResponse(char *id){ | |
420 | - | |
421 | - FILE *arquivofinish; | |
422 | - string namearq = "vlibras_user/vlibras-web/public/uploads/videos/"; | |
423 | - namearq += id; | |
424 | - namearq += "/"; | |
425 | - namearq += id; | |
426 | - namearq += ".xml"; | |
427 | - | |
428 | - arquivofinish = fopen(namearq.c_str(), "w+"); | |
429 | - string arqtext = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<request>\n\t<id>"; | |
430 | - arqtext += id; | |
431 | - arqtext += "</id>\n\t<finished>false</finished>\n</request>"; | |
432 | - const char *textchar = arqtext.c_str(); | |
433 | - fwrite(textchar, 1, arqtext.size(), arquivofinish); | |
434 | - fclose(arquivofinish); | |
435 | - | |
436 | - return namearq; | |
437 | - | |
438 | -} | |
439 | - | |
440 | -void updateRequestStatus(const char* filename, char* id, char* status){ | |
441 | - | |
442 | - FILE *arquivofinish = fopen(filename, "w+"); | |
443 | - string arqtext = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<request>\n\t<id>"; | |
444 | - arqtext += id; | |
445 | - arqtext += "</id>\n\t<finished>"; | |
446 | - arqtext += status; | |
447 | - arqtext += "</finished>\n</request>"; | |
448 | - const char *textchar = arqtext.c_str(); | |
449 | - fwrite(textchar, 1, arqtext.size(), arquivofinish); | |
450 | - fclose(arquivofinish); | |
451 | - | |
452 | -} | |
453 | - | ... | ... |
mixer/src/Mixer.cpp
... | ... | @@ -6,11 +6,10 @@ |
6 | 6 | */ |
7 | 7 | |
8 | 8 | #include "Mixer.h" |
9 | - | |
9 | +#define PATH_API "vlibras_user/vlibras-api/videos/" | |
10 | 10 | |
11 | 11 | using namespace std; |
12 | 12 | |
13 | - | |
14 | 13 | /* Construtores e destrutores...*/ |
15 | 14 | Mixer::Mixer() { |
16 | 15 | this->setNumThreads("1"); |
... | ... | @@ -35,7 +34,7 @@ void Mixer::initialize(string mainVideo, string slVideo, int positionSecondaryVi |
35 | 34 | |
36 | 35 | stringstream ss; |
37 | 36 | ss << _id; |
38 | - ss >> this->user_id; | |
37 | + ss >> user_id; | |
39 | 38 | |
40 | 39 | this->setMainVideo(mainVideo); |
41 | 40 | this->setSecondaryVideo(slVideo); |
... | ... | @@ -45,6 +44,7 @@ void Mixer::initialize(string mainVideo, string slVideo, int positionSecondaryVi |
45 | 44 | this->setSize(sizeSecondaryVideo); |
46 | 45 | this->setPositionSecondaryVideo(positionSecondaryVideo); |
47 | 46 | this->setTransparency(transparency); |
47 | + this->setPathFinal(); | |
48 | 48 | this->mixVideos(); |
49 | 49 | |
50 | 50 | } |
... | ... | @@ -103,8 +103,6 @@ void Mixer::mixVideos () { |
103 | 103 | else |
104 | 104 | transparency = "transp"; |
105 | 105 | |
106 | - setPathFinal(nameOfMainVideo); | |
107 | - | |
108 | 106 | /*string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -y -vf \"movie="+this->secondaryVideo+", "+ |
109 | 107 | "scale="+ num1String +":"+num2String+", setpts=PTS-STARTPTS [movie]; "+ |
110 | 108 | "[in] setpts=PTS-STARTPTS, [movie] overlay"+transparency+"="+strPosition+ |
... | ... | @@ -120,10 +118,17 @@ void Mixer::mixVideos () { |
120 | 118 | "scale="+ num1String +":"+num2String+", [movie] overlay"+transparency+"="+strPosition+ |
121 | 119 | " [out]\" -sameq -ar 22050 -ab 32 -f flv -acodec pcm_s16le -vcodec flv -threads "+this->numThreads+" "+nameOfMainVideo+"_Libras.flv";*/ |
122 | 120 | |
121 | + //TRANSCODIFICAR PARA FLV | |
122 | + string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -y -vf \"movie="+this->secondaryVideo+", "+ | |
123 | + "scale="+ num1String +":"+num2String+", setpts=PTS-STARTPTS, [movie] overlay"+transparency+"="+strPosition+ | |
124 | + " [out]\" -sameq -strict experimental -vcodec mpeg2video -r 30 -threads "+this->numThreads+" "+pathFinal; | |
125 | + | |
123 | 126 | |
124 | - string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -y -vf \"movie="+this->secondaryVideo+", "+ | |
127 | + /* | |
128 | + string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -y -vf \"movie="+this->secondaryVideo+", "+ | |
125 | 129 | "scale="+ num1String +":"+num2String+", setpts=PTS-STARTPTS, [movie] overlay"+transparency+"="+strPosition+ |
126 | - " [out]\" -sameq -ar 22050 -ab 32 -f flv -acodec pcm_s16le -vcodec flv -threads "+this->numThreads+" "+getPathFinal(); | |
130 | + " [out]\" -sameq -threads "+this->numThreads+" "+pathFinal; | |
131 | + */ | |
127 | 132 | |
128 | 133 | /* |
129 | 134 | convertendo e obtendo ótimos resultados de tamanho do vídeo |
... | ... | @@ -137,15 +142,9 @@ void Mixer::mixVideos () { |
137 | 142 | //system(removeVideoCMD.c_str()); |
138 | 143 | } |
139 | 144 | |
140 | -void Mixer::setPathFinal(string path){ | |
141 | - pathFinal = path+"_Libras.flv"; | |
142 | - | |
143 | -} | |
144 | - | |
145 | -string Mixer::getPathFinal(){ | |
146 | - //char* path = new char[pathFinal.size()+1]; | |
147 | - //strcpy(path, (char*) pathFinal.c_str()); | |
148 | - return pathFinal; | |
145 | +void Mixer::setPathFinal(){ | |
146 | + pathFinal = PATH_API; | |
147 | + pathFinal.append(user_id).append(".mp4"); | |
149 | 148 | } |
150 | 149 | |
151 | 150 | /*Ajusta o FPS do vídeo principal para 45 se preciso...*/ |
... | ... | @@ -312,7 +311,7 @@ void Mixer::setMainVideo(string mainVideo){ |
312 | 311 | } |
313 | 312 | //ajeitar isso depois |
314 | 313 | string nameOfMainVideo = mainVideo.substr(0, dotPosition); |
315 | - this->temporaryTextFile = "vlibras_user/vlibras-web/public/uploads/videos/"; | |
314 | + this->temporaryTextFile = "vlibras_user/vlibras-api/uploads/"; | |
316 | 315 | temporaryTextFile.append(this->user_id).append("/tamanho.txt"); |
317 | 316 | |
318 | 317 | //printf("##########temporaryTextFile: %s\n", temporaryTextFile.c_str()); | ... | ... |
mixer/src/include/Mixer.h
... | ... | @@ -66,10 +66,7 @@ public: |
66 | 66 | void setNumThreads(string); |
67 | 67 | string getNumThreads(); |
68 | 68 | void initialize(string mainVideo, string slVideo, int, int, int, char*); |
69 | - void setPathFinal(string path); | |
70 | - string getPathFinal(); | |
71 | - | |
72 | - | |
69 | + void setPathFinal(); | |
73 | 70 | |
74 | 71 | private: |
75 | 72 | ... | ... |
recognize/src/recognize.cpp
... | ... | @@ -20,7 +20,7 @@ |
20 | 20 | #define SIZE_BUFFER 256 |
21 | 21 | #define CONFIDENCE_RATE 0.45 |
22 | 22 | |
23 | -#define PATH_GTAAAS_WEB "vlibras_user/vlibras-web/public/uploads/videos/" | |
23 | +#define PATH_API_UPLOADS "vlibras_user/vlibras-api/uploads/" | |
24 | 24 | #define PATH_AUDIO_ORIGIN "/audio/origin/audio_origin.wav" |
25 | 25 | #define PATH_AUDIO_PARTS "/audio/parts/" |
26 | 26 | #define FILENAME_RECOGNIZED_OUT "/audio/recognized.out" |
... | ... | @@ -119,7 +119,7 @@ void Recognize::Run(){ |
119 | 119 | executeJuliusEngine(); |
120 | 120 | generateConfidence(); |
121 | 121 | filterOutputJulius(); |
122 | - cleanFiles(); | |
122 | + //cleanFiles(); | |
123 | 123 | |
124 | 124 | finished = true; |
125 | 125 | notifyEndExtraction(count_lines); |
... | ... | @@ -150,7 +150,7 @@ char* Recognize::extractAudioFromVideo() { |
150 | 150 | //command.append(strFreq).append(" -ac 1 -f wav ").append(PATH_AUDIO_ORIGIN).append(" &"); |
151 | 151 | command.append(strFreq). |
152 | 152 | append(" -ac 1 -f wav "). |
153 | - append(PATH_GTAAAS_WEB). | |
153 | + append(PATH_API_UPLOADS). | |
154 | 154 | append(id). |
155 | 155 | append(PATH_AUDIO_ORIGIN). |
156 | 156 | |
... | ... | @@ -168,7 +168,7 @@ char* Recognize::extractAudioFromVideo() { |
168 | 168 | int Recognize::getTimeMediaSec() { |
169 | 169 | |
170 | 170 | string command = PROGRAM; |
171 | - command.append(" -i ").append(PATH_GTAAAS_WEB).append(id).append(PATH_AUDIO_ORIGIN); | |
171 | + command.append(" -i ").append(PATH_API_UPLOADS).append(id).append(PATH_AUDIO_ORIGIN); | |
172 | 172 | command.append(" 2>&1 | grep Duration >> outfile"); |
173 | 173 | system(command.c_str()); |
174 | 174 | |
... | ... | @@ -230,7 +230,7 @@ void Recognize::breakVideoParts(int timeTotal) { |
230 | 230 | pts.push_back(convert_pts(ss_str)); |
231 | 231 | |
232 | 232 | command = "sox "; |
233 | - command.append(PATH_GTAAAS_WEB).append(id).append(PATH_AUDIO_ORIGIN).append(" ").append(PATH_GTAAAS_WEB).append(id).append(PATH_AUDIO_PARTS); | |
233 | + command.append(PATH_API_UPLOADS).append(id).append(PATH_AUDIO_ORIGIN).append(" ").append(PATH_API_UPLOADS).append(id).append(PATH_AUDIO_PARTS); | |
234 | 234 | sprintf(tmp, "%i", count++); |
235 | 235 | filename.append(tmp).append(".wav"); |
236 | 236 | command.append(filename).append(" trim ").append(ss_str).append(" ").append(t_str); |
... | ... | @@ -238,7 +238,7 @@ void Recognize::breakVideoParts(int timeTotal) { |
238 | 238 | system(command.c_str()); |
239 | 239 | |
240 | 240 | string apcomm = "echo "; |
241 | - apcomm.append(PATH_GTAAAS_WEB).append(id).append(PATH_AUDIO_PARTS).append(filename).append(" >> ").append(PATH_GTAAAS_WEB).append(id).append(FILENAME_AUDIOLIST); | |
241 | + apcomm.append(PATH_API_UPLOADS).append(id).append(PATH_AUDIO_PARTS).append(filename).append(" >> ").append(PATH_API_UPLOADS).append(id).append(FILENAME_AUDIOLIST); | |
242 | 242 | system(apcomm.c_str()); |
243 | 243 | |
244 | 244 | filename = FILENAME_AUDIOPART; |
... | ... | @@ -257,7 +257,7 @@ void Recognize::executeJuliusEngine() { |
257 | 257 | command = "julius -C vlibras_user/vlibras-core/recognize/src/julius.jconf -input "; |
258 | 258 | if (inputType == 1) { |
259 | 259 | type = "rawfile"; |
260 | - command.append(type).append(" -filelist ").append(PATH_GTAAAS_WEB).append(id).append(FILENAME_AUDIOLIST); | |
260 | + command.append(type).append(" -filelist ").append(PATH_API_UPLOADS).append(id).append(FILENAME_AUDIOLIST); | |
261 | 261 | } else { |
262 | 262 | type = "mic"; |
263 | 263 | } |
... | ... | @@ -265,7 +265,7 @@ void Recognize::executeJuliusEngine() { |
265 | 265 | command.append(" -smpFreq "). |
266 | 266 | append(cfreq). |
267 | 267 | append(" -nolog >> "). |
268 | - append(PATH_GTAAAS_WEB).append(id). | |
268 | + append(PATH_API_UPLOADS).append(id). | |
269 | 269 | append(FILENAME_RECOGNIZED_OUT); |
270 | 270 | |
271 | 271 | //Command of execute Julius |
... | ... | @@ -277,14 +277,14 @@ void Recognize::executeJuliusEngine() { |
277 | 277 | void Recognize::generateConfidence() { |
278 | 278 | |
279 | 279 | string command = "cat "; |
280 | - command.append(PATH_GTAAAS_WEB).append(id).append(FILENAME_RECOGNIZED_OUT).append(" | grep "). | |
281 | - append(FIND_CONFIDENCE).append(" >> ").append(PATH_GTAAAS_WEB).append(id).append(FILENAME_CONFIDENCEOUT); | |
280 | + command.append(PATH_API_UPLOADS).append(id).append(FILENAME_RECOGNIZED_OUT).append(" | grep "). | |
281 | + append(FIND_CONFIDENCE).append(" >> ").append(PATH_API_UPLOADS).append(id).append(FILENAME_CONFIDENCEOUT); | |
282 | 282 | |
283 | 283 | system(command.c_str()); |
284 | 284 | //printf("\n\n---> command: %s\n\n", command.c_str()); |
285 | 285 | |
286 | 286 | string path; |
287 | - path.append(PATH_GTAAAS_WEB).append(id).append(FILENAME_CONFIDENCEOUT); | |
287 | + path.append(PATH_API_UPLOADS).append(id).append(FILENAME_CONFIDENCEOUT); | |
288 | 288 | ifstream in(path.c_str()); |
289 | 289 | |
290 | 290 | if (!in) { |
... | ... | @@ -344,8 +344,8 @@ void Recognize::filterOutputJulius() { |
344 | 344 | sentences = new std::list<char*>(); |
345 | 345 | |
346 | 346 | string command = "cat "; |
347 | - command.append(PATH_GTAAAS_WEB).append(id).append(FILENAME_RECOGNIZED_OUT).append(" | grep -e "). | |
348 | - append(FIND_SENTENCE).append(" -e \"").append(AUDIO_SILENT).append("\"").append(" >> ").append(PATH_GTAAAS_WEB).append(id).append(FILENAME_FILTEROUT); | |
347 | + command.append(PATH_API_UPLOADS).append(id).append(FILENAME_RECOGNIZED_OUT).append(" | grep -e "). | |
348 | + append(FIND_SENTENCE).append(" -e \"").append(AUDIO_SILENT).append("\"").append(" >> ").append(PATH_API_UPLOADS).append(id).append(FILENAME_FILTEROUT); | |
349 | 349 | |
350 | 350 | system(command.c_str()); |
351 | 351 | //printf("\n\n---> command: %s\n\n", command.c_str()); |
... | ... | @@ -353,7 +353,7 @@ void Recognize::filterOutputJulius() { |
353 | 353 | count_lines = 0; |
354 | 354 | |
355 | 355 | string path; |
356 | - path.append(PATH_GTAAAS_WEB).append(id).append(FILENAME_FILTEROUT); | |
356 | + path.append(PATH_API_UPLOADS).append(id).append(FILENAME_FILTEROUT); | |
357 | 357 | ifstream in(path.c_str()); |
358 | 358 | string strFilter; |
359 | 359 | |
... | ... | @@ -437,15 +437,15 @@ bool Recognize::isFinished() { |
437 | 437 | void Recognize::cleanFiles() { |
438 | 438 | |
439 | 439 | string command = "rm -r "; |
440 | - command.append(PATH_GTAAAS_WEB).append(id).append("/audio"); | |
440 | + command.append(PATH_API_UPLOADS).append(id).append("/audio"); | |
441 | 441 | system(command.c_str()); |
442 | 442 | } |
443 | 443 | |
444 | 444 | void Recognize::createDir(){ |
445 | 445 | |
446 | 446 | string command = "mkdir "; |
447 | - command.append(PATH_GTAAAS_WEB).append(id).append("/audio").append(" && mkdir "). | |
448 | - append(PATH_GTAAAS_WEB).append(id).append("/audio/parts").append(" && mkdir "). | |
449 | - append(PATH_GTAAAS_WEB).append(id).append("/audio/origin"); | |
447 | + command.append(PATH_API_UPLOADS).append(id).append("/audio").append(" && mkdir "). | |
448 | + append(PATH_API_UPLOADS).append(id).append("/audio/parts").append(" && mkdir "). | |
449 | + append(PATH_API_UPLOADS).append(id).append("/audio/origin"); | |
450 | 450 | system(command.c_str()); |
451 | 451 | } | ... | ... |
servico/src/include/serviceWindowGeneration.h
... | ... | @@ -53,6 +53,8 @@ protected: |
53 | 53 | char* path_input; |
54 | 54 | char* path_audio; |
55 | 55 | char* path_libras; |
56 | + char* client_type; | |
57 | + | |
56 | 58 | bool running; |
57 | 59 | |
58 | 60 | bool finish; |
... | ... | @@ -66,11 +68,12 @@ protected: |
66 | 68 | void setSubLanguage(int sublang); |
67 | 69 | void setServiceType(int type); |
68 | 70 | void setUserId(char* _userId); |
71 | + void setClientType(char* client_type); | |
72 | + void setPathInput(char* _path_input); | |
69 | 73 | |
70 | - //TEMP | |
71 | - void sendFileToPath(string source); | |
72 | - | |
73 | - void transcodeVideoToFlv(); | |
74 | + void transcodeVideoToWebm(); | |
75 | + void transcodeVideoToMp4(); | |
76 | + void createThumbnail(); | |
74 | 77 | |
75 | 78 | public: |
76 | 79 | |
... | ... | @@ -88,7 +91,10 @@ public: |
88 | 91 | |
89 | 92 | char* getPathLibras(); |
90 | 93 | char* getUserId(); |
91 | - void setPathLibras(char* _path_libras); | |
94 | + char* getClientType(); | |
95 | + char* getPathInput(); | |
96 | + string getPathAPI(); | |
97 | + void setPathLibras(); | |
92 | 98 | void setSizeOfSubtitles(int sub_size); |
93 | 99 | }; |
94 | 100 | ... | ... |
servico/src/include/serviceWindowGenerationFromSRT.h
... | ... | @@ -45,8 +45,7 @@ public: |
45 | 45 | |
46 | 46 | void notificaSincronizadorSemTradutor(unsigned char *legenda, int64_t pts); |
47 | 47 | void initialize(); |
48 | - void setPathInput(char* path_video, char* path_srt); | |
49 | - void setPathInput(char* path_srt); | |
48 | + void setPathSRT(char* path_srt); | |
50 | 49 | void Run(); |
51 | 50 | |
52 | 51 | }; | ... | ... |
servico/src/include/serviceWindowGenerationFromText.h
... | ... | @@ -13,10 +13,7 @@ class ServiceWindowGenerationFromText : public ServiceWindowGeneration, public L |
13 | 13 | |
14 | 14 | private: |
15 | 15 | ExtratorTXT * extratorTXT; |
16 | - char* path_file; | |
17 | 16 | bool alive; |
18 | - char* client_type; | |
19 | - char* id; | |
20 | 17 | |
21 | 18 | public: |
22 | 19 | ServiceWindowGenerationFromText (char* _path_file, char* _video_path_file, |
... | ... | @@ -27,8 +24,6 @@ public: |
27 | 24 | void initialize(); |
28 | 25 | bool isAlive(); |
29 | 26 | void Run(); |
30 | - void transcodeVideoToWebm(); | |
31 | - void transcodeVideoToAvi(); | |
32 | 27 | }; |
33 | 28 | |
34 | 29 | #endif /* _SERVICEWINDOWGENERATIONFROMTEXT_H */ | ... | ... |
servico/src/serviceWindowGeneration.cpp
... | ... | @@ -5,7 +5,9 @@ |
5 | 5 | #define BASEDIR "vlibras_user/dicionario_libras/" |
6 | 6 | #define BASEDIRTRANSP "vlibras_user/dicionarioTransp_libras/" |
7 | 7 | #define EXTENSAO_DICIONARIO ".ts" |
8 | -#define FINAL_DESTINATION_API "vlibras_user/vlibras-api/videos/" | |
8 | +#define PATH_API "vlibras_user/vlibras-api/videos/" | |
9 | +#define MAX_SIZE_PATH 256 | |
10 | + | |
9 | 11 | |
10 | 12 | ServiceWindowGeneration::ServiceWindowGeneration() { |
11 | 13 | if (getRunningOption() != '3') { |
... | ... | @@ -47,9 +49,9 @@ void ServiceWindowGeneration::finalizouSincronizacao() { |
47 | 49 | if (getRunningOption() != '2' && serviceType != SERVICE_TYPE_TEXT && serviceType != SERVICE_TYPE_SRT_ONLY) { |
48 | 50 | mixer = new Mixer(); |
49 | 51 | mixer->initialize(this->path_input, this->path_libras,this->position,this->size,this->transparency, this->user_id); |
50 | - sendFileToPath(mixer->getPathFinal()); | |
51 | - } | |
52 | - | |
52 | + createThumbnail(); | |
53 | + }else | |
54 | + transcodeVideoToMp4(); | |
53 | 55 | this->running = false; |
54 | 56 | |
55 | 57 | } |
... | ... | @@ -71,19 +73,40 @@ void ServiceWindowGeneration::setSizeOfSubtitles(int sub_size) { |
71 | 73 | } |
72 | 74 | } |
73 | 75 | |
74 | -void ServiceWindowGeneration::setPathLibras(char* _path_libras) { | |
75 | - this->path_libras = _path_libras; | |
76 | - DDPRINTF("Path TS File: %s\n", _path_libras); | |
76 | +void ServiceWindowGeneration::setPathLibras() { | |
77 | + char* final_path = new char[MAX_SIZE_PATH]; | |
78 | + strcpy(final_path, "vlibras_user/vlibras-api/uploads/"); | |
79 | + strcat(final_path, this->user_id); | |
80 | + strcat(final_path, "/libras.ts"); | |
81 | + | |
82 | + this->path_libras = final_path; | |
83 | + //DDPRINTF("Path TS File: %s\n", this->path_libras); | |
77 | 84 | } |
78 | 85 | |
79 | 86 | char* ServiceWindowGeneration::getPathLibras() { |
80 | 87 | return path_libras; |
81 | 88 | } |
82 | 89 | |
90 | +void ServiceWindowGeneration::setPathInput(char* _path_input) { | |
91 | + this->path_input = _path_input; | |
92 | +} | |
93 | + | |
94 | +char* ServiceWindowGeneration::getPathInput() { | |
95 | + return path_input; | |
96 | +} | |
97 | + | |
98 | +string ServiceWindowGeneration::getPathAPI() { | |
99 | + return PATH_API; | |
100 | +} | |
101 | + | |
83 | 102 | void ServiceWindowGeneration::setUserId(char* _userId) { |
84 | 103 | this->user_id = _userId; |
85 | 104 | } |
86 | 105 | |
106 | +char* ServiceWindowGeneration::getClientType(){ | |
107 | + return client_type; | |
108 | +} | |
109 | + | |
87 | 110 | char* ServiceWindowGeneration::getUserId() { |
88 | 111 | return user_id; |
89 | 112 | } |
... | ... | @@ -92,6 +115,10 @@ void ServiceWindowGeneration::setServiceType(int type) { |
92 | 115 | serviceType = type; |
93 | 116 | } |
94 | 117 | |
118 | +void ServiceWindowGeneration::setClientType(char* client_type) { | |
119 | + this->client_type = client_type; | |
120 | +} | |
121 | + | |
95 | 122 | void ServiceWindowGeneration::setSize(int size){ |
96 | 123 | this->size = size; |
97 | 124 | } |
... | ... | @@ -110,6 +137,8 @@ void ServiceWindowGeneration::setSubLanguage(int sublang){ |
110 | 137 | |
111 | 138 | void ServiceWindowGeneration::initialize() { |
112 | 139 | |
140 | + setPathLibras(); | |
141 | + | |
113 | 142 | this->finish = false; |
114 | 143 | if (getRunningOption() != '3' && this->sublanguage == 1) { |
115 | 144 | tradutor->registraOuvinte(this); |
... | ... | @@ -207,26 +236,46 @@ void ServiceWindowGeneration::codifica(vector<string> * glosas) { |
207 | 236 | legendas_enviadas++; |
208 | 237 | } |
209 | 238 | |
210 | -void ServiceWindowGeneration::sendFileToPath(string source){ | |
239 | +void ServiceWindowGeneration::transcodeVideoToWebm() { | |
211 | 240 | |
212 | - string command = "cp "; | |
213 | - command.append(source) | |
214 | - .append(" ").append(FINAL_DESTINATION_API).append(getUserId()).append(".flv") | |
215 | - .append(" && rm ").append(path_libras); | |
216 | - system(command.c_str()); | |
241 | + //printf("[INFO]: A transcodificação para .webm está ativada!\n"); | |
217 | 242 | |
243 | + string command = "ffmpeg -i "; | |
244 | + command.append(path_libras) | |
245 | + .append(" -vcodec libvpx -acodec libvorbis ") | |
246 | + .append(PATH_API) | |
247 | + .append(getUserId()) | |
248 | + .append(".webm"); | |
249 | + //printf("[INFO]: Transcodification command -> %s\n", command.c_str()); | |
250 | + system(command.c_str()); | |
218 | 251 | } |
219 | 252 | |
220 | -void ServiceWindowGeneration::transcodeVideoToFlv(){ | |
253 | +void ServiceWindowGeneration::transcodeVideoToMp4() { | |
221 | 254 | |
222 | - string command = "ffmpeg -i "; | |
223 | - command.append(getPathLibras()) | |
224 | - .append(" -vcodec copy -f flv ") | |
225 | - .append(FINAL_DESTINATION_API).append(user_id).append(".flv") | |
226 | - .append(" && rm ") | |
227 | - .append(getPathLibras()); | |
255 | + if (serviceType == SERVICE_TYPE_TEXT && strcmp(client_type, (char*)"WEB") == 0) | |
256 | + transcodeVideoToWebm(); | |
257 | + else{ | |
258 | + //printf("[INFO]: A transcodificação para .mp4 está ativada!\n"); | |
259 | + string command = "ffmpeg -i "; | |
260 | + command.append(path_libras) | |
261 | + .append(" -strict experimental -vcodec mpeg2video -r 30 ") | |
262 | + .append(PATH_API) | |
263 | + .append(getUserId()) | |
264 | + .append(".mp4"); | |
265 | + //printf("[INFO]: Transcodification command -> %s\n", command.c_str()); | |
266 | + system(command.c_str()); | |
228 | 267 | |
229 | - system(command.c_str()); | |
268 | + //.append(" -strict experimental -vcodec mjpeg -r 30 -pix_fmt yuvj422p ") | |
269 | + | |
270 | + } | |
271 | +} | |
272 | + | |
273 | +void ServiceWindowGeneration::createThumbnail(){ | |
230 | 274 | |
275 | + string command = "ffmpeg -ss 10 -i "; | |
276 | + command.append(getPathInput()) | |
277 | + .append(" -vcodec png -vframes 1 -an -f rawvideo -y -vf scale=200:200 ") | |
278 | + .append(PATH_API).append(user_id).append(".png"); | |
279 | + system(command.c_str()); | |
231 | 280 | } |
232 | 281 | ... | ... |
servico/src/serviceWindowGenerationFromREC.cpp
... | ... | @@ -3,30 +3,30 @@ |
3 | 3 | using namespace std; |
4 | 4 | |
5 | 5 | ServiceWindowGenerationFromREC::ServiceWindowGenerationFromREC( |
6 | - char* path_video, int sublanguage, int position, int size, int transparency, char* id, int _serviceType, char* rate) { | |
6 | + char* path_video, int sublanguage, int position, int size, int transparency, char* id, int serviceType, char* rate) { | |
7 | 7 | |
8 | - path_input = path_video; | |
8 | + setPathInput(path_video); | |
9 | 9 | setSubLanguage(sublanguage); |
10 | 10 | setPosition(position); |
11 | 11 | setSize(size); |
12 | 12 | setTransparency(transparency); |
13 | - setServiceType(_serviceType); | |
13 | + setServiceType(serviceType); | |
14 | 14 | setUserId(id); |
15 | - rec = new Recognize(path_input, id, rate); | |
15 | + rec = new Recognize(path_video, id, rate); | |
16 | 16 | DPRINTF("Done!\n"); |
17 | 17 | } |
18 | 18 | |
19 | 19 | ServiceWindowGenerationFromREC::ServiceWindowGenerationFromREC( |
20 | - char* path_video, int sublanguage, int position, int size, int transparency, char* id, int _serviceType) { | |
20 | + char* path_video, int sublanguage, int position, int size, int transparency, char* id, int serviceType) { | |
21 | 21 | |
22 | - path_input = path_video; | |
22 | + setPathInput(path_video); | |
23 | 23 | setSubLanguage(sublanguage); |
24 | 24 | setPosition(position); |
25 | 25 | setSize(size); |
26 | 26 | setTransparency(transparency); |
27 | - setServiceType(_serviceType); | |
27 | + setServiceType(serviceType); | |
28 | 28 | setUserId(id); |
29 | - rec = new Recognize(path_input, id); | |
29 | + rec = new Recognize(path_video, id); | |
30 | 30 | DPRINTF("Done!\n"); |
31 | 31 | } |
32 | 32 | |
... | ... | @@ -87,6 +87,6 @@ void ServiceWindowGenerationFromREC::notifySynchWithoutTranslator(unsigned char |
87 | 87 | void ServiceWindowGenerationFromREC::Run() { |
88 | 88 | |
89 | 89 | while (!rec->isFinished()) { |
90 | - sleep(2); | |
90 | + sleep(200000); | |
91 | 91 | } |
92 | 92 | } | ... | ... |
servico/src/serviceWindowGenerationFromSRT.cpp
1 | 1 | #include "serviceWindowGenerationFromSRT.h" |
2 | 2 | |
3 | -#define PATH_LIBRAS "vlibras_user/vlibras-api/videos/" | |
4 | - | |
5 | 3 | using namespace std; |
6 | 4 | |
7 | 5 | //Construtor Service 2 |
8 | 6 | ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT( |
9 | - char* path_video, char* path_srt, int sublanguage, int position, int size, int transparency, char* id, int _serviceType) { | |
10 | - setPathInput(path_video, path_srt); | |
7 | + char* path_video, char* path_srt, int sublanguage, int position, int size, int transparency, char* id, int serviceType) { | |
8 | + setPathInput(path_video); | |
9 | + setPathSRT(path_srt); | |
11 | 10 | setPosition(position); |
12 | 11 | setSize(size); |
13 | 12 | setTransparency(transparency); |
14 | 13 | setSubLanguage(sublanguage); |
15 | - setServiceType(_serviceType); | |
14 | + setServiceType(serviceType); | |
16 | 15 | setUserId(id); |
17 | 16 | this->finish = false; |
18 | 17 | DPRINTF("Done!\n"); |
19 | 18 | } |
20 | 19 | |
21 | 20 | //Construtor Service 5 |
22 | -ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* path_srt, int transparency, char* id, int _serviceType){ | |
21 | +ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* path_srt, int transparency, char* id, int serviceType){ | |
23 | 22 | setPathInput(path_srt); |
24 | 23 | setTransparency(transparency); |
25 | - setServiceType(_serviceType); | |
24 | + setServiceType(serviceType); | |
26 | 25 | setUserId(id); |
27 | - | |
28 | - string new_path_libras = PATH_LIBRAS; | |
29 | - new_path_libras.append((string) id).append(".ts"); | |
30 | - char* pathl = new char[strlen(new_path_libras.c_str()) + 1]; | |
31 | - strcpy(pathl, (char*)new_path_libras.c_str()); | |
32 | - setPathLibras(pathl); | |
33 | 26 | finish_srt = false; |
34 | 27 | DPRINTF("Done!\n"); |
35 | 28 | } |
... | ... | @@ -40,12 +33,7 @@ ServiceWindowGenerationFromSRT::~ServiceWindowGenerationFromSRT() { |
40 | 33 | DDDPRINTF("Service SRT finalized!\n"); |
41 | 34 | } |
42 | 35 | |
43 | -void ServiceWindowGenerationFromSRT::setPathInput(char* path_video, char* path_srt) { | |
44 | - this->path_input = path_video; | |
45 | - this->path_srt = path_srt; | |
46 | -} | |
47 | - | |
48 | -void ServiceWindowGenerationFromSRT::setPathInput(char* path_srt){ | |
36 | +void ServiceWindowGenerationFromSRT::setPathSRT(char* path_srt) { | |
49 | 37 | this->path_srt = path_srt; |
50 | 38 | } |
51 | 39 | |
... | ... | @@ -143,7 +131,7 @@ void ServiceWindowGenerationFromSRT::initialize() { |
143 | 131 | monitor_pcr_base = new MonitorPCR(); |
144 | 132 | monitor_pcr_base->addListenerPCRBase(extratorSRT); |
145 | 133 | extratorSRT->addListener(this); |
146 | - extratorSRT->setFilePath((char*) path_srt); | |
134 | + extratorSRT->setFilePath((char*) path_input); | |
147 | 135 | |
148 | 136 | ServiceWindowGeneration::initialize(); |
149 | 137 | |
... | ... | @@ -167,7 +155,4 @@ void ServiceWindowGenerationFromSRT::Run() { |
167 | 155 | usleep(200000); //200ms |
168 | 156 | } |
169 | 157 | finish_srt = true; |
170 | - | |
171 | - if (serviceType == 5) | |
172 | - transcodeVideoToFlv(); | |
173 | 158 | } | ... | ... |
servico/src/serviceWindowGenerationFromText.cpp
1 | - | |
2 | 1 | #include "serviceWindowGenerationFromText.h" |
3 | 2 | |
4 | - | |
5 | -#define PATH_LIBRAS "vlibras_user/vlibras-api/videos/" | |
6 | -#define MAX_SIZE_PATH 256 | |
7 | - | |
8 | 3 | ServiceWindowGenerationFromText::ServiceWindowGenerationFromText ( |
9 | - char* _path_file, char* _username, int _transp, int _serviceType, char* _client_type) { | |
10 | - | |
11 | - path_file = _path_file; | |
12 | - client_type = _client_type; | |
13 | - setUserId(_username); | |
14 | - setTransparency(_transp); | |
15 | - setServiceType(_serviceType); | |
16 | - char* final_path = new char[MAX_SIZE_PATH]; | |
17 | - strcpy(final_path, PATH_LIBRAS); | |
18 | - strcat(final_path, _username); | |
19 | - strcat(final_path, ".ts"); | |
20 | - | |
21 | - setPathLibras(final_path); | |
4 | + char* path_file, char* username, int transp, int serviceType, char* client_type) { | |
22 | 5 | |
6 | + setPathInput(path_file); | |
7 | + setClientType(client_type); | |
8 | + setUserId(username); | |
9 | + setTransparency(transp); | |
10 | + setServiceType(serviceType); | |
23 | 11 | alive = true; |
24 | 12 | DPRINTF("Done!\n"); |
25 | - | |
26 | 13 | } |
27 | 14 | |
28 | 15 | ServiceWindowGenerationFromText::~ServiceWindowGenerationFromText() { |
... | ... | @@ -35,7 +22,7 @@ void ServiceWindowGenerationFromText::initialize() { |
35 | 22 | |
36 | 23 | extratorTXT = new ExtratorTXT(); |
37 | 24 | extratorTXT->addListener(this); |
38 | - extratorTXT->setFilePath((char*) path_file); | |
25 | + extratorTXT->setFilePath(getPathInput()); | |
39 | 26 | |
40 | 27 | ServiceWindowGeneration::initialize(); |
41 | 28 | |
... | ... | @@ -64,44 +51,5 @@ void ServiceWindowGenerationFromText::Run() { |
64 | 51 | while (isRunning()) { |
65 | 52 | usleep(200000); //200ms |
66 | 53 | } |
67 | - if (strcmp(client_type, (char*)"WEB") == 0) { | |
68 | - printf("[INFO]: A transcodificação para .webm está ativada!\n"); | |
69 | - transcodeVideoToWebm(); | |
70 | - } else if (strcmp(client_type, (char*)"IOS") == 0) { | |
71 | - printf("[INFO]: A transcodificação para .avi está ativada!\n"); | |
72 | - | |
73 | - transcodeVideoToAvi(); | |
74 | - } | |
75 | - else | |
76 | - transcodeVideoToFlv(); | |
77 | - | |
78 | 54 | alive = false; |
79 | 55 | } |
80 | - | |
81 | -void ServiceWindowGenerationFromText::transcodeVideoToWebm() { | |
82 | - | |
83 | - string command = "ffmpeg -i "; | |
84 | - command.append(getPathLibras()) | |
85 | - .append(" -vcodec libvpx -acodec libvorbis ") | |
86 | - .append(PATH_LIBRAS) | |
87 | - .append(getUserId()) | |
88 | - .append(".webm") | |
89 | - .append(" && rm ") | |
90 | - .append(getPathLibras()); | |
91 | - //printf("[INFO]: Transcodification command -> %s\n", command.c_str()); | |
92 | - system(command.c_str()); | |
93 | -} | |
94 | - | |
95 | -void ServiceWindowGenerationFromText::transcodeVideoToAvi() { | |
96 | - | |
97 | - string command = "ffmpeg -i "; | |
98 | - command.append(getPathLibras()) | |
99 | - .append(" -vcodec mjpeg -r 30 -pix_fmt yuvj422p ") | |
100 | - .append(PATH_LIBRAS) | |
101 | - .append(getUserId()) | |
102 | - .append(".mp4") | |
103 | - .append(" && rm ") | |
104 | - .append(getPathLibras()); | |
105 | - //printf("[INFO]: Transcodification command -> %s\n", command.c_str()); | |
106 | - system(command.c_str()); | |
107 | -} | ... | ... |