From 2c424ca578e18a37ac96ec24f1b7d6c9dc73c068 Mon Sep 17 00:00:00 2001 From: Erickson Silva Date: Thu, 10 Apr 2014 21:01:07 -0300 Subject: [PATCH] Geração de vídeos na pasta vlibras-api --- main.cpp | 28 +++++++++++++++++++++++++++- mixer/src/Mixer.cpp | 15 ++++++++++++++- mixer/src/include/Mixer.h | 7 +++++-- servico/src/include/serviceWindowGeneration.h | 6 ++++++ servico/src/include/serviceWindowGenerationFromSRT.h | 2 +- servico/src/serviceWindowGeneration.cpp | 23 ++++++++++++++++++++++- servico/src/serviceWindowGenerationFromREC.cpp | 3 ++- servico/src/serviceWindowGenerationFromSRT.cpp | 8 +++++--- servico/src/serviceWindowGenerationFromText.cpp | 12 ++++++------ texto | 1 - 10 files changed, 88 insertions(+), 17 deletions(-) delete mode 100644 texto diff --git a/main.cpp b/main.cpp index a5a3090..49fb547 100644 --- a/main.cpp +++ b/main.cpp @@ -38,6 +38,9 @@ void updateRequestStatus(const char* filename, char* id, char* status); string createFileToRespWeb(char* id); void updateRequestStatusWeb(const char* filename, char* id, char* status); +//função temporária para a logisitica dos videos gerados +void sendFileToPath(char* source, char* dest); + string filename; bool isFailed; @@ -207,7 +210,7 @@ void serviceSRT(char* path_in, char* path_srt, char* sublanguage, service_srt = new ServiceWindowGenerationFromSRT( path_in, path_srt, (int) atoi(sublanguage), (int) atoi(position), (int) atoi(size), - (int) atoi(transparency), 2); + (int) atoi(transparency), id, 2); try{ service_srt->initialize(); @@ -266,6 +269,18 @@ void serviceOnlySRT(char* path_file, char* transparency, char* id){ } delete service_srt; + string source = "vlibras_user/vlibras-api/videos/"; + + string command = "ffmpeg -i "; + command.append(source) + .append(id).append(".ts") + .append(" -vcodec copy -f flv ") + .append(source).append(id).append(".flv") + .append(" && rm ") + .append(source).append(id).append(".ts"); + + system(command.c_str()); + } void serviceREC2(){ @@ -296,6 +311,17 @@ void serviceREC2(){ **/ } +void sendFileToPath(char* source, char* dest){ + char* command = (char*) malloc(strlen(source) + strlen(dest)+1); + strcpy(command, "cp "); + strcat(command, source); + strcat(command, " "); + strcat(command, dest); + system(command); + free(command); +} + + void fail(string msg){ printf("\n"); DDDDPRINTF("Ops... Tivemos um problema! :(\n"); diff --git a/mixer/src/Mixer.cpp b/mixer/src/Mixer.cpp index 509127f..2cb4039 100644 --- a/mixer/src/Mixer.cpp +++ b/mixer/src/Mixer.cpp @@ -99,6 +99,8 @@ void Mixer::mixVideos () { else transparency = "transp"; + setPathFinal(nameOfMainVideo); + /*string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -y -vf \"movie="+this->secondaryVideo+", "+ "scale="+ num1String +":"+num2String+", setpts=PTS-STARTPTS [movie]; "+ "[in] setpts=PTS-STARTPTS, [movie] overlay"+transparency+"="+strPosition+ @@ -114,9 +116,10 @@ void Mixer::mixVideos () { "scale="+ num1String +":"+num2String+", [movie] overlay"+transparency+"="+strPosition+ " [out]\" -sameq -ar 22050 -ab 32 -f flv -acodec pcm_s16le -vcodec flv -threads "+this->numThreads+" "+nameOfMainVideo+"_Libras.flv";*/ + string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -y -vf \"movie="+this->secondaryVideo+", "+ "scale="+ num1String +":"+num2String+", setpts=PTS-STARTPTS, [movie] overlay"+transparency+"="+strPosition+ - " [out]\" -sameq -ar 22050 -ab 32 -f flv -acodec pcm_s16le -vcodec flv -threads "+this->numThreads+" "+nameOfMainVideo+"_Libras.flv"; + " [out]\" -sameq -ar 22050 -ab 32 -f flv -acodec pcm_s16le -vcodec flv -threads "+this->numThreads+" "+getPathFinal(); /* convertendo e obtendo ótimos resultados de tamanho do vídeo @@ -130,6 +133,16 @@ void Mixer::mixVideos () { //system(removeVideoCMD.c_str()); } +void Mixer::setPathFinal(string path){ + pathFinal = path+"_Libras.flv"; +} + +char* Mixer::getPathFinal(){ + char* path = new char[pathFinal.size()+1]; + strcpy(path, (char*) pathFinal.c_str()); + return path; +} + /*Ajusta o FPS do vídeo principal para 45 se preciso...*/ void Mixer::adjustVideosFps(){ //primeiro executo a linha de comando que me dá todas as informações do vídeo diff --git a/mixer/src/include/Mixer.h b/mixer/src/include/Mixer.h index bb3fd78..0c3925b 100644 --- a/mixer/src/include/Mixer.h +++ b/mixer/src/include/Mixer.h @@ -12,7 +12,7 @@ #define MIXER_H -#include +#include "string.h" #include #include #include @@ -66,6 +66,9 @@ public: void setNumThreads(string); string getNumThreads(); void initialize(string mainVideo, string slVideo, int, int, int); + void setPathFinal(string path); + char* getPathFinal(); + private: @@ -80,7 +83,7 @@ private: void convertMainVideoFPS(fpsAndLine [], int *); void convertSecondaryVideoFPS(double); - string mainVideo, secondaryVideo, temporaryTextFile, numThreads; + string mainVideo, secondaryVideo, temporaryTextFile, numThreads, pathFinal; int positionSecondaryVideo; double widthSecondaryVideo, heightSecondaryVideo; int transparency; diff --git a/servico/src/include/serviceWindowGeneration.h b/servico/src/include/serviceWindowGeneration.h index f3258f5..0b6e305 100644 --- a/servico/src/include/serviceWindowGeneration.h +++ b/servico/src/include/serviceWindowGeneration.h @@ -56,6 +56,7 @@ protected: bool running; bool finish; + char* user_id; int size, position, transparency, sublanguage, serviceType, numero_legendas, legendas_enviadas; @@ -64,6 +65,10 @@ protected: void setTransparency(int); void setSubLanguage(int sublang); void setServiceType(int type); + void setUserId(char* _userId); + + //TEMP + void sendFileToPath(); public: @@ -80,6 +85,7 @@ public: char getRunningOption(); char* getPathLibras(); + char* getUserId(); void setPathLibras(char* _path_libras); void setSizeOfSubtitles(int sub_size); }; diff --git a/servico/src/include/serviceWindowGenerationFromSRT.h b/servico/src/include/serviceWindowGenerationFromSRT.h index 83c7e26..47072df 100644 --- a/servico/src/include/serviceWindowGenerationFromSRT.h +++ b/servico/src/include/serviceWindowGenerationFromSRT.h @@ -28,7 +28,7 @@ public: /* Construtor 1 - legenda e vídeo */ ServiceWindowGenerationFromSRT( char* path_video, char* path_srt, int sublanguage, - int position, int size, int transparency, int _serviceType); + int position, int size, int transparency, char* id, int _serviceType); /* Construtor 2 - só legenda */ ServiceWindowGenerationFromSRT(char* path_srt, int transparency, char* id, int _serviceType); diff --git a/servico/src/serviceWindowGeneration.cpp b/servico/src/serviceWindowGeneration.cpp index 4044d18..d8643d1 100644 --- a/servico/src/serviceWindowGeneration.cpp +++ b/servico/src/serviceWindowGeneration.cpp @@ -5,6 +5,7 @@ #define BASEDIR "vlibras_user/dicionario_libras/" #define BASEDIRTRANSP "vlibras_user/dicionarioTransp_libras/" #define EXTENSAO_DICIONARIO ".ts" +#define FINAL_DESTINATION_API "vlibras_user/vlibras-api/videos/" ServiceWindowGeneration::ServiceWindowGeneration() { if (getRunningOption() != '3') { @@ -46,6 +47,8 @@ void ServiceWindowGeneration::finalizouSincronizacao() { if (getRunningOption() != '2' && serviceType != SERVICE_TYPE_TEXT && serviceType != SERVICE_TYPE_SRT_ONLY) { mixer = new Mixer(); mixer->initialize(this->path_input, this->path_libras,this->position,this->size,this->transparency); + setPathLibras(mixer->getPathFinal()); + sendFileToPath(); } this->running = false; @@ -77,6 +80,13 @@ char* ServiceWindowGeneration::getPathLibras() { return path_libras; } +void ServiceWindowGeneration::setUserId(char* _userId) { + this->user_id = _userId; +} + +char* ServiceWindowGeneration::getUserId() { + return user_id; +} void ServiceWindowGeneration::setServiceType(int type) { serviceType = type; @@ -157,7 +167,6 @@ void ServiceWindowGeneration::initialize() { sincronizador->registraOuvinte(this); sincronizador->Start(); - } /* Método utilizado pelo Tradutor para notificar o texto traduzido. */ @@ -198,3 +207,15 @@ void ServiceWindowGeneration::codifica(vector * glosas) { legendas_enviadas++; } +void ServiceWindowGeneration::sendFileToPath(){ + char* command = (char*) malloc(strlen(getPathLibras()) + strlen(FINAL_DESTINATION_API)+10); + strcpy(command, "cp "); + strcat(command, getPathLibras()); + strcat(command, " "); + strcat(command, FINAL_DESTINATION_API); + strcat(command, getUserId()); + strcat(command, ".flv"); + system(command); + free(command); +} + diff --git a/servico/src/serviceWindowGenerationFromREC.cpp b/servico/src/serviceWindowGenerationFromREC.cpp index 488420f..e561668 100644 --- a/servico/src/serviceWindowGenerationFromREC.cpp +++ b/servico/src/serviceWindowGenerationFromREC.cpp @@ -11,6 +11,7 @@ ServiceWindowGenerationFromREC::ServiceWindowGenerationFromREC( setSize(size); setTransparency(transparency); setServiceType(_serviceType); + setUserId(id); rec = new Recognize(path_input, id, rate); DPRINTF("Done!\n"); } @@ -24,6 +25,7 @@ ServiceWindowGenerationFromREC::ServiceWindowGenerationFromREC( setSize(size); setTransparency(transparency); setServiceType(_serviceType); + setUserId(id); rec = new Recognize(path_input, id); DPRINTF("Done!\n"); } @@ -74,5 +76,4 @@ void ServiceWindowGenerationFromREC::Run() { sleep(2); } sincronizador->stop(); - } diff --git a/servico/src/serviceWindowGenerationFromSRT.cpp b/servico/src/serviceWindowGenerationFromSRT.cpp index 9f49aab..f5f8246 100644 --- a/servico/src/serviceWindowGenerationFromSRT.cpp +++ b/servico/src/serviceWindowGenerationFromSRT.cpp @@ -1,18 +1,19 @@ #include "serviceWindowGenerationFromSRT.h" -#define PATH_LIBRAS "libras/video/" +#define PATH_LIBRAS "vlibras_user/vlibras-api/videos/" using namespace std; //Construtor Service 2 ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT( - char* path_video, char* path_srt, int sublanguage, int position, int size, int transparency, int _serviceType) { + char* path_video, char* path_srt, int sublanguage, int position, int size, int transparency, char* id, int _serviceType) { setPathInput(path_video, path_srt); setPosition(position); setSize(size); setTransparency(transparency); setSubLanguage(sublanguage); setServiceType(_serviceType); + setUserId(id); this->finish = false; DPRINTF("Done!\n"); } @@ -22,7 +23,8 @@ ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* path_srt, i setPathInput(path_srt); setTransparency(transparency); setServiceType(_serviceType); - + setUserId(id); + string new_path_libras = PATH_LIBRAS; new_path_libras.append((string) id).append(".ts"); char* pathl = new char[strlen(new_path_libras.c_str()) + 1]; diff --git a/servico/src/serviceWindowGenerationFromText.cpp b/servico/src/serviceWindowGenerationFromText.cpp index 25fb532..a31cd17 100644 --- a/servico/src/serviceWindowGenerationFromText.cpp +++ b/servico/src/serviceWindowGenerationFromText.cpp @@ -2,15 +2,15 @@ #include "serviceWindowGenerationFromText.h" -#define PATH_LIBRAS "libras/video/" -#define OUTPUT_VIDEO_WEB "vlibras_user/gtaaas-plugin-server/videos/" +#define PATH_LIBRAS "vlibras_user/vlibras-api/videos/" #define MAX_SIZE_PATH 256 -ServiceWindowGenerationFromText::ServiceWindowGenerationFromText (char* _path_file, char* _username, int _transp, int _serviceType, char* _client_type) { +ServiceWindowGenerationFromText::ServiceWindowGenerationFromText ( + char* _path_file, char* _username, int _transp, int _serviceType, char* _client_type) { path_file = _path_file; client_type = _client_type; - id = _username; + setUserId(_username); setTransparency(_transp); setServiceType(_serviceType); char* final_path = new char[MAX_SIZE_PATH]; @@ -76,8 +76,8 @@ void ServiceWindowGenerationFromText::transcodeVideoToWebm() { string command = "ffmpeg -i "; command.append(getPathLibras()) .append(" -vcodec libvpx -acodec libvorbis ") - .append(OUTPUT_VIDEO_WEB) - .append(id) + .append(PATH_LIBRAS) + .append(getUserId()) .append(".webm") .append(" && rm ") .append(getPathLibras()); diff --git a/texto b/texto deleted file mode 100644 index 24c72cf..0000000 --- a/texto +++ /dev/null @@ -1 +0,0 @@ -O gato comeu o rato \ No newline at end of file -- libgit2 0.21.2