diff --git a/main.cpp b/main.cpp
index b75a356..8af99a8 100644
--- a/main.cpp
+++ b/main.cpp
@@ -35,12 +35,7 @@ void help();
void fail(string msg);
void hasFailed();
void hasInvalid();
-string createFileToResponse(char* id);
-void updateRequestStatus(const char* filename, char* id, char* status);
-string createFileToRespWeb(char* id);
-void updateRequestStatusWeb(const char* filename, char* id, char* status);
-string filename;
bool isFailed;
bool isInvalid;
@@ -158,8 +153,6 @@ void serviceCC(){
void serviceREC(char* path_video, char* sublanguage,
char* position, char* size, char* transparency, char* id, char* rate){
- filename = createFileToResponse(id);
-
ServiceWindowGenerationFromREC * service_rec;
service_rec = new ServiceWindowGenerationFromREC(
path_video,
@@ -179,15 +172,12 @@ void serviceREC(char* path_video, char* sublanguage,
while(service_rec->isRunning()){
sleep(2);
}
- updateRequestStatus(filename.c_str(), id, "true");
delete service_rec;
}
void serviceREC(char* path_video, char* sublanguage,
char* position, char* size, char* transparency, char* id){
- filename = createFileToResponse(id);
-
ServiceWindowGenerationFromREC * service_rec;
service_rec = new ServiceWindowGenerationFromREC(
path_video,
@@ -207,14 +197,12 @@ void serviceREC(char* path_video, char* sublanguage,
while(service_rec->isRunning()){
sleep(2);
}
- updateRequestStatus(filename.c_str(), id, "true");
delete service_rec;
}
void serviceSRT(char* path_in, char* path_srt, char* sublanguage,
char* position, char* size, char* transparency, char* id){
- filename = createFileToResponse(id);
ServiceWindowGenerationFromSRT * service_srt;
service_srt = new ServiceWindowGenerationFromSRT(
@@ -233,14 +221,12 @@ void serviceSRT(char* path_in, char* path_srt, char* sublanguage,
sleep(5);
}
- updateRequestStatus(filename.c_str(), id, "true");
delete service_srt;
}
void serviceText(char* path_text, char* transparency, char* id, char* client_type){
- //filename = createFileToRespWeb(id);
if (strcmp(client_type, (char*)"WEB") == 0) {
ServiceWindowGenerationFromText *service_text;
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
while (service_text->isAlive()) {
usleep(100000); //100ms
}
- //updateRequestStatusWeb(filename.c_str(), id, "true");
delete service_text;
} else {
- printf("ServicoIOS\n");
+
ServiceWindowGenerationFromText *service_text;
service_text = new ServiceWindowGenerationFromText(path_text, id, (int) atoi(transparency), 4, (char*)"IOS");
try{
@@ -273,16 +258,13 @@ void serviceText(char* path_text, char* transparency, char* id, char* client_typ
while (service_text->isAlive()) {
usleep(100000); //100ms
}
- //updateRequestStatusWeb(filename.c_str(), id, "true");
delete service_text;
-
}
}
void serviceOnlySRT(char* path_file, char* transparency, char* id){
- //filename = createFileToRespWeb(id);
ServiceWindowGenerationFromSRT * service_srt;
service_srt = new ServiceWindowGenerationFromSRT(path_file, (int) atoi(transparency), id, 5);
@@ -382,72 +364,3 @@ void help() {
}
-
-string createFileToRespWeb(char* id) {
-
- FILE* file;
- string filename = "web-content/";
- filename += id;
- filename += ".xml";
- file = fopen(filename.c_str(), "w+");
- string content_file = "\n\n\t";
- content_file += id;
- content_file += "\n\tfalse\n";
- const char *textchar = content_file.c_str();
- fwrite(textchar, 1, content_file.size(), file);
- fclose(file);
- return filename;
-
-}
-
-void updateRequestStatusWeb(const char* filename, char* id, char* status){
-
- //printf("\nupdateRequestStatusWeb: id = %s\n", id);
-
- FILE *file = fopen(filename, "w+");
- string content = "\n\n\t";
- content += id;
- content += "\n\t";
- content += status;
- content += "\n";
- const char *textchar = content.c_str();
- fwrite(textchar, 1, content.size(), file);
- fclose(file);
-
-}
-
-string createFileToResponse(char *id){
-
- FILE *arquivofinish;
- string namearq = "vlibras_user/vlibras-web/public/uploads/videos/";
- namearq += id;
- namearq += "/";
- namearq += id;
- namearq += ".xml";
-
- arquivofinish = fopen(namearq.c_str(), "w+");
- string arqtext = "\n\n\t";
- arqtext += id;
- arqtext += "\n\tfalse\n";
- const char *textchar = arqtext.c_str();
- fwrite(textchar, 1, arqtext.size(), arquivofinish);
- fclose(arquivofinish);
-
- return namearq;
-
-}
-
-void updateRequestStatus(const char* filename, char* id, char* status){
-
- FILE *arquivofinish = fopen(filename, "w+");
- string arqtext = "\n\n\t";
- arqtext += id;
- arqtext += "\n\t";
- arqtext += status;
- arqtext += "\n";
- const char *textchar = arqtext.c_str();
- fwrite(textchar, 1, arqtext.size(), arquivofinish);
- fclose(arquivofinish);
-
-}
-
diff --git a/mixer/src/Mixer.cpp b/mixer/src/Mixer.cpp
index df8dce1..bc19a17 100644
--- a/mixer/src/Mixer.cpp
+++ b/mixer/src/Mixer.cpp
@@ -6,11 +6,10 @@
*/
#include "Mixer.h"
-
+#define PATH_API "vlibras_user/vlibras-api/videos/"
using namespace std;
-
/* Construtores e destrutores...*/
Mixer::Mixer() {
this->setNumThreads("1");
@@ -35,7 +34,7 @@ void Mixer::initialize(string mainVideo, string slVideo, int positionSecondaryVi
stringstream ss;
ss << _id;
- ss >> this->user_id;
+ ss >> user_id;
this->setMainVideo(mainVideo);
this->setSecondaryVideo(slVideo);
@@ -45,6 +44,7 @@ void Mixer::initialize(string mainVideo, string slVideo, int positionSecondaryVi
this->setSize(sizeSecondaryVideo);
this->setPositionSecondaryVideo(positionSecondaryVideo);
this->setTransparency(transparency);
+ this->setPathFinal();
this->mixVideos();
}
@@ -103,8 +103,6 @@ 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+
@@ -120,10 +118,17 @@ 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";*/
+ //TRANSCODIFICAR PARA FLV
+ string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -y -vf \"movie="+this->secondaryVideo+", "+
+ "scale="+ num1String +":"+num2String+", setpts=PTS-STARTPTS, [movie] overlay"+transparency+"="+strPosition+
+ " [out]\" -sameq -strict experimental -vcodec mpeg2video -r 30 -threads "+this->numThreads+" "+pathFinal;
+
- string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -y -vf \"movie="+this->secondaryVideo+", "+
+ /*
+ 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+" "+getPathFinal();
+ " [out]\" -sameq -threads "+this->numThreads+" "+pathFinal;
+ */
/*
convertendo e obtendo ótimos resultados de tamanho do vídeo
@@ -137,15 +142,9 @@ void Mixer::mixVideos () {
//system(removeVideoCMD.c_str());
}
-void Mixer::setPathFinal(string path){
- pathFinal = path+"_Libras.flv";
-
-}
-
-string Mixer::getPathFinal(){
- //char* path = new char[pathFinal.size()+1];
- //strcpy(path, (char*) pathFinal.c_str());
- return pathFinal;
+void Mixer::setPathFinal(){
+ pathFinal = PATH_API;
+ pathFinal.append(user_id).append(".mp4");
}
/*Ajusta o FPS do vídeo principal para 45 se preciso...*/
@@ -312,7 +311,7 @@ void Mixer::setMainVideo(string mainVideo){
}
//ajeitar isso depois
string nameOfMainVideo = mainVideo.substr(0, dotPosition);
- this->temporaryTextFile = "vlibras_user/vlibras-web/public/uploads/videos/";
+ this->temporaryTextFile = "vlibras_user/vlibras-api/uploads/";
temporaryTextFile.append(this->user_id).append("/tamanho.txt");
//printf("##########temporaryTextFile: %s\n", temporaryTextFile.c_str());
diff --git a/mixer/src/include/Mixer.h b/mixer/src/include/Mixer.h
index 1285db7..b9a3a29 100644
--- a/mixer/src/include/Mixer.h
+++ b/mixer/src/include/Mixer.h
@@ -66,10 +66,7 @@ public:
void setNumThreads(string);
string getNumThreads();
void initialize(string mainVideo, string slVideo, int, int, int, char*);
- void setPathFinal(string path);
- string getPathFinal();
-
-
+ void setPathFinal();
private:
diff --git a/recognize/src/recognize.cpp b/recognize/src/recognize.cpp
index 7dce75f..7b5681e 100644
--- a/recognize/src/recognize.cpp
+++ b/recognize/src/recognize.cpp
@@ -20,7 +20,7 @@
#define SIZE_BUFFER 256
#define CONFIDENCE_RATE 0.45
-#define PATH_GTAAAS_WEB "vlibras_user/vlibras-web/public/uploads/videos/"
+#define PATH_API_UPLOADS "vlibras_user/vlibras-api/uploads/"
#define PATH_AUDIO_ORIGIN "/audio/origin/audio_origin.wav"
#define PATH_AUDIO_PARTS "/audio/parts/"
#define FILENAME_RECOGNIZED_OUT "/audio/recognized.out"
@@ -119,7 +119,7 @@ void Recognize::Run(){
executeJuliusEngine();
generateConfidence();
filterOutputJulius();
- cleanFiles();
+ //cleanFiles();
finished = true;
notifyEndExtraction(count_lines);
@@ -150,7 +150,7 @@ char* Recognize::extractAudioFromVideo() {
//command.append(strFreq).append(" -ac 1 -f wav ").append(PATH_AUDIO_ORIGIN).append(" &");
command.append(strFreq).
append(" -ac 1 -f wav ").
- append(PATH_GTAAAS_WEB).
+ append(PATH_API_UPLOADS).
append(id).
append(PATH_AUDIO_ORIGIN).
@@ -168,7 +168,7 @@ char* Recognize::extractAudioFromVideo() {
int Recognize::getTimeMediaSec() {
string command = PROGRAM;
- command.append(" -i ").append(PATH_GTAAAS_WEB).append(id).append(PATH_AUDIO_ORIGIN);
+ command.append(" -i ").append(PATH_API_UPLOADS).append(id).append(PATH_AUDIO_ORIGIN);
command.append(" 2>&1 | grep Duration >> outfile");
system(command.c_str());
@@ -230,7 +230,7 @@ void Recognize::breakVideoParts(int timeTotal) {
pts.push_back(convert_pts(ss_str));
command = "sox ";
- command.append(PATH_GTAAAS_WEB).append(id).append(PATH_AUDIO_ORIGIN).append(" ").append(PATH_GTAAAS_WEB).append(id).append(PATH_AUDIO_PARTS);
+ command.append(PATH_API_UPLOADS).append(id).append(PATH_AUDIO_ORIGIN).append(" ").append(PATH_API_UPLOADS).append(id).append(PATH_AUDIO_PARTS);
sprintf(tmp, "%i", count++);
filename.append(tmp).append(".wav");
command.append(filename).append(" trim ").append(ss_str).append(" ").append(t_str);
@@ -238,7 +238,7 @@ void Recognize::breakVideoParts(int timeTotal) {
system(command.c_str());
string apcomm = "echo ";
- apcomm.append(PATH_GTAAAS_WEB).append(id).append(PATH_AUDIO_PARTS).append(filename).append(" >> ").append(PATH_GTAAAS_WEB).append(id).append(FILENAME_AUDIOLIST);
+ apcomm.append(PATH_API_UPLOADS).append(id).append(PATH_AUDIO_PARTS).append(filename).append(" >> ").append(PATH_API_UPLOADS).append(id).append(FILENAME_AUDIOLIST);
system(apcomm.c_str());
filename = FILENAME_AUDIOPART;
@@ -257,7 +257,7 @@ void Recognize::executeJuliusEngine() {
command = "julius -C vlibras_user/vlibras-core/recognize/src/julius.jconf -input ";
if (inputType == 1) {
type = "rawfile";
- command.append(type).append(" -filelist ").append(PATH_GTAAAS_WEB).append(id).append(FILENAME_AUDIOLIST);
+ command.append(type).append(" -filelist ").append(PATH_API_UPLOADS).append(id).append(FILENAME_AUDIOLIST);
} else {
type = "mic";
}
@@ -265,7 +265,7 @@ void Recognize::executeJuliusEngine() {
command.append(" -smpFreq ").
append(cfreq).
append(" -nolog >> ").
- append(PATH_GTAAAS_WEB).append(id).
+ append(PATH_API_UPLOADS).append(id).
append(FILENAME_RECOGNIZED_OUT);
//Command of execute Julius
@@ -277,14 +277,14 @@ void Recognize::executeJuliusEngine() {
void Recognize::generateConfidence() {
string command = "cat ";
- command.append(PATH_GTAAAS_WEB).append(id).append(FILENAME_RECOGNIZED_OUT).append(" | grep ").
- append(FIND_CONFIDENCE).append(" >> ").append(PATH_GTAAAS_WEB).append(id).append(FILENAME_CONFIDENCEOUT);
+ command.append(PATH_API_UPLOADS).append(id).append(FILENAME_RECOGNIZED_OUT).append(" | grep ").
+ append(FIND_CONFIDENCE).append(" >> ").append(PATH_API_UPLOADS).append(id).append(FILENAME_CONFIDENCEOUT);
system(command.c_str());
//printf("\n\n---> command: %s\n\n", command.c_str());
string path;
- path.append(PATH_GTAAAS_WEB).append(id).append(FILENAME_CONFIDENCEOUT);
+ path.append(PATH_API_UPLOADS).append(id).append(FILENAME_CONFIDENCEOUT);
ifstream in(path.c_str());
if (!in) {
@@ -344,8 +344,8 @@ void Recognize::filterOutputJulius() {
sentences = new std::list();
string command = "cat ";
- command.append(PATH_GTAAAS_WEB).append(id).append(FILENAME_RECOGNIZED_OUT).append(" | grep -e ").
- append(FIND_SENTENCE).append(" -e \"").append(AUDIO_SILENT).append("\"").append(" >> ").append(PATH_GTAAAS_WEB).append(id).append(FILENAME_FILTEROUT);
+ command.append(PATH_API_UPLOADS).append(id).append(FILENAME_RECOGNIZED_OUT).append(" | grep -e ").
+ append(FIND_SENTENCE).append(" -e \"").append(AUDIO_SILENT).append("\"").append(" >> ").append(PATH_API_UPLOADS).append(id).append(FILENAME_FILTEROUT);
system(command.c_str());
//printf("\n\n---> command: %s\n\n", command.c_str());
@@ -353,7 +353,7 @@ void Recognize::filterOutputJulius() {
count_lines = 0;
string path;
- path.append(PATH_GTAAAS_WEB).append(id).append(FILENAME_FILTEROUT);
+ path.append(PATH_API_UPLOADS).append(id).append(FILENAME_FILTEROUT);
ifstream in(path.c_str());
string strFilter;
@@ -437,15 +437,15 @@ bool Recognize::isFinished() {
void Recognize::cleanFiles() {
string command = "rm -r ";
- command.append(PATH_GTAAAS_WEB).append(id).append("/audio");
+ command.append(PATH_API_UPLOADS).append(id).append("/audio");
system(command.c_str());
}
void Recognize::createDir(){
string command = "mkdir ";
- command.append(PATH_GTAAAS_WEB).append(id).append("/audio").append(" && mkdir ").
- append(PATH_GTAAAS_WEB).append(id).append("/audio/parts").append(" && mkdir ").
- append(PATH_GTAAAS_WEB).append(id).append("/audio/origin");
+ command.append(PATH_API_UPLOADS).append(id).append("/audio").append(" && mkdir ").
+ append(PATH_API_UPLOADS).append(id).append("/audio/parts").append(" && mkdir ").
+ append(PATH_API_UPLOADS).append(id).append("/audio/origin");
system(command.c_str());
}
diff --git a/servico/src/include/serviceWindowGeneration.h b/servico/src/include/serviceWindowGeneration.h
index 2d59334..4ff403c 100644
--- a/servico/src/include/serviceWindowGeneration.h
+++ b/servico/src/include/serviceWindowGeneration.h
@@ -53,6 +53,8 @@ protected:
char* path_input;
char* path_audio;
char* path_libras;
+ char* client_type;
+
bool running;
bool finish;
@@ -66,11 +68,12 @@ protected:
void setSubLanguage(int sublang);
void setServiceType(int type);
void setUserId(char* _userId);
+ void setClientType(char* client_type);
+ void setPathInput(char* _path_input);
- //TEMP
- void sendFileToPath(string source);
-
- void transcodeVideoToFlv();
+ void transcodeVideoToWebm();
+ void transcodeVideoToMp4();
+ void createThumbnail();
public:
@@ -88,7 +91,10 @@ public:
char* getPathLibras();
char* getUserId();
- void setPathLibras(char* _path_libras);
+ char* getClientType();
+ char* getPathInput();
+ string getPathAPI();
+ void setPathLibras();
void setSizeOfSubtitles(int sub_size);
};
diff --git a/servico/src/include/serviceWindowGenerationFromSRT.h b/servico/src/include/serviceWindowGenerationFromSRT.h
index 47072df..a45b1fe 100644
--- a/servico/src/include/serviceWindowGenerationFromSRT.h
+++ b/servico/src/include/serviceWindowGenerationFromSRT.h
@@ -45,8 +45,7 @@ public:
void notificaSincronizadorSemTradutor(unsigned char *legenda, int64_t pts);
void initialize();
- void setPathInput(char* path_video, char* path_srt);
- void setPathInput(char* path_srt);
+ void setPathSRT(char* path_srt);
void Run();
};
diff --git a/servico/src/include/serviceWindowGenerationFromText.h b/servico/src/include/serviceWindowGenerationFromText.h
index 60ac55a..ee7d2eb 100644
--- a/servico/src/include/serviceWindowGenerationFromText.h
+++ b/servico/src/include/serviceWindowGenerationFromText.h
@@ -13,10 +13,7 @@ class ServiceWindowGenerationFromText : public ServiceWindowGeneration, public L
private:
ExtratorTXT * extratorTXT;
- char* path_file;
bool alive;
- char* client_type;
- char* id;
public:
ServiceWindowGenerationFromText (char* _path_file, char* _video_path_file,
@@ -27,8 +24,6 @@ public:
void initialize();
bool isAlive();
void Run();
- void transcodeVideoToWebm();
- void transcodeVideoToAvi();
};
#endif /* _SERVICEWINDOWGENERATIONFROMTEXT_H */
diff --git a/servico/src/serviceWindowGeneration.cpp b/servico/src/serviceWindowGeneration.cpp
index 36330dd..5b29a70 100644
--- a/servico/src/serviceWindowGeneration.cpp
+++ b/servico/src/serviceWindowGeneration.cpp
@@ -5,7 +5,9 @@
#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/"
+#define PATH_API "vlibras_user/vlibras-api/videos/"
+#define MAX_SIZE_PATH 256
+
ServiceWindowGeneration::ServiceWindowGeneration() {
if (getRunningOption() != '3') {
@@ -47,9 +49,9 @@ 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, this->user_id);
- sendFileToPath(mixer->getPathFinal());
- }
-
+ createThumbnail();
+ }else
+ transcodeVideoToMp4();
this->running = false;
}
@@ -71,19 +73,40 @@ void ServiceWindowGeneration::setSizeOfSubtitles(int sub_size) {
}
}
-void ServiceWindowGeneration::setPathLibras(char* _path_libras) {
- this->path_libras = _path_libras;
- DDPRINTF("Path TS File: %s\n", _path_libras);
+void ServiceWindowGeneration::setPathLibras() {
+ char* final_path = new char[MAX_SIZE_PATH];
+ strcpy(final_path, "vlibras_user/vlibras-api/uploads/");
+ strcat(final_path, this->user_id);
+ strcat(final_path, "/libras.ts");
+
+ this->path_libras = final_path;
+ //DDPRINTF("Path TS File: %s\n", this->path_libras);
}
char* ServiceWindowGeneration::getPathLibras() {
return path_libras;
}
+void ServiceWindowGeneration::setPathInput(char* _path_input) {
+ this->path_input = _path_input;
+}
+
+char* ServiceWindowGeneration::getPathInput() {
+ return path_input;
+}
+
+string ServiceWindowGeneration::getPathAPI() {
+ return PATH_API;
+}
+
void ServiceWindowGeneration::setUserId(char* _userId) {
this->user_id = _userId;
}
+char* ServiceWindowGeneration::getClientType(){
+ return client_type;
+}
+
char* ServiceWindowGeneration::getUserId() {
return user_id;
}
@@ -92,6 +115,10 @@ void ServiceWindowGeneration::setServiceType(int type) {
serviceType = type;
}
+void ServiceWindowGeneration::setClientType(char* client_type) {
+ this->client_type = client_type;
+}
+
void ServiceWindowGeneration::setSize(int size){
this->size = size;
}
@@ -110,6 +137,8 @@ void ServiceWindowGeneration::setSubLanguage(int sublang){
void ServiceWindowGeneration::initialize() {
+ setPathLibras();
+
this->finish = false;
if (getRunningOption() != '3' && this->sublanguage == 1) {
tradutor->registraOuvinte(this);
@@ -207,26 +236,46 @@ void ServiceWindowGeneration::codifica(vector * glosas) {
legendas_enviadas++;
}
-void ServiceWindowGeneration::sendFileToPath(string source){
+void ServiceWindowGeneration::transcodeVideoToWebm() {
- string command = "cp ";
- command.append(source)
- .append(" ").append(FINAL_DESTINATION_API).append(getUserId()).append(".flv")
- .append(" && rm ").append(path_libras);
- system(command.c_str());
+ //printf("[INFO]: A transcodificação para .webm está ativada!\n");
+ string command = "ffmpeg -i ";
+ command.append(path_libras)
+ .append(" -vcodec libvpx -acodec libvorbis ")
+ .append(PATH_API)
+ .append(getUserId())
+ .append(".webm");
+ //printf("[INFO]: Transcodification command -> %s\n", command.c_str());
+ system(command.c_str());
}
-void ServiceWindowGeneration::transcodeVideoToFlv(){
+void ServiceWindowGeneration::transcodeVideoToMp4() {
- string command = "ffmpeg -i ";
- command.append(getPathLibras())
- .append(" -vcodec copy -f flv ")
- .append(FINAL_DESTINATION_API).append(user_id).append(".flv")
- .append(" && rm ")
- .append(getPathLibras());
+ if (serviceType == SERVICE_TYPE_TEXT && strcmp(client_type, (char*)"WEB") == 0)
+ transcodeVideoToWebm();
+ else{
+ //printf("[INFO]: A transcodificação para .mp4 está ativada!\n");
+ string command = "ffmpeg -i ";
+ command.append(path_libras)
+ .append(" -strict experimental -vcodec mpeg2video -r 30 ")
+ .append(PATH_API)
+ .append(getUserId())
+ .append(".mp4");
+ //printf("[INFO]: Transcodification command -> %s\n", command.c_str());
+ system(command.c_str());
- system(command.c_str());
+ //.append(" -strict experimental -vcodec mjpeg -r 30 -pix_fmt yuvj422p ")
+
+ }
+}
+
+void ServiceWindowGeneration::createThumbnail(){
+ string command = "ffmpeg -ss 10 -i ";
+ command.append(getPathInput())
+ .append(" -vcodec png -vframes 1 -an -f rawvideo -y -vf scale=200:200 ")
+ .append(PATH_API).append(user_id).append(".png");
+ system(command.c_str());
}
diff --git a/servico/src/serviceWindowGenerationFromREC.cpp b/servico/src/serviceWindowGenerationFromREC.cpp
index f95b7a3..99ad487 100644
--- a/servico/src/serviceWindowGenerationFromREC.cpp
+++ b/servico/src/serviceWindowGenerationFromREC.cpp
@@ -3,30 +3,30 @@
using namespace std;
ServiceWindowGenerationFromREC::ServiceWindowGenerationFromREC(
- char* path_video, int sublanguage, int position, int size, int transparency, char* id, int _serviceType, char* rate) {
+ char* path_video, int sublanguage, int position, int size, int transparency, char* id, int serviceType, char* rate) {
- path_input = path_video;
+ setPathInput(path_video);
setSubLanguage(sublanguage);
setPosition(position);
setSize(size);
setTransparency(transparency);
- setServiceType(_serviceType);
+ setServiceType(serviceType);
setUserId(id);
- rec = new Recognize(path_input, id, rate);
+ rec = new Recognize(path_video, id, rate);
DPRINTF("Done!\n");
}
ServiceWindowGenerationFromREC::ServiceWindowGenerationFromREC(
- char* path_video, int sublanguage, int position, int size, int transparency, char* id, int _serviceType) {
+ char* path_video, int sublanguage, int position, int size, int transparency, char* id, int serviceType) {
- path_input = path_video;
+ setPathInput(path_video);
setSubLanguage(sublanguage);
setPosition(position);
setSize(size);
setTransparency(transparency);
- setServiceType(_serviceType);
+ setServiceType(serviceType);
setUserId(id);
- rec = new Recognize(path_input, id);
+ rec = new Recognize(path_video, id);
DPRINTF("Done!\n");
}
@@ -87,6 +87,6 @@ void ServiceWindowGenerationFromREC::notifySynchWithoutTranslator(unsigned char
void ServiceWindowGenerationFromREC::Run() {
while (!rec->isFinished()) {
- sleep(2);
+ sleep(200000);
}
}
diff --git a/servico/src/serviceWindowGenerationFromSRT.cpp b/servico/src/serviceWindowGenerationFromSRT.cpp
index 963f638..3204920 100644
--- a/servico/src/serviceWindowGenerationFromSRT.cpp
+++ b/servico/src/serviceWindowGenerationFromSRT.cpp
@@ -1,35 +1,28 @@
#include "serviceWindowGenerationFromSRT.h"
-#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, char* id, int _serviceType) {
- setPathInput(path_video, path_srt);
+ char* path_video, char* path_srt, int sublanguage, int position, int size, int transparency, char* id, int serviceType) {
+ setPathInput(path_video);
+ setPathSRT(path_srt);
setPosition(position);
setSize(size);
setTransparency(transparency);
setSubLanguage(sublanguage);
- setServiceType(_serviceType);
+ setServiceType(serviceType);
setUserId(id);
this->finish = false;
DPRINTF("Done!\n");
}
//Construtor Service 5
-ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* path_srt, int transparency, char* id, int _serviceType){
+ServiceWindowGenerationFromSRT::ServiceWindowGenerationFromSRT(char* path_srt, int transparency, char* id, int serviceType){
setPathInput(path_srt);
setTransparency(transparency);
- setServiceType(_serviceType);
+ 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];
- strcpy(pathl, (char*)new_path_libras.c_str());
- setPathLibras(pathl);
finish_srt = false;
DPRINTF("Done!\n");
}
@@ -40,12 +33,7 @@ ServiceWindowGenerationFromSRT::~ServiceWindowGenerationFromSRT() {
DDDPRINTF("Service SRT finalized!\n");
}
-void ServiceWindowGenerationFromSRT::setPathInput(char* path_video, char* path_srt) {
- this->path_input = path_video;
- this->path_srt = path_srt;
-}
-
-void ServiceWindowGenerationFromSRT::setPathInput(char* path_srt){
+void ServiceWindowGenerationFromSRT::setPathSRT(char* path_srt) {
this->path_srt = path_srt;
}
@@ -143,7 +131,7 @@ void ServiceWindowGenerationFromSRT::initialize() {
monitor_pcr_base = new MonitorPCR();
monitor_pcr_base->addListenerPCRBase(extratorSRT);
extratorSRT->addListener(this);
- extratorSRT->setFilePath((char*) path_srt);
+ extratorSRT->setFilePath((char*) path_input);
ServiceWindowGeneration::initialize();
@@ -167,7 +155,4 @@ void ServiceWindowGenerationFromSRT::Run() {
usleep(200000); //200ms
}
finish_srt = true;
-
- if (serviceType == 5)
- transcodeVideoToFlv();
}
diff --git a/servico/src/serviceWindowGenerationFromText.cpp b/servico/src/serviceWindowGenerationFromText.cpp
index 6027f8e..d527eeb 100644
--- a/servico/src/serviceWindowGenerationFromText.cpp
+++ b/servico/src/serviceWindowGenerationFromText.cpp
@@ -1,28 +1,15 @@
-
#include "serviceWindowGenerationFromText.h"
-
-#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) {
-
- path_file = _path_file;
- client_type = _client_type;
- setUserId(_username);
- setTransparency(_transp);
- setServiceType(_serviceType);
- char* final_path = new char[MAX_SIZE_PATH];
- strcpy(final_path, PATH_LIBRAS);
- strcat(final_path, _username);
- strcat(final_path, ".ts");
-
- setPathLibras(final_path);
+ char* path_file, char* username, int transp, int serviceType, char* client_type) {
+ setPathInput(path_file);
+ setClientType(client_type);
+ setUserId(username);
+ setTransparency(transp);
+ setServiceType(serviceType);
alive = true;
DPRINTF("Done!\n");
-
}
ServiceWindowGenerationFromText::~ServiceWindowGenerationFromText() {
@@ -35,7 +22,7 @@ void ServiceWindowGenerationFromText::initialize() {
extratorTXT = new ExtratorTXT();
extratorTXT->addListener(this);
- extratorTXT->setFilePath((char*) path_file);
+ extratorTXT->setFilePath(getPathInput());
ServiceWindowGeneration::initialize();
@@ -64,44 +51,5 @@ void ServiceWindowGenerationFromText::Run() {
while (isRunning()) {
usleep(200000); //200ms
}
- if (strcmp(client_type, (char*)"WEB") == 0) {
- printf("[INFO]: A transcodificação para .webm está ativada!\n");
- transcodeVideoToWebm();
- } else if (strcmp(client_type, (char*)"IOS") == 0) {
- printf("[INFO]: A transcodificação para .avi está ativada!\n");
-
- transcodeVideoToAvi();
- }
- else
- transcodeVideoToFlv();
-
alive = false;
}
-
-void ServiceWindowGenerationFromText::transcodeVideoToWebm() {
-
- string command = "ffmpeg -i ";
- command.append(getPathLibras())
- .append(" -vcodec libvpx -acodec libvorbis ")
- .append(PATH_LIBRAS)
- .append(getUserId())
- .append(".webm")
- .append(" && rm ")
- .append(getPathLibras());
- //printf("[INFO]: Transcodification command -> %s\n", command.c_str());
- system(command.c_str());
-}
-
-void ServiceWindowGenerationFromText::transcodeVideoToAvi() {
-
- string command = "ffmpeg -i ";
- command.append(getPathLibras())
- .append(" -vcodec mjpeg -r 30 -pix_fmt yuvj422p ")
- .append(PATH_LIBRAS)
- .append(getUserId())
- .append(".mp4")
- .append(" && rm ")
- .append(getPathLibras());
- //printf("[INFO]: Transcodification command -> %s\n", command.c_str());
- system(command.c_str());
-}
--
libgit2 0.21.2