Commit 2c424ca578e18a37ac96ec24f1b7d6c9dc73c068

Authored by Erickson Silva
1 parent 9d2f65fa
Exists in master and in 2 other branches api, devel

Geração de vídeos na pasta vlibras-api

main.cpp
... ... @@ -38,6 +38,9 @@ void updateRequestStatus(const char* filename, char* id, char* status);
38 38 string createFileToRespWeb(char* id);
39 39 void updateRequestStatusWeb(const char* filename, char* id, char* status);
40 40  
  41 +//função temporária para a logisitica dos videos gerados
  42 +void sendFileToPath(char* source, char* dest);
  43 +
41 44 string filename;
42 45 bool isFailed;
43 46  
... ... @@ -207,7 +210,7 @@ void serviceSRT(char* path_in, char* path_srt, char* sublanguage,
207 210 service_srt = new ServiceWindowGenerationFromSRT(
208 211 path_in, path_srt, (int) atoi(sublanguage),
209 212 (int) atoi(position), (int) atoi(size),
210   - (int) atoi(transparency), 2);
  213 + (int) atoi(transparency), id, 2);
211 214  
212 215 try{
213 216 service_srt->initialize();
... ... @@ -266,6 +269,18 @@ void serviceOnlySRT(char* path_file, char* transparency, char* id){
266 269 }
267 270 delete service_srt;
268 271  
  272 + string source = "vlibras_user/vlibras-api/videos/";
  273 +
  274 + string command = "ffmpeg -i ";
  275 + command.append(source)
  276 + .append(id).append(".ts")
  277 + .append(" -vcodec copy -f flv ")
  278 + .append(source).append(id).append(".flv")
  279 + .append(" && rm ")
  280 + .append(source).append(id).append(".ts");
  281 +
  282 + system(command.c_str());
  283 +
269 284 }
270 285  
271 286 void serviceREC2(){
... ... @@ -296,6 +311,17 @@ void serviceREC2(){
296 311 **/
297 312 }
298 313  
  314 +void sendFileToPath(char* source, char* dest){
  315 + char* command = (char*) malloc(strlen(source) + strlen(dest)+1);
  316 + strcpy(command, "cp ");
  317 + strcat(command, source);
  318 + strcat(command, " ");
  319 + strcat(command, dest);
  320 + system(command);
  321 + free(command);
  322 +}
  323 +
  324 +
299 325 void fail(string msg){
300 326 printf("\n");
301 327 DDDDPRINTF("Ops... Tivemos um problema! :(\n");
... ...
mixer/src/Mixer.cpp
... ... @@ -99,6 +99,8 @@ void Mixer::mixVideos () {
99 99 else
100 100 transparency = "transp";
101 101  
  102 + setPathFinal(nameOfMainVideo);
  103 +
102 104 /*string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -y -vf \"movie="+this->secondaryVideo+", "+
103 105 "scale="+ num1String +":"+num2String+", setpts=PTS-STARTPTS [movie]; "+
104 106 "[in] setpts=PTS-STARTPTS, [movie] overlay"+transparency+"="+strPosition+
... ... @@ -114,9 +116,10 @@ void Mixer::mixVideos () {
114 116 "scale="+ num1String +":"+num2String+", [movie] overlay"+transparency+"="+strPosition+
115 117 " [out]\" -sameq -ar 22050 -ab 32 -f flv -acodec pcm_s16le -vcodec flv -threads "+this->numThreads+" "+nameOfMainVideo+"_Libras.flv";*/
116 118  
  119 +
117 120 string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -y -vf \"movie="+this->secondaryVideo+", "+
118 121 "scale="+ num1String +":"+num2String+", setpts=PTS-STARTPTS, [movie] overlay"+transparency+"="+strPosition+
119   - " [out]\" -sameq -ar 22050 -ab 32 -f flv -acodec pcm_s16le -vcodec flv -threads "+this->numThreads+" "+nameOfMainVideo+"_Libras.flv";
  122 + " [out]\" -sameq -ar 22050 -ab 32 -f flv -acodec pcm_s16le -vcodec flv -threads "+this->numThreads+" "+getPathFinal();
120 123  
121 124 /*
122 125 convertendo e obtendo ótimos resultados de tamanho do vídeo
... ... @@ -130,6 +133,16 @@ void Mixer::mixVideos () {
130 133 //system(removeVideoCMD.c_str());
131 134 }
132 135  
  136 +void Mixer::setPathFinal(string path){
  137 + pathFinal = path+"_Libras.flv";
  138 +}
  139 +
  140 +char* Mixer::getPathFinal(){
  141 + char* path = new char[pathFinal.size()+1];
  142 + strcpy(path, (char*) pathFinal.c_str());
  143 + return path;
  144 +}
  145 +
133 146 /*Ajusta o FPS do vídeo principal para 45 se preciso...*/
134 147 void Mixer::adjustVideosFps(){
135 148 //primeiro executo a linha de comando que me dá todas as informações do vídeo
... ...
mixer/src/include/Mixer.h
... ... @@ -12,7 +12,7 @@
12 12 #define MIXER_H
13 13  
14 14  
15   -#include <string>
  15 +#include "string.h"
16 16 #include <cstdlib>
17 17 #include <iostream>
18 18 #include <stdio.h>
... ... @@ -66,6 +66,9 @@ public:
66 66 void setNumThreads(string);
67 67 string getNumThreads();
68 68 void initialize(string mainVideo, string slVideo, int, int, int);
  69 + void setPathFinal(string path);
  70 + char* getPathFinal();
  71 +
69 72  
70 73  
71 74 private:
... ... @@ -80,7 +83,7 @@ private:
80 83 void convertMainVideoFPS(fpsAndLine [], int *);
81 84 void convertSecondaryVideoFPS(double);
82 85  
83   - string mainVideo, secondaryVideo, temporaryTextFile, numThreads;
  86 + string mainVideo, secondaryVideo, temporaryTextFile, numThreads, pathFinal;
84 87 int positionSecondaryVideo;
85 88 double widthSecondaryVideo, heightSecondaryVideo;
86 89 int transparency;
... ...
servico/src/include/serviceWindowGeneration.h
... ... @@ -56,6 +56,7 @@ protected:
56 56 bool running;
57 57  
58 58 bool finish;
  59 + char* user_id;
59 60  
60 61 int size, position, transparency, sublanguage, serviceType, numero_legendas, legendas_enviadas;
61 62  
... ... @@ -64,6 +65,10 @@ protected:
64 65 void setTransparency(int);
65 66 void setSubLanguage(int sublang);
66 67 void setServiceType(int type);
  68 + void setUserId(char* _userId);
  69 +
  70 + //TEMP
  71 + void sendFileToPath();
67 72  
68 73 public:
69 74  
... ... @@ -80,6 +85,7 @@ public:
80 85 char getRunningOption();
81 86  
82 87 char* getPathLibras();
  88 + char* getUserId();
83 89 void setPathLibras(char* _path_libras);
84 90 void setSizeOfSubtitles(int sub_size);
85 91 };
... ...
servico/src/include/serviceWindowGenerationFromSRT.h
... ... @@ -28,7 +28,7 @@ public:
28 28 /* Construtor 1 - legenda e vídeo */
29 29 ServiceWindowGenerationFromSRT(
30 30 char* path_video, char* path_srt, int sublanguage,
31   - int position, int size, int transparency, int _serviceType);
  31 + int position, int size, int transparency, char* id, int _serviceType);
32 32  
33 33 /* Construtor 2 - só legenda */
34 34 ServiceWindowGenerationFromSRT(char* path_srt, int transparency, char* id, int _serviceType);
... ...
servico/src/serviceWindowGeneration.cpp
... ... @@ -5,6 +5,7 @@
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 9  
9 10 ServiceWindowGeneration::ServiceWindowGeneration() {
10 11 if (getRunningOption() != '3') {
... ... @@ -46,6 +47,8 @@ void ServiceWindowGeneration::finalizouSincronizacao() {
46 47 if (getRunningOption() != '2' && serviceType != SERVICE_TYPE_TEXT && serviceType != SERVICE_TYPE_SRT_ONLY) {
47 48 mixer = new Mixer();
48 49 mixer->initialize(this->path_input, this->path_libras,this->position,this->size,this->transparency);
  50 + setPathLibras(mixer->getPathFinal());
  51 + sendFileToPath();
49 52 }
50 53 this->running = false;
51 54  
... ... @@ -77,6 +80,13 @@ char* ServiceWindowGeneration::getPathLibras() {
77 80 return path_libras;
78 81 }
79 82  
  83 +void ServiceWindowGeneration::setUserId(char* _userId) {
  84 + this->user_id = _userId;
  85 +}
  86 +
  87 +char* ServiceWindowGeneration::getUserId() {
  88 + return user_id;
  89 +}
80 90  
81 91 void ServiceWindowGeneration::setServiceType(int type) {
82 92 serviceType = type;
... ... @@ -157,7 +167,6 @@ void ServiceWindowGeneration::initialize() {
157 167  
158 168 sincronizador->registraOuvinte(this);
159 169 sincronizador->Start();
160   -
161 170 }
162 171  
163 172 /* Método utilizado pelo Tradutor para notificar o texto traduzido. */
... ... @@ -198,3 +207,15 @@ void ServiceWindowGeneration::codifica(vector&lt;string&gt; * glosas) {
198 207 legendas_enviadas++;
199 208 }
200 209  
  210 +void ServiceWindowGeneration::sendFileToPath(){
  211 + char* command = (char*) malloc(strlen(getPathLibras()) + strlen(FINAL_DESTINATION_API)+10);
  212 + strcpy(command, "cp ");
  213 + strcat(command, getPathLibras());
  214 + strcat(command, " ");
  215 + strcat(command, FINAL_DESTINATION_API);
  216 + strcat(command, getUserId());
  217 + strcat(command, ".flv");
  218 + system(command);
  219 + free(command);
  220 +}
  221 +
... ...
servico/src/serviceWindowGenerationFromREC.cpp
... ... @@ -11,6 +11,7 @@ ServiceWindowGenerationFromREC::ServiceWindowGenerationFromREC(
11 11 setSize(size);
12 12 setTransparency(transparency);
13 13 setServiceType(_serviceType);
  14 + setUserId(id);
14 15 rec = new Recognize(path_input, id, rate);
15 16 DPRINTF("Done!\n");
16 17 }
... ... @@ -24,6 +25,7 @@ ServiceWindowGenerationFromREC::ServiceWindowGenerationFromREC(
24 25 setSize(size);
25 26 setTransparency(transparency);
26 27 setServiceType(_serviceType);
  28 + setUserId(id);
27 29 rec = new Recognize(path_input, id);
28 30 DPRINTF("Done!\n");
29 31 }
... ... @@ -74,5 +76,4 @@ void ServiceWindowGenerationFromREC::Run() {
74 76 sleep(2);
75 77 }
76 78 sincronizador->stop();
77   -
78 79 }
... ...
servico/src/serviceWindowGenerationFromSRT.cpp
1 1 #include "serviceWindowGenerationFromSRT.h"
2 2  
3   -#define PATH_LIBRAS "libras/video/"
  3 +#define PATH_LIBRAS "vlibras_user/vlibras-api/videos/"
4 4  
5 5 using namespace std;
6 6  
7 7 //Construtor Service 2
8 8 ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(
9   - char* path_video, char* path_srt, int sublanguage, int position, int size, int transparency, int _serviceType) {
  9 + char* path_video, char* path_srt, int sublanguage, int position, int size, int transparency, char* id, int _serviceType) {
10 10 setPathInput(path_video, path_srt);
11 11 setPosition(position);
12 12 setSize(size);
13 13 setTransparency(transparency);
14 14 setSubLanguage(sublanguage);
15 15 setServiceType(_serviceType);
  16 + setUserId(id);
16 17 this->finish = false;
17 18 DPRINTF("Done!\n");
18 19 }
... ... @@ -22,7 +23,8 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* path_srt, i
22 23 setPathInput(path_srt);
23 24 setTransparency(transparency);
24 25 setServiceType(_serviceType);
25   -
  26 + setUserId(id);
  27 +
26 28 string new_path_libras = PATH_LIBRAS;
27 29 new_path_libras.append((string) id).append(".ts");
28 30 char* pathl = new char[strlen(new_path_libras.c_str()) + 1];
... ...
servico/src/serviceWindowGenerationFromText.cpp
... ... @@ -2,15 +2,15 @@
2 2 #include "serviceWindowGenerationFromText.h"
3 3  
4 4  
5   -#define PATH_LIBRAS "libras/video/"
6   -#define OUTPUT_VIDEO_WEB "vlibras_user/gtaaas-plugin-server/videos/"
  5 +#define PATH_LIBRAS "vlibras_user/vlibras-api/videos/"
7 6 #define MAX_SIZE_PATH 256
8 7  
9   -ServiceWindowGenerationFromText::ServiceWindowGenerationFromText (char* _path_file, char* _username, int _transp, int _serviceType, char* _client_type) {
  8 +ServiceWindowGenerationFromText::ServiceWindowGenerationFromText (
  9 + char* _path_file, char* _username, int _transp, int _serviceType, char* _client_type) {
10 10  
11 11 path_file = _path_file;
12 12 client_type = _client_type;
13   - id = _username;
  13 + setUserId(_username);
14 14 setTransparency(_transp);
15 15 setServiceType(_serviceType);
16 16 char* final_path = new char[MAX_SIZE_PATH];
... ... @@ -76,8 +76,8 @@ void ServiceWindowGenerationFromText::transcodeVideoToWebm() {
76 76 string command = "ffmpeg -i ";
77 77 command.append(getPathLibras())
78 78 .append(" -vcodec libvpx -acodec libvorbis ")
79   - .append(OUTPUT_VIDEO_WEB)
80   - .append(id)
  79 + .append(PATH_LIBRAS)
  80 + .append(getUserId())
81 81 .append(".webm")
82 82 .append(" && rm ")
83 83 .append(getPathLibras());
... ...
... ... @@ -1 +0,0 @@
1   -O gato comeu o rato
2 0 \ No newline at end of file