Merge branch 'development' into LTS_development

# Conflicts:
#	src/analysers/dtsc_analyser.cpp
This commit is contained in:
Thulinma 2016-10-11 15:11:07 +02:00
commit 44e1bb9b33

View file

@ -26,42 +26,53 @@ namespace Analysers {
}
if (conf.getBool("compact")){
bool hasH264 = false;
bool hasAAC = false;
bool unstable_keys = false;
bool unstable_parts = false;
JSON::Value result;
std::stringstream issues;
for (std::map<unsigned int, DTSC::Track>::iterator it = F.getMeta().tracks.begin(); it != F.getMeta().tracks.end(); it++){
JSON::Value track;
track["kbits"] = (long long)((double)it->second.bps * 8 / 1024);
track["codec"] = it->second.codec;
uint32_t shrtest_key = 0xFFFFFFFFul;
uint32_t longest_key = 0;
uint32_t shrtest_prt = 0xFFFFFFFFul;
uint32_t longest_prt = 0;
uint32_t shrtest_cnt = 0xFFFFFFFFul;
uint32_t longest_cnt = 0;
for (std::deque<DTSC::Key>::iterator k = it->second.keys.begin(); k != it->second.keys.end(); k++){
if (!k->getLength()){continue;}
if (k->getLength() > longest_key){longest_key = k->getLength();}
if (k->getLength() < shrtest_key){shrtest_key = k->getLength();}
if (k->getParts() > longest_cnt){longest_cnt = k->getParts();}
if (k->getParts() < shrtest_cnt){shrtest_cnt = k->getParts();}
if ((k->getLength()/k->getParts()) > longest_prt){longest_prt = (k->getLength()/k->getParts());}
if ((k->getLength()/k->getParts()) < shrtest_prt){shrtest_prt = (k->getLength()/k->getParts());}
}
track["keys"]["min"] = (long long)shrtest_key;
track["keys"]["max"] = (long long)longest_key;
track["prts"]["min"] = (long long)shrtest_prt;
track["prts"]["max"] = (long long)longest_prt;
track["count"]["min"] = (long long)shrtest_cnt;
track["count"]["max"] = (long long)longest_cnt;
if (shrtest_key < longest_key / 2){issues << it->second.codec << " key duration unstable (variable key interval!) (" << shrtest_key << "-" << longest_key << ")! ";}
if ((shrtest_prt < longest_prt / 2) && (shrtest_cnt != longest_cnt)){issues << it->second.codec << " part duration unstable (bad connection!) (" << shrtest_prt << "-" << longest_prt << ")! ";}
if (it->second.codec == "AAC"){hasAAC = true;}
if (it->second.codec == "H264"){hasH264 = true;}
if (it->second.type=="video"){
std::stringstream tStream;
track["resolution"] = JSON::Value((long long)it->second.width).asString() + "x" + JSON::Value((long long)it->second.height).asString();
track["fps"] = (long long)((double)it->second.fpks / 1000);
track["width"] = (long long)it->second.width;
track["height"] = (long long)it->second.height;
track["fpks"] = it->second.fpks;
tStream << it->second.bps * 8 << " b/s, " << (double)it->second.bps * 8 / 1024 << " kb/s, " << (double)it->second.bps * 8 / 1024 / 1024 << " mb/s";
track["bitrate"] = tStream.str();
tStream.str("");
track["keyframe_duration"] = (long long)((float)(it->second.lastms - it->second.firstms) / it->second.keys.size());
tStream << ((double)(it->second.lastms - it->second.firstms) / it->second.keys.size()) / 1000;
track["keyframe_interval"] = tStream.str();
tStream.str("");
if (it->second.codec == "H264"){
h264::sequenceParameterSet sps;
sps.fromDTSCInit(it->second.init);
h264::SPSMeta spsData = sps.getCharacteristics();
track["encoding"]["width"] = spsData.width;
track["encoding"]["height"] = spsData.height;
tStream << spsData.fps;
track["encoding"]["fps"] = tStream.str();
track["encoding"]["profile"] = spsData.profile;
track["encoding"]["level"] = spsData.level;
}
}
if (it->second.type == "audio"){
std::stringstream tStream;
tStream << it->second.bps * 8 << " b/s, " << (double)it->second.bps * 8 / 1024 << " kb/s, " << (double)it->second.bps * 8 / 1024 / 1024 << " mb/s";
track["bitrate"] = tStream.str();
track["keyframe_interval"] = (long long)((float)(it->second.lastms - it->second.firstms) / it->second.keys.size());
}
result[it->second.getWritableIdentifier()] = track;
}
if (hasAAC || hasH264){
if (!hasAAC){issues << "video-only! ";}
if (!hasH264){issues << "audio-only! ";}
}
if (issues.str().size()){result["issues"] = issues.str();}
std::cout << result.toString();
return 0;
}