Commit 2c424ca578e18a37ac96ec24f1b7d6c9dc73c068
1 parent
9d2f65fa
Exists in
master
and in
2 other branches
Geração de vídeos na pasta vlibras-api
Showing
10 changed files
with
88 additions
and
17 deletions
Show diff stats
main.cpp
@@ -38,6 +38,9 @@ void updateRequestStatus(const char* filename, char* id, char* status); | @@ -38,6 +38,9 @@ void updateRequestStatus(const char* filename, char* id, char* status); | ||
38 | string createFileToRespWeb(char* id); | 38 | string createFileToRespWeb(char* id); |
39 | void updateRequestStatusWeb(const char* filename, char* id, char* status); | 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 | string filename; | 44 | string filename; |
42 | bool isFailed; | 45 | bool isFailed; |
43 | 46 | ||
@@ -207,7 +210,7 @@ void serviceSRT(char* path_in, char* path_srt, char* sublanguage, | @@ -207,7 +210,7 @@ void serviceSRT(char* path_in, char* path_srt, char* sublanguage, | ||
207 | service_srt = new ServiceWindowGenerationFromSRT( | 210 | service_srt = new ServiceWindowGenerationFromSRT( |
208 | path_in, path_srt, (int) atoi(sublanguage), | 211 | path_in, path_srt, (int) atoi(sublanguage), |
209 | (int) atoi(position), (int) atoi(size), | 212 | (int) atoi(position), (int) atoi(size), |
210 | - (int) atoi(transparency), 2); | 213 | + (int) atoi(transparency), id, 2); |
211 | 214 | ||
212 | try{ | 215 | try{ |
213 | service_srt->initialize(); | 216 | service_srt->initialize(); |
@@ -266,6 +269,18 @@ void serviceOnlySRT(char* path_file, char* transparency, char* id){ | @@ -266,6 +269,18 @@ void serviceOnlySRT(char* path_file, char* transparency, char* id){ | ||
266 | } | 269 | } |
267 | delete service_srt; | 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 | void serviceREC2(){ | 286 | void serviceREC2(){ |
@@ -296,6 +311,17 @@ 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 | void fail(string msg){ | 325 | void fail(string msg){ |
300 | printf("\n"); | 326 | printf("\n"); |
301 | DDDDPRINTF("Ops... Tivemos um problema! :(\n"); | 327 | DDDDPRINTF("Ops... Tivemos um problema! :(\n"); |
mixer/src/Mixer.cpp
@@ -99,6 +99,8 @@ void Mixer::mixVideos () { | @@ -99,6 +99,8 @@ void Mixer::mixVideos () { | ||
99 | else | 99 | else |
100 | transparency = "transp"; | 100 | transparency = "transp"; |
101 | 101 | ||
102 | + setPathFinal(nameOfMainVideo); | ||
103 | + | ||
102 | /*string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -y -vf \"movie="+this->secondaryVideo+", "+ | 104 | /*string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -y -vf \"movie="+this->secondaryVideo+", "+ |
103 | "scale="+ num1String +":"+num2String+", setpts=PTS-STARTPTS [movie]; "+ | 105 | "scale="+ num1String +":"+num2String+", setpts=PTS-STARTPTS [movie]; "+ |
104 | "[in] setpts=PTS-STARTPTS, [movie] overlay"+transparency+"="+strPosition+ | 106 | "[in] setpts=PTS-STARTPTS, [movie] overlay"+transparency+"="+strPosition+ |
@@ -114,9 +116,10 @@ void Mixer::mixVideos () { | @@ -114,9 +116,10 @@ void Mixer::mixVideos () { | ||
114 | "scale="+ num1String +":"+num2String+", [movie] overlay"+transparency+"="+strPosition+ | 116 | "scale="+ num1String +":"+num2String+", [movie] overlay"+transparency+"="+strPosition+ |
115 | " [out]\" -sameq -ar 22050 -ab 32 -f flv -acodec pcm_s16le -vcodec flv -threads "+this->numThreads+" "+nameOfMainVideo+"_Libras.flv";*/ | 117 | " [out]\" -sameq -ar 22050 -ab 32 -f flv -acodec pcm_s16le -vcodec flv -threads "+this->numThreads+" "+nameOfMainVideo+"_Libras.flv";*/ |
116 | 118 | ||
119 | + | ||
117 | string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -y -vf \"movie="+this->secondaryVideo+", "+ | 120 | string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -y -vf \"movie="+this->secondaryVideo+", "+ |
118 | "scale="+ num1String +":"+num2String+", setpts=PTS-STARTPTS, [movie] overlay"+transparency+"="+strPosition+ | 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 | convertendo e obtendo ótimos resultados de tamanho do vídeo | 125 | convertendo e obtendo ótimos resultados de tamanho do vídeo |
@@ -130,6 +133,16 @@ void Mixer::mixVideos () { | @@ -130,6 +133,16 @@ void Mixer::mixVideos () { | ||
130 | //system(removeVideoCMD.c_str()); | 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 | /*Ajusta o FPS do vídeo principal para 45 se preciso...*/ | 146 | /*Ajusta o FPS do vídeo principal para 45 se preciso...*/ |
134 | void Mixer::adjustVideosFps(){ | 147 | void Mixer::adjustVideosFps(){ |
135 | //primeiro executo a linha de comando que me dá todas as informações do vídeo | 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,7 +12,7 @@ | ||
12 | #define MIXER_H | 12 | #define MIXER_H |
13 | 13 | ||
14 | 14 | ||
15 | -#include <string> | 15 | +#include "string.h" |
16 | #include <cstdlib> | 16 | #include <cstdlib> |
17 | #include <iostream> | 17 | #include <iostream> |
18 | #include <stdio.h> | 18 | #include <stdio.h> |
@@ -66,6 +66,9 @@ public: | @@ -66,6 +66,9 @@ 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); | 68 | void initialize(string mainVideo, string slVideo, int, int, int); |
69 | + void setPathFinal(string path); | ||
70 | + char* getPathFinal(); | ||
71 | + | ||
69 | 72 | ||
70 | 73 | ||
71 | private: | 74 | private: |
@@ -80,7 +83,7 @@ private: | @@ -80,7 +83,7 @@ private: | ||
80 | void convertMainVideoFPS(fpsAndLine [], int *); | 83 | void convertMainVideoFPS(fpsAndLine [], int *); |
81 | void convertSecondaryVideoFPS(double); | 84 | void convertSecondaryVideoFPS(double); |
82 | 85 | ||
83 | - string mainVideo, secondaryVideo, temporaryTextFile, numThreads; | 86 | + string mainVideo, secondaryVideo, temporaryTextFile, numThreads, pathFinal; |
84 | int positionSecondaryVideo; | 87 | int positionSecondaryVideo; |
85 | double widthSecondaryVideo, heightSecondaryVideo; | 88 | double widthSecondaryVideo, heightSecondaryVideo; |
86 | int transparency; | 89 | int transparency; |
servico/src/include/serviceWindowGeneration.h
@@ -56,6 +56,7 @@ protected: | @@ -56,6 +56,7 @@ protected: | ||
56 | bool running; | 56 | bool running; |
57 | 57 | ||
58 | bool finish; | 58 | bool finish; |
59 | + char* user_id; | ||
59 | 60 | ||
60 | int size, position, transparency, sublanguage, serviceType, numero_legendas, legendas_enviadas; | 61 | int size, position, transparency, sublanguage, serviceType, numero_legendas, legendas_enviadas; |
61 | 62 | ||
@@ -64,6 +65,10 @@ protected: | @@ -64,6 +65,10 @@ protected: | ||
64 | void setTransparency(int); | 65 | void setTransparency(int); |
65 | void setSubLanguage(int sublang); | 66 | void setSubLanguage(int sublang); |
66 | void setServiceType(int type); | 67 | void setServiceType(int type); |
68 | + void setUserId(char* _userId); | ||
69 | + | ||
70 | + //TEMP | ||
71 | + void sendFileToPath(); | ||
67 | 72 | ||
68 | public: | 73 | public: |
69 | 74 | ||
@@ -80,6 +85,7 @@ public: | @@ -80,6 +85,7 @@ public: | ||
80 | char getRunningOption(); | 85 | char getRunningOption(); |
81 | 86 | ||
82 | char* getPathLibras(); | 87 | char* getPathLibras(); |
88 | + char* getUserId(); | ||
83 | void setPathLibras(char* _path_libras); | 89 | void setPathLibras(char* _path_libras); |
84 | void setSizeOfSubtitles(int sub_size); | 90 | void setSizeOfSubtitles(int sub_size); |
85 | }; | 91 | }; |
servico/src/include/serviceWindowGenerationFromSRT.h
@@ -28,7 +28,7 @@ public: | @@ -28,7 +28,7 @@ public: | ||
28 | /* Construtor 1 - legenda e vídeo */ | 28 | /* Construtor 1 - legenda e vídeo */ |
29 | ServiceWindowGenerationFromSRT( | 29 | ServiceWindowGenerationFromSRT( |
30 | char* path_video, char* path_srt, int sublanguage, | 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 | /* Construtor 2 - só legenda */ | 33 | /* Construtor 2 - só legenda */ |
34 | ServiceWindowGenerationFromSRT(char* path_srt, int transparency, char* id, int _serviceType); | 34 | ServiceWindowGenerationFromSRT(char* path_srt, int transparency, char* id, int _serviceType); |
servico/src/serviceWindowGeneration.cpp
@@ -5,6 +5,7 @@ | @@ -5,6 +5,7 @@ | ||
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 | 9 | ||
9 | ServiceWindowGeneration::ServiceWindowGeneration() { | 10 | ServiceWindowGeneration::ServiceWindowGeneration() { |
10 | if (getRunningOption() != '3') { | 11 | if (getRunningOption() != '3') { |
@@ -46,6 +47,8 @@ void ServiceWindowGeneration::finalizouSincronizacao() { | @@ -46,6 +47,8 @@ void ServiceWindowGeneration::finalizouSincronizacao() { | ||
46 | if (getRunningOption() != '2' && serviceType != SERVICE_TYPE_TEXT && serviceType != SERVICE_TYPE_SRT_ONLY) { | 47 | if (getRunningOption() != '2' && serviceType != SERVICE_TYPE_TEXT && serviceType != SERVICE_TYPE_SRT_ONLY) { |
47 | mixer = new Mixer(); | 48 | mixer = new Mixer(); |
48 | mixer->initialize(this->path_input, this->path_libras,this->position,this->size,this->transparency); | 49 | mixer->initialize(this->path_input, this->path_libras,this->position,this->size,this->transparency); |
50 | + setPathLibras(mixer->getPathFinal()); | ||
51 | + sendFileToPath(); | ||
49 | } | 52 | } |
50 | this->running = false; | 53 | this->running = false; |
51 | 54 | ||
@@ -77,6 +80,13 @@ char* ServiceWindowGeneration::getPathLibras() { | @@ -77,6 +80,13 @@ char* ServiceWindowGeneration::getPathLibras() { | ||
77 | return path_libras; | 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 | void ServiceWindowGeneration::setServiceType(int type) { | 91 | void ServiceWindowGeneration::setServiceType(int type) { |
82 | serviceType = type; | 92 | serviceType = type; |
@@ -157,7 +167,6 @@ void ServiceWindowGeneration::initialize() { | @@ -157,7 +167,6 @@ void ServiceWindowGeneration::initialize() { | ||
157 | 167 | ||
158 | sincronizador->registraOuvinte(this); | 168 | sincronizador->registraOuvinte(this); |
159 | sincronizador->Start(); | 169 | sincronizador->Start(); |
160 | - | ||
161 | } | 170 | } |
162 | 171 | ||
163 | /* Método utilizado pelo Tradutor para notificar o texto traduzido. */ | 172 | /* Método utilizado pelo Tradutor para notificar o texto traduzido. */ |
@@ -198,3 +207,15 @@ void ServiceWindowGeneration::codifica(vector<string> * glosas) { | @@ -198,3 +207,15 @@ void ServiceWindowGeneration::codifica(vector<string> * glosas) { | ||
198 | legendas_enviadas++; | 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,6 +11,7 @@ ServiceWindowGenerationFromREC::ServiceWindowGenerationFromREC( | ||
11 | setSize(size); | 11 | setSize(size); |
12 | setTransparency(transparency); | 12 | setTransparency(transparency); |
13 | setServiceType(_serviceType); | 13 | setServiceType(_serviceType); |
14 | + setUserId(id); | ||
14 | rec = new Recognize(path_input, id, rate); | 15 | rec = new Recognize(path_input, id, rate); |
15 | DPRINTF("Done!\n"); | 16 | DPRINTF("Done!\n"); |
16 | } | 17 | } |
@@ -24,6 +25,7 @@ ServiceWindowGenerationFromREC::ServiceWindowGenerationFromREC( | @@ -24,6 +25,7 @@ ServiceWindowGenerationFromREC::ServiceWindowGenerationFromREC( | ||
24 | setSize(size); | 25 | setSize(size); |
25 | setTransparency(transparency); | 26 | setTransparency(transparency); |
26 | setServiceType(_serviceType); | 27 | setServiceType(_serviceType); |
28 | + setUserId(id); | ||
27 | rec = new Recognize(path_input, id); | 29 | rec = new Recognize(path_input, id); |
28 | DPRINTF("Done!\n"); | 30 | DPRINTF("Done!\n"); |
29 | } | 31 | } |
@@ -74,5 +76,4 @@ void ServiceWindowGenerationFromREC::Run() { | @@ -74,5 +76,4 @@ void ServiceWindowGenerationFromREC::Run() { | ||
74 | sleep(2); | 76 | sleep(2); |
75 | } | 77 | } |
76 | sincronizador->stop(); | 78 | sincronizador->stop(); |
77 | - | ||
78 | } | 79 | } |
servico/src/serviceWindowGenerationFromSRT.cpp
1 | #include "serviceWindowGenerationFromSRT.h" | 1 | #include "serviceWindowGenerationFromSRT.h" |
2 | 2 | ||
3 | -#define PATH_LIBRAS "libras/video/" | 3 | +#define PATH_LIBRAS "vlibras_user/vlibras-api/videos/" |
4 | 4 | ||
5 | using namespace std; | 5 | using namespace std; |
6 | 6 | ||
7 | //Construtor Service 2 | 7 | //Construtor Service 2 |
8 | ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT( | 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 | setPathInput(path_video, path_srt); | 10 | setPathInput(path_video, path_srt); |
11 | setPosition(position); | 11 | setPosition(position); |
12 | setSize(size); | 12 | setSize(size); |
13 | setTransparency(transparency); | 13 | setTransparency(transparency); |
14 | setSubLanguage(sublanguage); | 14 | setSubLanguage(sublanguage); |
15 | setServiceType(_serviceType); | 15 | setServiceType(_serviceType); |
16 | + setUserId(id); | ||
16 | this->finish = false; | 17 | this->finish = false; |
17 | DPRINTF("Done!\n"); | 18 | DPRINTF("Done!\n"); |
18 | } | 19 | } |
@@ -22,7 +23,8 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* path_srt, i | @@ -22,7 +23,8 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* path_srt, i | ||
22 | setPathInput(path_srt); | 23 | setPathInput(path_srt); |
23 | setTransparency(transparency); | 24 | setTransparency(transparency); |
24 | setServiceType(_serviceType); | 25 | setServiceType(_serviceType); |
25 | - | 26 | + setUserId(id); |
27 | + | ||
26 | string new_path_libras = PATH_LIBRAS; | 28 | string new_path_libras = PATH_LIBRAS; |
27 | new_path_libras.append((string) id).append(".ts"); | 29 | new_path_libras.append((string) id).append(".ts"); |
28 | char* pathl = new char[strlen(new_path_libras.c_str()) + 1]; | 30 | char* pathl = new char[strlen(new_path_libras.c_str()) + 1]; |
servico/src/serviceWindowGenerationFromText.cpp
@@ -2,15 +2,15 @@ | @@ -2,15 +2,15 @@ | ||
2 | #include "serviceWindowGenerationFromText.h" | 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 | #define MAX_SIZE_PATH 256 | 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 | path_file = _path_file; | 11 | path_file = _path_file; |
12 | client_type = _client_type; | 12 | client_type = _client_type; |
13 | - id = _username; | 13 | + setUserId(_username); |
14 | setTransparency(_transp); | 14 | setTransparency(_transp); |
15 | setServiceType(_serviceType); | 15 | setServiceType(_serviceType); |
16 | char* final_path = new char[MAX_SIZE_PATH]; | 16 | char* final_path = new char[MAX_SIZE_PATH]; |
@@ -76,8 +76,8 @@ void ServiceWindowGenerationFromText::transcodeVideoToWebm() { | @@ -76,8 +76,8 @@ void ServiceWindowGenerationFromText::transcodeVideoToWebm() { | ||
76 | string command = "ffmpeg -i "; | 76 | string command = "ffmpeg -i "; |
77 | command.append(getPathLibras()) | 77 | command.append(getPathLibras()) |
78 | .append(" -vcodec libvpx -acodec libvorbis ") | 78 | .append(" -vcodec libvpx -acodec libvorbis ") |
79 | - .append(OUTPUT_VIDEO_WEB) | ||
80 | - .append(id) | 79 | + .append(PATH_LIBRAS) |
80 | + .append(getUserId()) | ||
81 | .append(".webm") | 81 | .append(".webm") |
82 | .append(" && rm ") | 82 | .append(" && rm ") |
83 | .append(getPathLibras()); | 83 | .append(getPathLibras()); |
texto