Working encoder detection
This commit is contained in:
parent
5db07ea5ed
commit
21a9aaab98
4 changed files with 24 additions and 11 deletions
|
@ -1,6 +1,8 @@
|
|||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include "timing.h"
|
||||
#include "converter.h"
|
||||
#include "procs.h"
|
||||
|
||||
|
@ -10,17 +12,18 @@ namespace Converter {
|
|||
fillFFMpegEncoders();
|
||||
}
|
||||
|
||||
void Converter::fillFFMpegEncoders(){
|
||||
std::vector<std::string> cmd;
|
||||
cmd.push_back("ffmpeg");
|
||||
cmd.push_back("-encoders");
|
||||
void Converter::fillFFMpegEncoders(){
|
||||
char ** cmd = (char**)malloc(3*sizeof(char*));
|
||||
cmd[0] = "ffmpeg";
|
||||
cmd[1] = "-encoders";
|
||||
cmd[2] = NULL;
|
||||
int outFD = -1;
|
||||
Util::Procs::StartPiped("FFMpegInfo", cmd, 0, &outFD, 0);
|
||||
while( Util::Procs::isActive("FFMpegInfo")){ Util::sleep(100); }
|
||||
FILE * outFile = fdopen( outFD, "r" );
|
||||
char * fileBuf = 0;
|
||||
size_t fileBufLen = 0;
|
||||
while ( !(feof(outFile) || ferror(outFile))){
|
||||
getline(&fileBuf, &fileBufLen, outFile);
|
||||
while ( !(feof(outFile) || ferror(outFile)) && (getline(&fileBuf, &fileBufLen, outFile) != -1)){
|
||||
if (strstr(fileBuf, "aac") || strstr(fileBuf, "AAC")){
|
||||
strtok(fileBuf, " \t");
|
||||
allCodecs["ffmpeg"][strtok(NULL, " \t")] = "aac";
|
||||
|
@ -37,8 +40,17 @@ namespace Converter {
|
|||
fclose( outFile );
|
||||
}
|
||||
|
||||
|
||||
converterInfo & Converter::getCodecs() {
|
||||
converterInfo & Converter::getCodecs(){
|
||||
return allCodecs;
|
||||
}
|
||||
|
||||
JSON::Value Converter::getEncoders(){
|
||||
JSON::Value Result;
|
||||
for (converterInfo::iterator convIt = allCodecs.begin(); convIt != allCodecs.end(); convIt++){
|
||||
for (codecInfo::iterator codIt = convIt->second.begin(); codIt != convIt->second.end(); codIt++){
|
||||
Result[convIt->first][codIt->first] = codIt->second;
|
||||
}
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue