Commit f4e1261973578ccf94f136aa9aaff42ff0a5dcf7

Authored by Wesnydy Ribeiro
1 parent 2933508f
Exists in master and in 1 other branch devel

Remoção de código obsoleto de mixer

Makefile
... ... @@ -47,7 +47,7 @@ inputOBJS = \
47 47 inputFile.o
48 48  
49 49 mixerOBJS = \
50   - Mixer.o
  50 + mixer.o
51 51  
52 52 recognizeOBJS = \
53 53 audiofile.o \
... ... @@ -116,7 +116,6 @@ clean:
116 116 echo -n "Removendo o link simbólico deste usuário...\n"; \
117 117 rm vlibras_user; \
118 118 fi
119   -
120 119 @if [ -e "doc" ];then \
121 120 echo -n "Removendo documentação...\n"; \
122 121 rm -r doc; \
... ...
mixer/src/Mixer.cpp
... ... @@ -1,353 +0,0 @@
1   -/*
2   - * File: Mixer.cpp
3   - * Author: eduardo
4   - *
5   - * Created on 17 de Janeiro de 2012, 15:28
6   - */
7   -#include "Mixer.h"
8   -
9   -/* Construtores e destrutores...*/
10   -Mixer::Mixer() {
11   - this->setNumThreads("1");
12   - PRINTL(util::_DEBUG, "Mixer Done!\n");
13   -}
14   -Mixer::Mixer(string mainVideo, string secondaryVideo) {
15   - this->setMainVideo(mainVideo);
16   - this->setSecondaryVideo(secondaryVideo);
17   - this->setNumThreads("1");
18   - PRINTL(util::_DEBUG, "Done!\n");
19   -}
20   -Mixer::~Mixer() {
21   - PRINTL(util::_DEBUG, "Mixer finalized!\n");
22   -}
23   -/* FIM de Construtores e destrutores...*/
24   -
25   -/*Faz a chamada ffmpeg no terminal.*/
26   -
27   -void Mixer::initialize(string mainVideo, string slVideo, int positionSecondaryVideo, int sizeSecondaryVideo,
28   - int transparency, char* _id, char* path_uploads, char* path_contents){
29   -
30   - PRINTL(util::_INFO, "Mixando...\n");
31   - uploads = path_uploads;
32   - contents = path_contents;
33   - stringstream ss;
34   - ss << _id;
35   - ss >> user_id;
36   -
37   - this->setMainVideo(mainVideo);
38   - this->setSecondaryVideo(slVideo);
39   - this->setNumThreads("8"); //tem que aparecer antes do metodo adjustVideosFps()
40   - //this->adjustVideosFps();
41   -
42   - this->setSize(sizeSecondaryVideo);
43   - this->setPositionSecondaryVideo(positionSecondaryVideo);
44   - this->setTransparency(transparency);
45   - this->setPathFinal();
46   - this->mixVideos();
47   -}
48   -
49   -void Mixer::mixVideos () {
50   - //convertendo os numeros em string para concatenar à frase
51   - std::stringstream num1;
52   - num1 << this->widthSecondaryVideo;
53   - string num1String;
54   - num1 >> num1String;
55   -
56   - std::stringstream num2;
57   - num2 << this->heightSecondaryVideo;
58   - string num2String;
59   - num2 >> num2String;
60   -
61   - /*std::stringstream num2;
62   - num2 << this->heightSecondaryVideo;
63   - string num2String, aux;
64   - num2 >> aux;
65   - num2String = "in_h*"+aux;*/
66   -
67   - string strPosition;
68   - if(this->getPositionSecondaryVideo() == TOP_LEFT)
69   - strPosition = "10:10";
70   - else if((this->getPositionSecondaryVideo() == TOP_RIGHT))
71   - strPosition = "main_w-overlay_w-10:10";
72   - else if((this->getPositionSecondaryVideo() == BOTTOM_RIGHT))
73   - strPosition = "main_w-overlay_w-10:main_h-overlay_h-10";
74   - else if((this->getPositionSecondaryVideo() == BOTTOM_LEFT))
75   - strPosition = "10:main_h-overlay_h-10";
76   - else{ //se não escolheu nenhum inteiro válido, consideramos BOTTOM_RIGHT o local padrão, mostra msg de erro
77   - strPosition = "main_w-overlay_w-10:main_h-overlay_h-10";
78   - cout << "####################################################################\n";
79   - cout << "# Posicao do vídeo de libras é inválido! #\n";
80   - cout << "# Assumiremos a posicao padrao (Bottom_Right)! #\n";
81   - cout << "# OPCOES: 1-Top_Left; 2-Top_Right; 3-Bottom_Right; 4-Bottom_Left; #\n";
82   - cout << "####################################################################";
83   - }
84   -
85   - //retira a string .ts da primeira string
86   - //string nameOfMainVideo = mainVideo.substr(0,mainVideo.length()-3);
87   - int dotPosition = 0;
88   - for(int k = mainVideo.length(); k >= 0; k--) {
89   - if (mainVideo[k] == '.') {
90   - dotPosition = k;
91   - break;
92   - }
93   - }
94   - string nameOfMainVideo = mainVideo.substr(0, dotPosition);
95   -
96   - string transparency;
97   - if(this->getTransparency()==0){
98   - transparency = "";
99   - }
100   - else
101   - transparency = "transp";
102   -
103   - /*string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -y -vf \"movie="+this->secondaryVideo+", "+
104   - "scale="+ num1String +":"+num2String+", setpts=PTS-STARTPTS [movie]; "+
105   - "[in] setpts=PTS-STARTPTS, [movie] overlay"+transparency+"="+strPosition+
106   - " [out]\" -sameq -threads "+this->numThreads+" "+nameOfMainVideo+"_Libras.ts";*/
107   -
108   - /*string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -y -vf \"movie="+this->secondaryVideo+", "+
109   - "scale="+ num1String +":"+num2String+", setpts=PTS-STARTPTS [movie]; "+
110   - "[in] setpts=PTS-STARTPTS, [movie] overlay"+transparency+"="+strPosition+
111   - " [out]\" -sameq -ar 22050 -ab 32 -f flv -acodec pcm_s16le -vcodec flv -threads "+this->numThreads+" "+nameOfMainVideo+"_Libras.flv";*/
112   -
113   - //LEONARDO
114   - /*string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -y -vf \"movie="+this->secondaryVideo+", "+
115   - "scale="+ num1String +":"+num2String+", [movie] overlay"+transparency+"="+strPosition+
116   - " [out]\" -sameq -ar 22050 -ab 32 -f flv -acodec pcm_s16le -vcodec flv -threads "+this->numThreads+" "+nameOfMainVideo+"_Libras.flv";*/
117   -
118   - //TRANSCODIFICAR PARA FLV
119   - /*
120   - string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -y -vf \"movie="+this->secondaryVideo+", "+
121   - "scale="+ num1String +":"+num2String+", setpts=PTS-STARTPTS, [movie] overlay"+transparency+"="+strPosition+
122   - " [out]\" -sameq -strict experimental -vcodec mpeg2video -r 30 -threads "+this->numThreads+" "+pathFinal;
123   - */
124   -
125   - string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -v quiet -y -vf \"movie="+this->secondaryVideo+", "+
126   - "scale="+ num1String +":"+num2String+", setpts=PTS-STARTPTS, [movie] overlay"+transparency+"="+strPosition+
127   - " [out]\" -qscale 0 -strict experimental -vcodec libx264 -preset fast -r 30 -threads "+this->numThreads+" "+pathFinal;
128   -
129   -
130   -
131   - /*
132   - string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -y -vf \"movie="+this->secondaryVideo+", "+
133   - "scale="+ num1String +":"+num2String+", setpts=PTS-STARTPTS, [movie] overlay"+transparency+"="+strPosition+
134   - " [out]\" -sameq -threads "+this->numThreads+" "+pathFinal;
135   - */
136   -
137   - /*
138   - convertendo e obtendo ótimos resultados de tamanho do vídeo
139   - ffmpeg -i videoDemoLibras.ts -vcodec libx264 -f flv -ar 22050 -ab 32 -sameq -threads 8 -y teste.flv
140   - */
141   -
142   - //printf("\n\n%s\n\n", ffmpegSentence.c_str());
143   - system(ffmpegSentence.c_str());
144   -
145   - //string removeVideoCMD = "rm -rf "+nameOfMainVideo+".ts"; //removo o vídeo exemplo-45fps.ts
146   - //system(removeVideoCMD.c_str());
147   -}
148   -
149   -void Mixer::setPathFinal(){
150   - stringstream ss;
151   - ss << contents;
152   - ss >> pathFinal;
153   - pathFinal.append("/").append(user_id).append(".mp4");
154   -}
155   -
156   -/*Ajusta o FPS do vídeo principal para 45 se preciso...*/
157   -void Mixer::adjustVideosFps(){
158   - //primeiro executo a linha de comando que me dá todas as informações do vídeo
159   - string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" 2> "+temporaryTextFile;
160   - system(ffmpegSentence.c_str()); //executo o comando ffmpeg que escreve no arquivo temporário
161   -
162   - fpsAndLine arrayDeFps[10]; //array onde será guardado os fps encontrados
163   - int qtdadeDeFPSEncontrados = 0;
164   - this->readFileFPS(arrayDeFps, &qtdadeDeFPSEncontrados); //leio o arquivo procurando os FPS disponíveis
165   -
166   - this->convertMainVideoFPS(arrayDeFps, &qtdadeDeFPSEncontrados); //converte o fps do vídeo principal
167   -}
168   -
169   -/*Lê do arquivo procurando o fps...*/
170   -void Mixer::readFileFPS(fpsAndLine arrayDeFps [], int * qtdadeDeFPSEncontrados){
171   - ifstream arq(temporaryTextFile.c_str());//abrindo arquivo com info. dos vídeos
172   - if (arq.is_open()){
173   - int indiceDoFPSEncontrados = 0; //indice a ser utilizado no array
174   - string line;
175   - while (!arq.eof()){
176   - getline(arq,line); //linha lida no arquivo
177   -
178   - int auxProgram = line.find("Program "); //procura pela string "fps,"
179   - if(auxProgram >= 0){
180   - string id = line.substr(auxProgram+10);
181   - if(atoi(id.c_str()) != 0){ //diferente de 0, a conversão deu blz...
182   - arrayDeFps[indiceDoFPSEncontrados].possibleProgramID = id;
183   - printf("\n\n\n\n\nID: %s\n\n\n\n\n",id.c_str());
184   - }
185   - }
186   -
187   - int aux = line.find("fps,"); //procura pela string "fps,"
188   - if(aux >= 0){
189   - int i;
190   - int espacos = 0; //quantidade de espacos encontrados
191   - for(i = aux;espacos != 2;i--){
192   - if(line.at(i) == ' '){ //se for espaço incremente
193   - espacos++;
194   - }
195   - }
196   - string fps = line.substr(i+espacos,aux-i-espacos-1);//extrai o fps da linha
197   - double fpsDouble = atof(fps.c_str()); //transformo de string pra double
198   -
199   - arrayDeFps[indiceDoFPSEncontrados].fps = fpsDouble; //armazeno o fps em um array de struct
200   - arrayDeFps[indiceDoFPSEncontrados].line = line; //armazeno a linha em um array de struct
201   -
202   - indiceDoFPSEncontrados++; //achei um fps, preenchi um struct, vou pro prox.
203   - }
204   - }
205   - arq.close();
206   - //*qtdadeDeFPSEncontrados = indiceDoFPSEncontrados + 1;
207   - *qtdadeDeFPSEncontrados = indiceDoFPSEncontrados;
208   - }
209   -
210   -}
211   -
212   -void Mixer::convertMainVideoFPS(fpsAndLine arrayDeFps [], int * qtdadeDeFPSEncontrados){
213   - //retira a string .ts da primeira string
214   - string nameOfMainVideo = mainVideo.substr(0,mainVideo.length()-3);
215   -
216   - int i;
217   - if(*qtdadeDeFPSEncontrados > 1){
218   - //cout << "\n############################\nConverter fps do vídeo principal com vários canais!\n############################\n");
219   - for(i = 0; i < *qtdadeDeFPSEncontrados;i++){
220   - //procura pela string "Video: h264 (High), yuv420p, 1920x1080 [PAR 1:1 DAR 16:9],"
221   - int indexMainVideo1 = arrayDeFps[i].line.find("Video: h264 (High)");
222   - int indexMainVideo2 = arrayDeFps[i].line.find("yuv420p");
223   - int indexMainVideo3 = arrayDeFps[i].line.find("1920x1080");
224   - //int indexMainVideo = arrayDeFps[i].line.find("DAR 16:9");
225   -
226   - //printf("\n\n\n\n\n\n\nPID do canal: %s \n\n\n\n\n\n\n",arrayDeFps[i].possibleProgramID.c_str());
227   - if(indexMainVideo1 > 0 && indexMainVideo2 > 0 && indexMainVideo3 > 0){ //eis aqui o vídeo principal
228   - //printf("\n\n\n\n\n\n\nPID do canal a ser alterado: %s \n\n\n\n\n\n\n",arrayDeFps[i].possibleProgramID.c_str());
229   - string ffmpegSentence45 = "ffmpeg -i "+this->mainVideo+" -v quiet -y -r 45 -vcodec libx264 -streamid 0:"+arrayDeFps[i].possibleProgramID+
230   - "-sameq -threads "+this->numThreads+" "+nameOfMainVideo+"-45fps.ts";
231   - system(ffmpegSentence45.c_str());
232   - //string removeVideoCMD = "rm -rf "+nameOfMainVideo+".ts"; //removo o vídeo exemplo.ts
233   - //system(removeVideoCMD.c_str());
234   - this->setMainVideo(nameOfMainVideo+"-45fps.ts");
235   - break;
236   - }
237   - }
238   - }
239   - else{
240   - //cout << "\n############################\nConverter fps do vídeo principal com apenas um canal!\n############################\n");
241   - string ffmpegSentence45 = "ffmpeg -i "+this->mainVideo+" -v quiet -y -r 45 -vcodec libx264 "
242   - "-sameq -threads "+this->numThreads+" "+nameOfMainVideo+"-45fps.ts";
243   - system(ffmpegSentence45.c_str());
244   - //string removeVideoCMD = "rm -rf "+nameOfMainVideo+".ts"; //removo o vídeo exemplo.ts
245   - //system(removeVideoCMD.c_str());
246   - this->setMainVideo(nameOfMainVideo+"-45fps.ts");
247   - }
248   -}
249   -
250   -
251   -
252   -
253   -/* O valor da largura e altura está na unidade de Pixels.
254   - * Se o valor da variável for -1, deverá manter a proporção da mesma em relação
255   - * à outra.
256   - * Ex.: 600:-1 ==> largura é 600 e a altura será calculada em relação à mesma para
257   - * manter proporção.
258   - * Ex.: -1:600 ==> altura é 600 e a largura será calculada em relação à mesma para
259   - * manter proporção.
260   - */
261   -void Mixer::setSize(int size){
262   -
263   - string ffprobeSentence = "ffprobe -show_streams "+this->mainVideo+" 2> /dev/null | grep \"height=\" | cut -d'=' -f2 > "+temporaryTextFile;
264   - system(ffprobeSentence.c_str());
265   -
266   - //printf("\n\n%s\n\n",ffprobeSentence.c_str());
267   -
268   -
269   - string heightStr = "324"; //se não conseguir ler do arquivo a altura será essa.. :(
270   -
271   - ifstream arq(temporaryTextFile.c_str());//abrindo arquivo com info. dos vídeos
272   - if (arq.is_open()){
273   - getline(arq,heightStr); //lendo o tamanho(altura) do vídeo
274   - arq.close();
275   - }
276   -
277   - string removeFileSentence = "rm -rf "+temporaryTextFile;
278   - //system(removeFileSentence.c_str());
279   -
280   - int height = atoi(heightStr.c_str());
281   -
282   -
283   - if(size == SMALL){
284   - this->widthSecondaryVideo = -1;
285   - this->heightSecondaryVideo = (0.3*height);
286   - }
287   - else if(size == MEDIUM){
288   - this->widthSecondaryVideo = -1;
289   - this->heightSecondaryVideo = (0.4*height);
290   - }
291   - else if(size == LARGE){
292   - this->widthSecondaryVideo = -1;
293   - this->heightSecondaryVideo = (0.5*height);
294   - }
295   - else{ //se não escolheu nenhum inteiro válido, consideramos MEDIUM_WIDTH a largura padrão, mostra msg de erro
296   - this->widthSecondaryVideo = -1;
297   - this->heightSecondaryVideo = (0.4*height);
298   - cout << "################################################\n";
299   - cout << "# Tamanho do vídeo de libras é inválido! #\n";
300   - cout << "# Assumiremos a largura padrao (Medium_Width)! #\n";
301   - cout << "# OPCOES: 1-Small; 2-Medium; 3-Large; #\n";
302   - cout << "################################################";
303   - }
304   -}
305   -
306   -/*Setters e getters...*/
307   -void Mixer::setMainVideo(string mainVideo){
308   - this->mainVideo = mainVideo;
309   - //retira a string .ts da primeira string, adiciona o "temp" antes e o ".txt" depois
310   - //string nameOfMainVideo = mainVideo.substr(0,mainVideo.length()-3);
311   - int dotPosition = 0;
312   - for(int k = mainVideo.length(); k >= 0; k--) {
313   - if (mainVideo[k] == '.') {
314   - dotPosition = k;
315   - break;
316   - }
317   - }
318   -//ajeitar isso depois
319   - nameOfMainVideo = mainVideo.substr(0, dotPosition);
320   -
321   - stringstream ss;
322   - ss << uploads;
323   - ss >> temporaryTextFile;
324   - temporaryTextFile.append("/").append(this->user_id).append("/tamanho.txt");
325   - //printf("##########temporaryTextFile: %s\n", temporaryTextFile.c_str());
326   -}
327   -string Mixer::getMainVideo(){
328   - return this->mainVideo;
329   -}
330   -void Mixer::setSecondaryVideo(string secondaryVideo){
331   - this->secondaryVideo = secondaryVideo;
332   -}
333   -string Mixer::getSecondaryVideo(){
334   - return this->secondaryVideo;
335   -}
336   -void Mixer::setPositionSecondaryVideo(int positionSecondaryVideo){
337   - this->positionSecondaryVideo = positionSecondaryVideo;
338   -}
339   -int Mixer::getPositionSecondaryVideo(){
340   - return this->positionSecondaryVideo;
341   -}
342   -void Mixer::setTransparency(int transparency){
343   - this->transparency = transparency;
344   -}
345   -int Mixer::getTransparency(){
346   - return this->transparency;
347   -}
348   -void Mixer::setNumThreads(string numThreads){
349   - this->numThreads = numThreads;
350   -}
351   -string Mixer::getNumThreads(){
352   - return this->numThreads;
353   -}
mixer/src/include/Mixer.h
... ... @@ -1,145 +0,0 @@
1   -/**
2   - * \file Mixer.h
3   - *
4   - * \author Eduardo
5   - * \date 17/01/2012
6   - */
7   -
8   -#ifndef MIXER_H
9   -#define MIXER_H
10   -
11   -#include "string.h"
12   -#include <cstdlib>
13   -#include <iostream>
14   -#include <stdio.h>
15   -#include <stdlib.h>
16   -#include <sstream>
17   -#include <string>
18   -#include <fstream>
19   -#include "logging.h"
20   -
21   -//SL Video Position
22   -#define TOP_LEFT 1
23   -#define TOP_RIGHT 2
24   -#define BOTTOM_RIGHT 3
25   -#define BOTTOM_LEFT 4
26   -//SL Video Size
27   -#define SMALL 1
28   -#define MEDIUM 2
29   -#define LARGE 3
30   -//SL Video Width
31   -#define SMALL_HEIGHT 324 //0,3*1080 se fosse full hd
32   -#define MEDIUM_HEIGHT 432 //0,4*1080
33   -#define LARGE_HEIGHT 540 //0.5*1080
34   -
35   -#define MAX_SIZE_PATH 256
36   -
37   -using namespace std;
38   -using namespace util;
39   -
40   -/** \brief Classe que implementa o mixer de vídeo.
41   - *
42   - * \headerfile mixer/src/include/Mixer.h
43   - */
44   -class Mixer {
45   -public:
46   -
47   - /** Construtor.
48   - *
49   - * \param mainVideo O vídeo principal.
50   - * \param secondaryVideo O vídeo secundário.
51   - */
52   - Mixer(string,string);
53   -
54   - /** Construtor */
55   - Mixer();
56   -
57   - /** Destrutor */
58   - virtual ~Mixer();
59   -
60   - /** Ajusta o FPS do vídeo principal para 45 se preciso. */
61   - void adjustVideosFps();
62   -
63   - /** Realiza a Mixagem do vídeo original com o vídeo de LIBRAS. */
64   - void mixVideos();
65   -
66   - /** Seta o tamanho do vídeo de LIBRAS. */
67   - void setSize(int);
68   -
69   - /** Seta o path do vídeo principal. */
70   - void setMainVideo(string);
71   -
72   - /** Retorna o path do vídeo principal.
73   - *
74   - * \return Path do vídeo principal.
75   - */
76   - string getMainVideo();
77   -
78   - /** Seta o path do vídeo secundario. */
79   - void setSecondaryVideo(string);
80   -
81   - /** Retorna o path do vídeo secundário.
82   - *
83   - * \return Path do vídeo secundário.
84   - */
85   - string getSecondaryVideo();
86   -
87   - /** Seta a posição do vídeo secundário em relação ao vídeo principal. */
88   - void setPositionSecondaryVideo(int);
89   -
90   - /** Retorna a posição do vídeo secundário em relação ao vídeo principal.
91   - *
92   - * \return A posição do vídeo.
93   - */
94   - int getPositionSecondaryVideo();
95   -
96   - /** Seta a transparência do vídeo secundário. */
97   - void setTransparency(int);
98   -
99   - /** Retorna a Transparência do vídeo secundário.
100   - *
101   - * \return A transparência do vídeo.
102   - */
103   - int getTransparency();
104   -
105   - /** seta o número de threads utilizadas na mixagem. */
106   - void setNumThreads(string);
107   -
108   - /** Retorna o número de threads utilizadas na mixagem.
109   - *
110   - * \return O número de threads.
111   - */
112   - string getNumThreads();
113   -
114   - /** Inicializa o processo de mixagem.
115   - *
116   - * \param mainVideo O vídeo princial.
117   - * \param slVideo O vídeo secundário.
118   - */
119   - void initialize(string mainVideo, string slVideo, int, int, int, char*, char*, char*);
120   -
121   - /** Seta o path do vídeo mixado */
122   - void setPathFinal();
123   -
124   -private:
125   -
126   - struct fpsAndLine {
127   - string line;
128   - double fps;
129   - string possibleProgramID;
130   - };
131   -
132   - void readFileFPS(fpsAndLine [], int *);
133   - void convertMainVideoFPS(fpsAndLine [], int *);
134   - void convertSecondaryVideoFPS(double);
135   -
136   - string mainVideo, secondaryVideo, temporaryTextFile, numThreads, pathFinal, user_id, nameOfMainVideo;
137   - char* contents;
138   - char* uploads;
139   - int positionSecondaryVideo;
140   - double widthSecondaryVideo, heightSecondaryVideo;
141   - int transparency;
142   -};
143   -
144   -#endif /* MIXER_H */
145   -
mixer/src/include/mixer.h 0 → 100644
... ... @@ -0,0 +1,62 @@
  1 +#ifndef MIXER_H
  2 +#define MIXER_H
  3 +
  4 +#include <string>
  5 +#include <iostream>
  6 +#include <sstream>
  7 +#include <fstream>
  8 +#include "logging.h"
  9 +
  10 +//Secondary Video Position
  11 +#define TOP_LEFT 1
  12 +#define TOP_RIGHT 2
  13 +#define BOTTOM_RIGHT 3
  14 +#define BOTTOM_LEFT 4
  15 +
  16 +//Secondary Video Size
  17 +#define SMALL 1
  18 +#define MEDIUM 2
  19 +#define LARGE 3
  20 +
  21 +#define NUMTHREADS "8"
  22 +
  23 +using namespace std;
  24 +using namespace util;
  25 +
  26 +class Mixer {
  27 +
  28 +public:
  29 + Mixer(string mVideo, string sVideo, int ssVideo, int psVideo, int tsVideo,
  30 + string id, string pathTemp, string pathContents);
  31 + ~Mixer();
  32 +
  33 + void initialize();
  34 +
  35 +private:
  36 + string pathMixedVideo;
  37 + string pathTempFiles;
  38 +
  39 + string mainVideo;
  40 + string secondaryVideo;
  41 + string temporaryTextFile;
  42 + string transparency;
  43 + string userID;
  44 +
  45 + string heigthStr;
  46 + string widthStr;
  47 + string positionStr;
  48 +
  49 + double widthSVideo;
  50 + double heigthSVideo;
  51 +
  52 + int positionSVideo;
  53 + int sizeSVideo;
  54 + int transpSVideo;
  55 +
  56 + void mixVideos();
  57 + void setSVSize();
  58 + void setSVPosition();
  59 + void setPathOfFiles();
  60 +};
  61 +
  62 +#endif /* MIXER_H */
0 63 \ No newline at end of file
... ...
mixer/src/mixer.cpp 0 → 100644
... ... @@ -0,0 +1,146 @@
  1 +#include "mixer.h"
  2 +
  3 +Mixer::Mixer(string mVideo, string sVideo, int ssVideo, int psVideo, int tsVideo,
  4 + string id, string pathTemp, string pathContents) {
  5 + this->mainVideo = mVideo;
  6 + this->secondaryVideo = sVideo;
  7 + this->sizeSVideo = ssVideo;
  8 + this->positionSVideo = psVideo;
  9 + this->transpSVideo = tsVideo;
  10 + this->transparency = ""; //Por enquanto, a transparência esta desativada.
  11 + this->pathTempFiles = pathTemp;
  12 + this->pathMixedVideo = pathContents;
  13 + this->userID = id;
  14 + PRINTL(util::_DEBUG, "Mixer Done!\n");
  15 +}
  16 +
  17 +Mixer::~Mixer() {
  18 + PRINTL(util::_DEBUG, "Mixer finalized!\n");
  19 +}
  20 +
  21 +void Mixer::setPathOfFiles() {
  22 + this->pathTempFiles.append("/").append(this->userID);
  23 + this->pathMixedVideo.append("/").append(this->userID).append(".mp4");
  24 +
  25 + cout << "PATH TEMP FILES: " << this->pathTempFiles << endl;
  26 + cout << "PATH MIXED VIDEOS: " << this->pathMixedVideo << endl;
  27 +}
  28 +
  29 +/* O valor da largura e altura está na unidade de Pixels.
  30 + * Se o valor da variável for -1, deverá manter a proporção da mesma em relação
  31 + * à outra.
  32 + * Ex.: 600:-1 ==> largura é 600 e a altura será calculada em relação à mesma para
  33 + * manter proporção.
  34 + * Ex.: -1:600 ==> altura é 600 e a largura será calculada em relação à mesma para
  35 + * manter proporção.
  36 + */
  37 +void Mixer::setSVSize() {
  38 + string tempTextFile = this->pathTempFiles;
  39 + tempTextFile.append("/").append("tamanho.txt");
  40 +
  41 + cout << "TEMPTXT: " << tempTextFile << endl;
  42 +
  43 + string ffprobeSentence = "ffprobe -show_streams "+this->mainVideo+" 2> /dev/null | grep \"height=\" | cut -d'=' -f2 > "+tempTextFile;
  44 + system(ffprobeSentence.c_str());
  45 +
  46 + string strHeight = "324"; //Se não conseguir ler do arquivo a altura será essa...
  47 + ifstream arq(tempTextFile.c_str()); //Abrindo arquivo com info. dos vídeos
  48 + if (arq.is_open()) {
  49 + getline(arq,strHeight); //Lendo o tamanho(altura) do vídeo
  50 + arq.close();
  51 + }
  52 + int height = atoi(strHeight.c_str());
  53 +
  54 + stringstream alt;
  55 + stringstream larg;
  56 +
  57 + switch(this->sizeSVideo){
  58 + case SMALL:
  59 + this->widthSVideo = -1;
  60 + this->heigthSVideo = (0.3*height);
  61 +
  62 + larg << this->widthSVideo;
  63 + larg >> this->widthStr;
  64 +
  65 + alt << this->heigthSVideo;
  66 + alt >> this->heigthStr;
  67 + break;
  68 +
  69 + case MEDIUM:
  70 + this->widthSVideo = -1;
  71 + this->heigthSVideo = (0.4*height);
  72 +
  73 + larg << this->widthSVideo;
  74 + larg >> this->widthStr;
  75 +
  76 + alt << this->heigthSVideo;
  77 + alt >> this->heigthStr;
  78 + break;
  79 +
  80 + case LARGE:
  81 + this->widthSVideo = -1;
  82 + this->heigthSVideo = (0.5*height);
  83 +
  84 + larg << this->widthSVideo;
  85 + larg >> this->widthStr;
  86 +
  87 + alt << this->heigthSVideo;
  88 + alt >> this->heigthStr;
  89 + break;
  90 +
  91 + default: //Se não escolheu nenhum inteiro válido, consideramos MEDIUM como o tamanho padrão.
  92 + this->widthSVideo = -1;
  93 + this->heigthSVideo = (0.4*height);
  94 +
  95 + larg << this->widthSVideo;
  96 + larg >> this->widthStr;
  97 +
  98 + alt << this->heigthSVideo;
  99 + alt >> this->heigthStr;
  100 +
  101 + PRINTL(util::_WARNING, "Tamanho do vídeo de libras é inválido! Tamanho padrão selecionado.\n");
  102 + }
  103 +}
  104 +
  105 +void Mixer::setSVPosition() {
  106 + switch(this->positionSVideo){
  107 + case TOP_LEFT:
  108 + this->positionStr = "10:10";
  109 + break;
  110 +
  111 + case TOP_RIGHT:
  112 + this->positionStr = "main_w-overlay_w-10:10";
  113 + break;
  114 +
  115 + case BOTTOM_RIGHT:
  116 + this->positionStr = "main_w-overlay_w-10:main_h-overlay_h-10";
  117 + break;
  118 +
  119 + case BOTTOM_LEFT:
  120 + this->positionStr = "10:main_h-overlay_h-10";
  121 + break;
  122 +
  123 + default: //Se não escolheu nenhum inteiro válido, consideramos BOTTOM_RIGHT como a posição padrão.
  124 + this->positionStr = "main_w-overlay_w-10:main_h-overlay_h-10";
  125 + PRINTL(util::_WARNING, "Posição do vídeo de libras é inválido! Posição padrão selecionada.\n");
  126 + }
  127 +}
  128 +
  129 +void Mixer::initialize() {
  130 + setPathOfFiles(); //Tem que aparecer antes de setSVSize();
  131 + setSVSize();
  132 + setSVPosition();
  133 + mixVideos();
  134 +}
  135 +
  136 +void Mixer::mixVideos() {
  137 + PRINTL(util::_INFO, "Mixando...\n");
  138 +
  139 + string ffmpegSentence = "ffmpeg -i "+this->mainVideo+" -v quiet -y -vf \"movie="+this->secondaryVideo+", "+
  140 + "scale="+ this->widthStr +":"+this->heigthStr+", setpts=PTS-STARTPTS, [movie] overlay"+this->transparency+"="+this->positionStr+
  141 + " [out]\" -qscale 0 -strict experimental -vcodec libx264 -preset fast -r 30 -threads "+NUMTHREADS+" "+this->pathMixedVideo;
  142 +
  143 + cout << "FFMPEG: " << ffmpegSentence << endl;
  144 +
  145 + system(ffmpegSentence.c_str());
  146 +}
0 147 \ No newline at end of file
... ...
servico/src/include/serviceWindowGeneration.h
... ... @@ -13,7 +13,7 @@
13 13 #include <locale>
14 14 #include "jthread.h"
15 15 #include "logging.h"
16   -#include "Mixer.h"
  16 +#include "mixer.h"
17 17 #include "renderer.h"
18 18 #include "listenerRenderer.h"
19 19 #include "listenerTradutor.h"
... ...
servico/src/serviceWindowGenerationFromRec.cpp
... ... @@ -158,10 +158,11 @@ void ServiceWindowGenerationFromRec::notifyTranslation(char* glosa) {
158 158 }
159 159  
160 160 void ServiceWindowGenerationFromRec::notifyEndOfRenderization() {
161   - mixer = new Mixer();
  161 + mixer = new Mixer(this->path_input, this->path_libras, this->size, this->position,
  162 + this->transparency, this->user_id, this->path_uploads, this->path_contents);
  163 +
162 164 if(this->service_type == SERVICE_TYPE_REC){
163   - mixer->initialize(this->path_input, this->path_libras, this->position, this->size,
164   - this->transparency, this->user_id, this->path_uploads, this->path_contents);
  165 + mixer->initialize();
165 166 }
166 167 running = false;
167 168 }
... ...
servico/src/serviceWindowGenerationFromSRT.cpp
... ... @@ -170,10 +170,11 @@ void ServiceWindowGenerationFromSRT::notifyRenderer(string glosa) {
170 170 }
171 171  
172 172 void ServiceWindowGenerationFromSRT::notifyEndOfRenderization() {
173   - mixer = new Mixer();
  173 + mixer = new Mixer(this->path_input, this->path_libras, this->size, this->position,
  174 + this->transparency, this->user_id, this->path_uploads, this->path_contents);
  175 +
174 176 if(this->service_type == SERVICE_TYPE_SRT){
175   - mixer->initialize(this->path_input, this->path_libras, this->position, this->size,
176   - this->transparency, this->user_id, this->path_uploads, this->path_contents);
  177 + mixer->initialize();
177 178 }
178 179 this->running = false;
179 180 }
... ...