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,12 +35,7 @@ void help(); | ||
| 35 | void fail(string msg); | 35 | void fail(string msg); |
| 36 | void hasFailed(); | 36 | void hasFailed(); |
| 37 | void hasInvalid(); | 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 | bool isFailed; | 39 | bool isFailed; |
| 45 | bool isInvalid; | 40 | bool isInvalid; |
| 46 | 41 | ||
| @@ -158,8 +153,6 @@ void serviceCC(){ | @@ -158,8 +153,6 @@ void serviceCC(){ | ||
| 158 | void serviceREC(char* path_video, char* sublanguage, | 153 | void serviceREC(char* path_video, char* sublanguage, |
| 159 | char* position, char* size, char* transparency, char* id, char* rate){ | 154 | char* position, char* size, char* transparency, char* id, char* rate){ |
| 160 | 155 | ||
| 161 | - filename = createFileToResponse(id); | ||
| 162 | - | ||
| 163 | ServiceWindowGenerationFromREC * service_rec; | 156 | ServiceWindowGenerationFromREC * service_rec; |
| 164 | service_rec = new ServiceWindowGenerationFromREC( | 157 | service_rec = new ServiceWindowGenerationFromREC( |
| 165 | path_video, | 158 | path_video, |
| @@ -179,15 +172,12 @@ void serviceREC(char* path_video, char* sublanguage, | @@ -179,15 +172,12 @@ void serviceREC(char* path_video, char* sublanguage, | ||
| 179 | while(service_rec->isRunning()){ | 172 | while(service_rec->isRunning()){ |
| 180 | sleep(2); | 173 | sleep(2); |
| 181 | } | 174 | } |
| 182 | - updateRequestStatus(filename.c_str(), id, "true"); | ||
| 183 | delete service_rec; | 175 | delete service_rec; |
| 184 | } | 176 | } |
| 185 | 177 | ||
| 186 | void serviceREC(char* path_video, char* sublanguage, | 178 | void serviceREC(char* path_video, char* sublanguage, |
| 187 | char* position, char* size, char* transparency, char* id){ | 179 | char* position, char* size, char* transparency, char* id){ |
| 188 | 180 | ||
| 189 | - filename = createFileToResponse(id); | ||
| 190 | - | ||
| 191 | ServiceWindowGenerationFromREC * service_rec; | 181 | ServiceWindowGenerationFromREC * service_rec; |
| 192 | service_rec = new ServiceWindowGenerationFromREC( | 182 | service_rec = new ServiceWindowGenerationFromREC( |
| 193 | path_video, | 183 | path_video, |
| @@ -207,14 +197,12 @@ void serviceREC(char* path_video, char* sublanguage, | @@ -207,14 +197,12 @@ void serviceREC(char* path_video, char* sublanguage, | ||
| 207 | while(service_rec->isRunning()){ | 197 | while(service_rec->isRunning()){ |
| 208 | sleep(2); | 198 | sleep(2); |
| 209 | } | 199 | } |
| 210 | - updateRequestStatus(filename.c_str(), id, "true"); | ||
| 211 | delete service_rec; | 200 | delete service_rec; |
| 212 | } | 201 | } |
| 213 | 202 | ||
| 214 | void serviceSRT(char* path_in, char* path_srt, char* sublanguage, | 203 | void serviceSRT(char* path_in, char* path_srt, char* sublanguage, |
| 215 | char* position, char* size, char* transparency, char* id){ | 204 | char* position, char* size, char* transparency, char* id){ |
| 216 | 205 | ||
| 217 | - filename = createFileToResponse(id); | ||
| 218 | 206 | ||
| 219 | ServiceWindowGenerationFromSRT * service_srt; | 207 | ServiceWindowGenerationFromSRT * service_srt; |
| 220 | service_srt = new ServiceWindowGenerationFromSRT( | 208 | service_srt = new ServiceWindowGenerationFromSRT( |
| @@ -233,14 +221,12 @@ void serviceSRT(char* path_in, char* path_srt, char* sublanguage, | @@ -233,14 +221,12 @@ void serviceSRT(char* path_in, char* path_srt, char* sublanguage, | ||
| 233 | sleep(5); | 221 | sleep(5); |
| 234 | } | 222 | } |
| 235 | 223 | ||
| 236 | - updateRequestStatus(filename.c_str(), id, "true"); | ||
| 237 | delete service_srt; | 224 | delete service_srt; |
| 238 | 225 | ||
| 239 | } | 226 | } |
| 240 | 227 | ||
| 241 | void serviceText(char* path_text, char* transparency, char* id, char* client_type){ | 228 | void serviceText(char* path_text, char* transparency, char* id, char* client_type){ |
| 242 | 229 | ||
| 243 | - //filename = createFileToRespWeb(id); | ||
| 244 | if (strcmp(client_type, (char*)"WEB") == 0) { | 230 | if (strcmp(client_type, (char*)"WEB") == 0) { |
| 245 | ServiceWindowGenerationFromText *service_text; | 231 | ServiceWindowGenerationFromText *service_text; |
| 246 | service_text = new ServiceWindowGenerationFromText(path_text, id, (int) atoi(transparency), 4, client_type); | 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,11 +241,10 @@ void serviceText(char* path_text, char* transparency, char* id, char* client_typ | ||
| 255 | while (service_text->isAlive()) { | 241 | while (service_text->isAlive()) { |
| 256 | usleep(100000); //100ms | 242 | usleep(100000); //100ms |
| 257 | } | 243 | } |
| 258 | - //updateRequestStatusWeb(filename.c_str(), id, "true"); | ||
| 259 | delete service_text; | 244 | delete service_text; |
| 260 | 245 | ||
| 261 | } else { | 246 | } else { |
| 262 | - printf("ServicoIOS\n"); | 247 | + |
| 263 | ServiceWindowGenerationFromText *service_text; | 248 | ServiceWindowGenerationFromText *service_text; |
| 264 | service_text = new ServiceWindowGenerationFromText(path_text, id, (int) atoi(transparency), 4, (char*)"IOS"); | 249 | service_text = new ServiceWindowGenerationFromText(path_text, id, (int) atoi(transparency), 4, (char*)"IOS"); |
| 265 | try{ | 250 | try{ |
| @@ -273,16 +258,13 @@ void serviceText(char* path_text, char* transparency, char* id, char* client_typ | @@ -273,16 +258,13 @@ void serviceText(char* path_text, char* transparency, char* id, char* client_typ | ||
| 273 | while (service_text->isAlive()) { | 258 | while (service_text->isAlive()) { |
| 274 | usleep(100000); //100ms | 259 | usleep(100000); //100ms |
| 275 | } | 260 | } |
| 276 | - //updateRequestStatusWeb(filename.c_str(), id, "true"); | ||
| 277 | delete service_text; | 261 | delete service_text; |
| 278 | - | ||
| 279 | } | 262 | } |
| 280 | 263 | ||
| 281 | } | 264 | } |
| 282 | 265 | ||
| 283 | void serviceOnlySRT(char* path_file, char* transparency, char* id){ | 266 | void serviceOnlySRT(char* path_file, char* transparency, char* id){ |
| 284 | 267 | ||
| 285 | - //filename = createFileToRespWeb(id); | ||
| 286 | 268 | ||
| 287 | ServiceWindowGenerationFromSRT * service_srt; | 269 | ServiceWindowGenerationFromSRT * service_srt; |
| 288 | service_srt = new ServiceWindowGenerationFromSRT(path_file, (int) atoi(transparency), id, 5); | 270 | service_srt = new ServiceWindowGenerationFromSRT(path_file, (int) atoi(transparency), id, 5); |
| @@ -382,72 +364,3 @@ void help() { | @@ -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,11 +6,10 @@ | ||
| 6 | */ | 6 | */ |
| 7 | 7 | ||
| 8 | #include "Mixer.h" | 8 | #include "Mixer.h" |
| 9 | - | 9 | +#define PATH_API "vlibras_user/vlibras-api/videos/" |
| 10 | 10 | ||
| 11 | using namespace std; | 11 | using namespace std; |
| 12 | 12 | ||
| 13 | - | ||
| 14 | /* Construtores e destrutores...*/ | 13 | /* Construtores e destrutores...*/ |
| 15 | Mixer::Mixer() { | 14 | Mixer::Mixer() { |
| 16 | this->setNumThreads("1"); | 15 | this->setNumThreads("1"); |
| @@ -35,7 +34,7 @@ void Mixer::initialize(string mainVideo, string slVideo, int positionSecondaryVi | @@ -35,7 +34,7 @@ void Mixer::initialize(string mainVideo, string slVideo, int positionSecondaryVi | ||
| 35 | 34 | ||
| 36 | stringstream ss; | 35 | stringstream ss; |
| 37 | ss << _id; | 36 | ss << _id; |
| 38 | - ss >> this->user_id; | 37 | + ss >> user_id; |
| 39 | 38 | ||
| 40 | this->setMainVideo(mainVideo); | 39 | this->setMainVideo(mainVideo); |
| 41 | this->setSecondaryVideo(slVideo); | 40 | this->setSecondaryVideo(slVideo); |
| @@ -45,6 +44,7 @@ void Mixer::initialize(string mainVideo, string slVideo, int positionSecondaryVi | @@ -45,6 +44,7 @@ void Mixer::initialize(string mainVideo, string slVideo, int positionSecondaryVi | ||
| 45 | this->setSize(sizeSecondaryVideo); | 44 | this->setSize(sizeSecondaryVideo); |
| 46 | this->setPositionSecondaryVideo(positionSecondaryVideo); | 45 | this->setPositionSecondaryVideo(positionSecondaryVideo); |
| 47 | this->setTransparency(transparency); | 46 | this->setTransparency(transparency); |
| 47 | + this->setPathFinal(); | ||
| 48 | this->mixVideos(); | 48 | this->mixVideos(); |
| 49 | 49 | ||
| 50 | } | 50 | } |
| @@ -103,8 +103,6 @@ void Mixer::mixVideos () { | @@ -103,8 +103,6 @@ void Mixer::mixVideos () { | ||
| 103 | else | 103 | else |
| 104 | transparency = "transp"; | 104 | transparency = "transp"; |
| 105 | 105 | ||
| 106 | - setPathFinal(nameOfMainVideo); | ||
| 107 | - | ||
| 108 | /*string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -y -vf \"movie="+this->secondaryVideo+", "+ | 106 | /*string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -y -vf \"movie="+this->secondaryVideo+", "+ |
| 109 | "scale="+ num1String +":"+num2String+", setpts=PTS-STARTPTS [movie]; "+ | 107 | "scale="+ num1String +":"+num2String+", setpts=PTS-STARTPTS [movie]; "+ |
| 110 | "[in] setpts=PTS-STARTPTS, [movie] overlay"+transparency+"="+strPosition+ | 108 | "[in] setpts=PTS-STARTPTS, [movie] overlay"+transparency+"="+strPosition+ |
| @@ -120,10 +118,17 @@ void Mixer::mixVideos () { | @@ -120,10 +118,17 @@ void Mixer::mixVideos () { | ||
| 120 | "scale="+ num1String +":"+num2String+", [movie] overlay"+transparency+"="+strPosition+ | 118 | "scale="+ num1String +":"+num2String+", [movie] overlay"+transparency+"="+strPosition+ |
| 121 | " [out]\" -sameq -ar 22050 -ab 32 -f flv -acodec pcm_s16le -vcodec flv -threads "+this->numThreads+" "+nameOfMainVideo+"_Libras.flv";*/ | 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 | "scale="+ num1String +":"+num2String+", setpts=PTS-STARTPTS, [movie] overlay"+transparency+"="+strPosition+ | 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 | convertendo e obtendo ótimos resultados de tamanho do vídeo | 134 | convertendo e obtendo ótimos resultados de tamanho do vídeo |
| @@ -137,15 +142,9 @@ void Mixer::mixVideos () { | @@ -137,15 +142,9 @@ void Mixer::mixVideos () { | ||
| 137 | //system(removeVideoCMD.c_str()); | 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 | /*Ajusta o FPS do vídeo principal para 45 se preciso...*/ | 150 | /*Ajusta o FPS do vídeo principal para 45 se preciso...*/ |
| @@ -312,7 +311,7 @@ void Mixer::setMainVideo(string mainVideo){ | @@ -312,7 +311,7 @@ void Mixer::setMainVideo(string mainVideo){ | ||
| 312 | } | 311 | } |
| 313 | //ajeitar isso depois | 312 | //ajeitar isso depois |
| 314 | string nameOfMainVideo = mainVideo.substr(0, dotPosition); | 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 | temporaryTextFile.append(this->user_id).append("/tamanho.txt"); | 315 | temporaryTextFile.append(this->user_id).append("/tamanho.txt"); |
| 317 | 316 | ||
| 318 | //printf("##########temporaryTextFile: %s\n", temporaryTextFile.c_str()); | 317 | //printf("##########temporaryTextFile: %s\n", temporaryTextFile.c_str()); |
mixer/src/include/Mixer.h
| @@ -66,10 +66,7 @@ public: | @@ -66,10 +66,7 @@ public: | ||
| 66 | void setNumThreads(string); | 66 | void setNumThreads(string); |
| 67 | string getNumThreads(); | 67 | string getNumThreads(); |
| 68 | void initialize(string mainVideo, string slVideo, int, int, int, char*); | 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 | private: | 71 | private: |
| 75 | 72 |
recognize/src/recognize.cpp
| @@ -20,7 +20,7 @@ | @@ -20,7 +20,7 @@ | ||
| 20 | #define SIZE_BUFFER 256 | 20 | #define SIZE_BUFFER 256 |
| 21 | #define CONFIDENCE_RATE 0.45 | 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 | #define PATH_AUDIO_ORIGIN "/audio/origin/audio_origin.wav" | 24 | #define PATH_AUDIO_ORIGIN "/audio/origin/audio_origin.wav" |
| 25 | #define PATH_AUDIO_PARTS "/audio/parts/" | 25 | #define PATH_AUDIO_PARTS "/audio/parts/" |
| 26 | #define FILENAME_RECOGNIZED_OUT "/audio/recognized.out" | 26 | #define FILENAME_RECOGNIZED_OUT "/audio/recognized.out" |
| @@ -119,7 +119,7 @@ void Recognize::Run(){ | @@ -119,7 +119,7 @@ void Recognize::Run(){ | ||
| 119 | executeJuliusEngine(); | 119 | executeJuliusEngine(); |
| 120 | generateConfidence(); | 120 | generateConfidence(); |
| 121 | filterOutputJulius(); | 121 | filterOutputJulius(); |
| 122 | - cleanFiles(); | 122 | + //cleanFiles(); |
| 123 | 123 | ||
| 124 | finished = true; | 124 | finished = true; |
| 125 | notifyEndExtraction(count_lines); | 125 | notifyEndExtraction(count_lines); |
| @@ -150,7 +150,7 @@ char* Recognize::extractAudioFromVideo() { | @@ -150,7 +150,7 @@ char* Recognize::extractAudioFromVideo() { | ||
| 150 | //command.append(strFreq).append(" -ac 1 -f wav ").append(PATH_AUDIO_ORIGIN).append(" &"); | 150 | //command.append(strFreq).append(" -ac 1 -f wav ").append(PATH_AUDIO_ORIGIN).append(" &"); |
| 151 | command.append(strFreq). | 151 | command.append(strFreq). |
| 152 | append(" -ac 1 -f wav "). | 152 | append(" -ac 1 -f wav "). |
| 153 | - append(PATH_GTAAAS_WEB). | 153 | + append(PATH_API_UPLOADS). |
| 154 | append(id). | 154 | append(id). |
| 155 | append(PATH_AUDIO_ORIGIN). | 155 | append(PATH_AUDIO_ORIGIN). |
| 156 | 156 | ||
| @@ -168,7 +168,7 @@ char* Recognize::extractAudioFromVideo() { | @@ -168,7 +168,7 @@ char* Recognize::extractAudioFromVideo() { | ||
| 168 | int Recognize::getTimeMediaSec() { | 168 | int Recognize::getTimeMediaSec() { |
| 169 | 169 | ||
| 170 | string command = PROGRAM; | 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 | command.append(" 2>&1 | grep Duration >> outfile"); | 172 | command.append(" 2>&1 | grep Duration >> outfile"); |
| 173 | system(command.c_str()); | 173 | system(command.c_str()); |
| 174 | 174 | ||
| @@ -230,7 +230,7 @@ void Recognize::breakVideoParts(int timeTotal) { | @@ -230,7 +230,7 @@ void Recognize::breakVideoParts(int timeTotal) { | ||
| 230 | pts.push_back(convert_pts(ss_str)); | 230 | pts.push_back(convert_pts(ss_str)); |
| 231 | 231 | ||
| 232 | command = "sox "; | 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 | sprintf(tmp, "%i", count++); | 234 | sprintf(tmp, "%i", count++); |
| 235 | filename.append(tmp).append(".wav"); | 235 | filename.append(tmp).append(".wav"); |
| 236 | command.append(filename).append(" trim ").append(ss_str).append(" ").append(t_str); | 236 | command.append(filename).append(" trim ").append(ss_str).append(" ").append(t_str); |
| @@ -238,7 +238,7 @@ void Recognize::breakVideoParts(int timeTotal) { | @@ -238,7 +238,7 @@ void Recognize::breakVideoParts(int timeTotal) { | ||
| 238 | system(command.c_str()); | 238 | system(command.c_str()); |
| 239 | 239 | ||
| 240 | string apcomm = "echo "; | 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 | system(apcomm.c_str()); | 242 | system(apcomm.c_str()); |
| 243 | 243 | ||
| 244 | filename = FILENAME_AUDIOPART; | 244 | filename = FILENAME_AUDIOPART; |
| @@ -257,7 +257,7 @@ void Recognize::executeJuliusEngine() { | @@ -257,7 +257,7 @@ void Recognize::executeJuliusEngine() { | ||
| 257 | command = "julius -C vlibras_user/vlibras-core/recognize/src/julius.jconf -input "; | 257 | command = "julius -C vlibras_user/vlibras-core/recognize/src/julius.jconf -input "; |
| 258 | if (inputType == 1) { | 258 | if (inputType == 1) { |
| 259 | type = "rawfile"; | 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 | } else { | 261 | } else { |
| 262 | type = "mic"; | 262 | type = "mic"; |
| 263 | } | 263 | } |
| @@ -265,7 +265,7 @@ void Recognize::executeJuliusEngine() { | @@ -265,7 +265,7 @@ void Recognize::executeJuliusEngine() { | ||
| 265 | command.append(" -smpFreq "). | 265 | command.append(" -smpFreq "). |
| 266 | append(cfreq). | 266 | append(cfreq). |
| 267 | append(" -nolog >> "). | 267 | append(" -nolog >> "). |
| 268 | - append(PATH_GTAAAS_WEB).append(id). | 268 | + append(PATH_API_UPLOADS).append(id). |
| 269 | append(FILENAME_RECOGNIZED_OUT); | 269 | append(FILENAME_RECOGNIZED_OUT); |
| 270 | 270 | ||
| 271 | //Command of execute Julius | 271 | //Command of execute Julius |
| @@ -277,14 +277,14 @@ void Recognize::executeJuliusEngine() { | @@ -277,14 +277,14 @@ void Recognize::executeJuliusEngine() { | ||
| 277 | void Recognize::generateConfidence() { | 277 | void Recognize::generateConfidence() { |
| 278 | 278 | ||
| 279 | string command = "cat "; | 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 | system(command.c_str()); | 283 | system(command.c_str()); |
| 284 | //printf("\n\n---> command: %s\n\n", command.c_str()); | 284 | //printf("\n\n---> command: %s\n\n", command.c_str()); |
| 285 | 285 | ||
| 286 | string path; | 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 | ifstream in(path.c_str()); | 288 | ifstream in(path.c_str()); |
| 289 | 289 | ||
| 290 | if (!in) { | 290 | if (!in) { |
| @@ -344,8 +344,8 @@ void Recognize::filterOutputJulius() { | @@ -344,8 +344,8 @@ void Recognize::filterOutputJulius() { | ||
| 344 | sentences = new std::list<char*>(); | 344 | sentences = new std::list<char*>(); |
| 345 | 345 | ||
| 346 | string command = "cat "; | 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 | system(command.c_str()); | 350 | system(command.c_str()); |
| 351 | //printf("\n\n---> command: %s\n\n", command.c_str()); | 351 | //printf("\n\n---> command: %s\n\n", command.c_str()); |
| @@ -353,7 +353,7 @@ void Recognize::filterOutputJulius() { | @@ -353,7 +353,7 @@ void Recognize::filterOutputJulius() { | ||
| 353 | count_lines = 0; | 353 | count_lines = 0; |
| 354 | 354 | ||
| 355 | string path; | 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 | ifstream in(path.c_str()); | 357 | ifstream in(path.c_str()); |
| 358 | string strFilter; | 358 | string strFilter; |
| 359 | 359 | ||
| @@ -437,15 +437,15 @@ bool Recognize::isFinished() { | @@ -437,15 +437,15 @@ bool Recognize::isFinished() { | ||
| 437 | void Recognize::cleanFiles() { | 437 | void Recognize::cleanFiles() { |
| 438 | 438 | ||
| 439 | string command = "rm -r "; | 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 | system(command.c_str()); | 441 | system(command.c_str()); |
| 442 | } | 442 | } |
| 443 | 443 | ||
| 444 | void Recognize::createDir(){ | 444 | void Recognize::createDir(){ |
| 445 | 445 | ||
| 446 | string command = "mkdir "; | 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 | system(command.c_str()); | 450 | system(command.c_str()); |
| 451 | } | 451 | } |
servico/src/include/serviceWindowGeneration.h
| @@ -53,6 +53,8 @@ protected: | @@ -53,6 +53,8 @@ protected: | ||
| 53 | char* path_input; | 53 | char* path_input; |
| 54 | char* path_audio; | 54 | char* path_audio; |
| 55 | char* path_libras; | 55 | char* path_libras; |
| 56 | + char* client_type; | ||
| 57 | + | ||
| 56 | bool running; | 58 | bool running; |
| 57 | 59 | ||
| 58 | bool finish; | 60 | bool finish; |
| @@ -66,11 +68,12 @@ protected: | @@ -66,11 +68,12 @@ protected: | ||
| 66 | void setSubLanguage(int sublang); | 68 | void setSubLanguage(int sublang); |
| 67 | void setServiceType(int type); | 69 | void setServiceType(int type); |
| 68 | void setUserId(char* _userId); | 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 | public: | 78 | public: |
| 76 | 79 | ||
| @@ -88,7 +91,10 @@ public: | @@ -88,7 +91,10 @@ public: | ||
| 88 | 91 | ||
| 89 | char* getPathLibras(); | 92 | char* getPathLibras(); |
| 90 | char* getUserId(); | 93 | char* getUserId(); |
| 91 | - void setPathLibras(char* _path_libras); | 94 | + char* getClientType(); |
| 95 | + char* getPathInput(); | ||
| 96 | + string getPathAPI(); | ||
| 97 | + void setPathLibras(); | ||
| 92 | void setSizeOfSubtitles(int sub_size); | 98 | void setSizeOfSubtitles(int sub_size); |
| 93 | }; | 99 | }; |
| 94 | 100 |
servico/src/include/serviceWindowGenerationFromSRT.h
| @@ -45,8 +45,7 @@ public: | @@ -45,8 +45,7 @@ public: | ||
| 45 | 45 | ||
| 46 | void notificaSincronizadorSemTradutor(unsigned char *legenda, int64_t pts); | 46 | void notificaSincronizadorSemTradutor(unsigned char *legenda, int64_t pts); |
| 47 | void initialize(); | 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 | void Run(); | 49 | void Run(); |
| 51 | 50 | ||
| 52 | }; | 51 | }; |
servico/src/include/serviceWindowGenerationFromText.h
| @@ -13,10 +13,7 @@ class ServiceWindowGenerationFromText : public ServiceWindowGeneration, public L | @@ -13,10 +13,7 @@ class ServiceWindowGenerationFromText : public ServiceWindowGeneration, public L | ||
| 13 | 13 | ||
| 14 | private: | 14 | private: |
| 15 | ExtratorTXT * extratorTXT; | 15 | ExtratorTXT * extratorTXT; |
| 16 | - char* path_file; | ||
| 17 | bool alive; | 16 | bool alive; |
| 18 | - char* client_type; | ||
| 19 | - char* id; | ||
| 20 | 17 | ||
| 21 | public: | 18 | public: |
| 22 | ServiceWindowGenerationFromText (char* _path_file, char* _video_path_file, | 19 | ServiceWindowGenerationFromText (char* _path_file, char* _video_path_file, |
| @@ -27,8 +24,6 @@ public: | @@ -27,8 +24,6 @@ public: | ||
| 27 | void initialize(); | 24 | void initialize(); |
| 28 | bool isAlive(); | 25 | bool isAlive(); |
| 29 | void Run(); | 26 | void Run(); |
| 30 | - void transcodeVideoToWebm(); | ||
| 31 | - void transcodeVideoToAvi(); | ||
| 32 | }; | 27 | }; |
| 33 | 28 | ||
| 34 | #endif /* _SERVICEWINDOWGENERATIONFROMTEXT_H */ | 29 | #endif /* _SERVICEWINDOWGENERATIONFROMTEXT_H */ |
servico/src/serviceWindowGeneration.cpp
| @@ -5,7 +5,9 @@ | @@ -5,7 +5,9 @@ | ||
| 5 | #define BASEDIR "vlibras_user/dicionario_libras/" | 5 | #define BASEDIR "vlibras_user/dicionario_libras/" |
| 6 | #define BASEDIRTRANSP "vlibras_user/dicionarioTransp_libras/" | 6 | #define BASEDIRTRANSP "vlibras_user/dicionarioTransp_libras/" |
| 7 | #define EXTENSAO_DICIONARIO ".ts" | 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 | ServiceWindowGeneration::ServiceWindowGeneration() { | 12 | ServiceWindowGeneration::ServiceWindowGeneration() { |
| 11 | if (getRunningOption() != '3') { | 13 | if (getRunningOption() != '3') { |
| @@ -47,9 +49,9 @@ void ServiceWindowGeneration::finalizouSincronizacao() { | @@ -47,9 +49,9 @@ void ServiceWindowGeneration::finalizouSincronizacao() { | ||
| 47 | if (getRunningOption() != '2' && serviceType != SERVICE_TYPE_TEXT && serviceType != SERVICE_TYPE_SRT_ONLY) { | 49 | if (getRunningOption() != '2' && serviceType != SERVICE_TYPE_TEXT && serviceType != SERVICE_TYPE_SRT_ONLY) { |
| 48 | mixer = new Mixer(); | 50 | mixer = new Mixer(); |
| 49 | mixer->initialize(this->path_input, this->path_libras,this->position,this->size,this->transparency, this->user_id); | 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 | this->running = false; | 55 | this->running = false; |
| 54 | 56 | ||
| 55 | } | 57 | } |
| @@ -71,19 +73,40 @@ void ServiceWindowGeneration::setSizeOfSubtitles(int sub_size) { | @@ -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 | char* ServiceWindowGeneration::getPathLibras() { | 86 | char* ServiceWindowGeneration::getPathLibras() { |
| 80 | return path_libras; | 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 | void ServiceWindowGeneration::setUserId(char* _userId) { | 102 | void ServiceWindowGeneration::setUserId(char* _userId) { |
| 84 | this->user_id = _userId; | 103 | this->user_id = _userId; |
| 85 | } | 104 | } |
| 86 | 105 | ||
| 106 | +char* ServiceWindowGeneration::getClientType(){ | ||
| 107 | + return client_type; | ||
| 108 | +} | ||
| 109 | + | ||
| 87 | char* ServiceWindowGeneration::getUserId() { | 110 | char* ServiceWindowGeneration::getUserId() { |
| 88 | return user_id; | 111 | return user_id; |
| 89 | } | 112 | } |
| @@ -92,6 +115,10 @@ void ServiceWindowGeneration::setServiceType(int type) { | @@ -92,6 +115,10 @@ void ServiceWindowGeneration::setServiceType(int type) { | ||
| 92 | serviceType = type; | 115 | serviceType = type; |
| 93 | } | 116 | } |
| 94 | 117 | ||
| 118 | +void ServiceWindowGeneration::setClientType(char* client_type) { | ||
| 119 | + this->client_type = client_type; | ||
| 120 | +} | ||
| 121 | + | ||
| 95 | void ServiceWindowGeneration::setSize(int size){ | 122 | void ServiceWindowGeneration::setSize(int size){ |
| 96 | this->size = size; | 123 | this->size = size; |
| 97 | } | 124 | } |
| @@ -110,6 +137,8 @@ void ServiceWindowGeneration::setSubLanguage(int sublang){ | @@ -110,6 +137,8 @@ void ServiceWindowGeneration::setSubLanguage(int sublang){ | ||
| 110 | 137 | ||
| 111 | void ServiceWindowGeneration::initialize() { | 138 | void ServiceWindowGeneration::initialize() { |
| 112 | 139 | ||
| 140 | + setPathLibras(); | ||
| 141 | + | ||
| 113 | this->finish = false; | 142 | this->finish = false; |
| 114 | if (getRunningOption() != '3' && this->sublanguage == 1) { | 143 | if (getRunningOption() != '3' && this->sublanguage == 1) { |
| 115 | tradutor->registraOuvinte(this); | 144 | tradutor->registraOuvinte(this); |
| @@ -207,26 +236,46 @@ void ServiceWindowGeneration::codifica(vector<string> * glosas) { | @@ -207,26 +236,46 @@ void ServiceWindowGeneration::codifica(vector<string> * glosas) { | ||
| 207 | legendas_enviadas++; | 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,30 +3,30 @@ | ||
| 3 | using namespace std; | 3 | using namespace std; |
| 4 | 4 | ||
| 5 | ServiceWindowGenerationFromREC::ServiceWindowGenerationFromREC( | 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 | setSubLanguage(sublanguage); | 9 | setSubLanguage(sublanguage); |
| 10 | setPosition(position); | 10 | setPosition(position); |
| 11 | setSize(size); | 11 | setSize(size); |
| 12 | setTransparency(transparency); | 12 | setTransparency(transparency); |
| 13 | - setServiceType(_serviceType); | 13 | + setServiceType(serviceType); |
| 14 | setUserId(id); | 14 | setUserId(id); |
| 15 | - rec = new Recognize(path_input, id, rate); | 15 | + rec = new Recognize(path_video, id, rate); |
| 16 | DPRINTF("Done!\n"); | 16 | DPRINTF("Done!\n"); |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | ServiceWindowGenerationFromREC::ServiceWindowGenerationFromREC( | 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 | setSubLanguage(sublanguage); | 23 | setSubLanguage(sublanguage); |
| 24 | setPosition(position); | 24 | setPosition(position); |
| 25 | setSize(size); | 25 | setSize(size); |
| 26 | setTransparency(transparency); | 26 | setTransparency(transparency); |
| 27 | - setServiceType(_serviceType); | 27 | + setServiceType(serviceType); |
| 28 | setUserId(id); | 28 | setUserId(id); |
| 29 | - rec = new Recognize(path_input, id); | 29 | + rec = new Recognize(path_video, id); |
| 30 | DPRINTF("Done!\n"); | 30 | DPRINTF("Done!\n"); |
| 31 | } | 31 | } |
| 32 | 32 | ||
| @@ -87,6 +87,6 @@ void ServiceWindowGenerationFromREC::notifySynchWithoutTranslator(unsigned char | @@ -87,6 +87,6 @@ void ServiceWindowGenerationFromREC::notifySynchWithoutTranslator(unsigned char | ||
| 87 | void ServiceWindowGenerationFromREC::Run() { | 87 | void ServiceWindowGenerationFromREC::Run() { |
| 88 | 88 | ||
| 89 | while (!rec->isFinished()) { | 89 | while (!rec->isFinished()) { |
| 90 | - sleep(2); | 90 | + sleep(200000); |
| 91 | } | 91 | } |
| 92 | } | 92 | } |
servico/src/serviceWindowGenerationFromSRT.cpp
| 1 | #include "serviceWindowGenerationFromSRT.h" | 1 | #include "serviceWindowGenerationFromSRT.h" |
| 2 | 2 | ||
| 3 | -#define PATH_LIBRAS "vlibras_user/vlibras-api/videos/" | ||
| 4 | - | ||
| 5 | using namespace std; | 3 | using namespace std; |
| 6 | 4 | ||
| 7 | //Construtor Service 2 | 5 | //Construtor Service 2 |
| 8 | ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT( | 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 | setPosition(position); | 10 | setPosition(position); |
| 12 | setSize(size); | 11 | setSize(size); |
| 13 | setTransparency(transparency); | 12 | setTransparency(transparency); |
| 14 | setSubLanguage(sublanguage); | 13 | setSubLanguage(sublanguage); |
| 15 | - setServiceType(_serviceType); | 14 | + setServiceType(serviceType); |
| 16 | setUserId(id); | 15 | setUserId(id); |
| 17 | this->finish = false; | 16 | this->finish = false; |
| 18 | DPRINTF("Done!\n"); | 17 | DPRINTF("Done!\n"); |
| 19 | } | 18 | } |
| 20 | 19 | ||
| 21 | //Construtor Service 5 | 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 | setPathInput(path_srt); | 22 | setPathInput(path_srt); |
| 24 | setTransparency(transparency); | 23 | setTransparency(transparency); |
| 25 | - setServiceType(_serviceType); | 24 | + setServiceType(serviceType); |
| 26 | setUserId(id); | 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 | finish_srt = false; | 26 | finish_srt = false; |
| 34 | DPRINTF("Done!\n"); | 27 | DPRINTF("Done!\n"); |
| 35 | } | 28 | } |
| @@ -40,12 +33,7 @@ ServiceWindowGenerationFromSRT::~ServiceWindowGenerationFromSRT() { | @@ -40,12 +33,7 @@ ServiceWindowGenerationFromSRT::~ServiceWindowGenerationFromSRT() { | ||
| 40 | DDDPRINTF("Service SRT finalized!\n"); | 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 | this->path_srt = path_srt; | 37 | this->path_srt = path_srt; |
| 50 | } | 38 | } |
| 51 | 39 | ||
| @@ -143,7 +131,7 @@ void ServiceWindowGenerationFromSRT::initialize() { | @@ -143,7 +131,7 @@ void ServiceWindowGenerationFromSRT::initialize() { | ||
| 143 | monitor_pcr_base = new MonitorPCR(); | 131 | monitor_pcr_base = new MonitorPCR(); |
| 144 | monitor_pcr_base->addListenerPCRBase(extratorSRT); | 132 | monitor_pcr_base->addListenerPCRBase(extratorSRT); |
| 145 | extratorSRT->addListener(this); | 133 | extratorSRT->addListener(this); |
| 146 | - extratorSRT->setFilePath((char*) path_srt); | 134 | + extratorSRT->setFilePath((char*) path_input); |
| 147 | 135 | ||
| 148 | ServiceWindowGeneration::initialize(); | 136 | ServiceWindowGeneration::initialize(); |
| 149 | 137 | ||
| @@ -167,7 +155,4 @@ void ServiceWindowGenerationFromSRT::Run() { | @@ -167,7 +155,4 @@ void ServiceWindowGenerationFromSRT::Run() { | ||
| 167 | usleep(200000); //200ms | 155 | usleep(200000); //200ms |
| 168 | } | 156 | } |
| 169 | finish_srt = true; | 157 | finish_srt = true; |
| 170 | - | ||
| 171 | - if (serviceType == 5) | ||
| 172 | - transcodeVideoToFlv(); | ||
| 173 | } | 158 | } |
servico/src/serviceWindowGenerationFromText.cpp
| 1 | - | ||
| 2 | #include "serviceWindowGenerationFromText.h" | 1 | #include "serviceWindowGenerationFromText.h" |
| 3 | 2 | ||
| 4 | - | ||
| 5 | -#define PATH_LIBRAS "vlibras_user/vlibras-api/videos/" | ||
| 6 | -#define MAX_SIZE_PATH 256 | ||
| 7 | - | ||
| 8 | ServiceWindowGenerationFromText::ServiceWindowGenerationFromText ( | 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 | alive = true; | 11 | alive = true; |
| 24 | DPRINTF("Done!\n"); | 12 | DPRINTF("Done!\n"); |
| 25 | - | ||
| 26 | } | 13 | } |
| 27 | 14 | ||
| 28 | ServiceWindowGenerationFromText::~ServiceWindowGenerationFromText() { | 15 | ServiceWindowGenerationFromText::~ServiceWindowGenerationFromText() { |
| @@ -35,7 +22,7 @@ void ServiceWindowGenerationFromText::initialize() { | @@ -35,7 +22,7 @@ void ServiceWindowGenerationFromText::initialize() { | ||
| 35 | 22 | ||
| 36 | extratorTXT = new ExtratorTXT(); | 23 | extratorTXT = new ExtratorTXT(); |
| 37 | extratorTXT->addListener(this); | 24 | extratorTXT->addListener(this); |
| 38 | - extratorTXT->setFilePath((char*) path_file); | 25 | + extratorTXT->setFilePath(getPathInput()); |
| 39 | 26 | ||
| 40 | ServiceWindowGeneration::initialize(); | 27 | ServiceWindowGeneration::initialize(); |
| 41 | 28 | ||
| @@ -64,44 +51,5 @@ void ServiceWindowGenerationFromText::Run() { | @@ -64,44 +51,5 @@ void ServiceWindowGenerationFromText::Run() { | ||
| 64 | while (isRunning()) { | 51 | while (isRunning()) { |
| 65 | usleep(200000); //200ms | 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 | alive = false; | 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 | -} |