Added a -c / --compact flag to MistAnalyserDTSC
This commit is contained in:
parent
24ca250d2e
commit
5a8b9be44a
3 changed files with 49 additions and 1 deletions
|
@ -113,8 +113,10 @@ namespace h264 {
|
|||
}
|
||||
|
||||
char profileIdc = bs.get(8);
|
||||
result.profile = profileIdc;
|
||||
//Start skipping unused data
|
||||
bs.skip(16);
|
||||
bs.skip(8);
|
||||
result.level = bs.get(8);
|
||||
bs.getUExpGolomb();
|
||||
if (profileIdc == 100 || profileIdc == 110 || profileIdc == 122 || profileIdc == 244 || profileIdc == 44 || profileIdc == 83 || profileIdc == 86 || profileIdc == 118 || profileIdc == 128) {
|
||||
//chroma format idc
|
||||
|
|
|
@ -12,6 +12,8 @@ namespace h264 {
|
|||
unsigned int width;
|
||||
unsigned int height;
|
||||
double fps;
|
||||
uint8_t profile;
|
||||
uint8_t level;
|
||||
};
|
||||
|
||||
///Class for analyzing generic nal units
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <mist/json.h>
|
||||
#include <mist/config.h>
|
||||
#include <mist/defines.h>
|
||||
#include <mist/h264.h>
|
||||
|
||||
///\brief Holds everything unique to the analysers.
|
||||
namespace Analysers {
|
||||
|
@ -23,6 +24,48 @@ namespace Analysers {
|
|||
std::cerr << "Not a valid DTSC file" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (conf.getBool("compact")){
|
||||
JSON::Value result;
|
||||
for (std::map<unsigned int, DTSC::Track>::iterator it = F.getMeta().tracks.begin(); it != F.getMeta().tracks.end(); it++){
|
||||
JSON::Value track;
|
||||
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["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;
|
||||
}
|
||||
std::cout << result.toString();
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (F.getMeta().vod || F.getMeta().live){
|
||||
F.getMeta().toPrettyString(std::cout,0, 0x03);
|
||||
}
|
||||
|
@ -63,6 +106,7 @@ namespace Analysers {
|
|||
int main(int argc, char ** argv){
|
||||
Util::Config conf = Util::Config(argv[0]);
|
||||
conf.addOption("filename", JSON::fromString("{\"arg_num\":1, \"arg\":\"string\", \"help\":\"Filename of the DTSC file to analyse.\"}"));
|
||||
conf.addOption("compact", JSON::fromString("{\"short\": \"c\", \"long\": \"compact\", \"help\":\"Filename of the DTSC file to analyse.\"}"));
|
||||
conf.parseArgs(argc, argv);
|
||||
return Analysers::analyseDTSC(conf);
|
||||
} //main
|
||||
|
|
Loading…
Add table
Reference in a new issue