Converter API New Version for mistinfo
This commit is contained in:
parent
68f44c3d29
commit
5db07ea5ed
2 changed files with 62 additions and 0 deletions
44
lib/converter.cpp
Normal file
44
lib/converter.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
#include "converter.h"
|
||||
#include "procs.h"
|
||||
|
||||
namespace Converter {
|
||||
|
||||
Converter::Converter(){
|
||||
fillFFMpegEncoders();
|
||||
}
|
||||
|
||||
void Converter::fillFFMpegEncoders(){
|
||||
std::vector<std::string> cmd;
|
||||
cmd.push_back("ffmpeg");
|
||||
cmd.push_back("-encoders");
|
||||
int outFD = -1;
|
||||
Util::Procs::StartPiped("FFMpegInfo", cmd, 0, &outFD, 0);
|
||||
FILE * outFile = fdopen( outFD, "r" );
|
||||
char * fileBuf = 0;
|
||||
size_t fileBufLen = 0;
|
||||
while ( !(feof(outFile) || ferror(outFile))){
|
||||
getline(&fileBuf, &fileBufLen, outFile);
|
||||
if (strstr(fileBuf, "aac") || strstr(fileBuf, "AAC")){
|
||||
strtok(fileBuf, " \t");
|
||||
allCodecs["ffmpeg"][strtok(NULL, " \t")] = "aac";
|
||||
}
|
||||
if (strstr(fileBuf, "h264") || strstr(fileBuf, "H264")){
|
||||
strtok(fileBuf, " \t");
|
||||
allCodecs["ffmpeg"][strtok(NULL, " \t")] = "h264";
|
||||
}
|
||||
if (strstr(fileBuf, "mp3") || strstr(fileBuf, "MP3")){
|
||||
strtok(fileBuf, " \t");
|
||||
allCodecs["ffmpeg"][strtok(NULL, " \t")] = "mp3";
|
||||
}
|
||||
}
|
||||
fclose( outFile );
|
||||
}
|
||||
|
||||
|
||||
converterInfo & Converter::getCodecs() {
|
||||
return allCodecs;
|
||||
}
|
||||
}
|
18
lib/converter.h
Normal file
18
lib/converter.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "json.h"
|
||||
|
||||
typedef std::map<std::string,std::string> codecInfo;
|
||||
typedef std::map<std::string,codecInfo> converterInfo;
|
||||
|
||||
namespace Converter {
|
||||
class Converter {
|
||||
public:
|
||||
Converter();
|
||||
converterInfo & getCodecs();
|
||||
private:
|
||||
void fillFFMpegEncoders();
|
||||
converterInfo allCodecs;
|
||||
};
|
||||
}
|
Loading…
Add table
Reference in a new issue