Adding metadata from format, audio stream, and video streams to ReaderBase.info, which in some cases includes the 'rotate' metadata added by certain cameras, and audio metadata like title, album, artist, copyright, dates, etc... Auto-Rotates any Clip with Reader metadata 'rotate' attribute.

This commit is contained in:
Jonathan Thomas
2018-02-03 01:57:18 -06:00
parent 7b13001bf7
commit f2b0f3a0f4
9 changed files with 101 additions and 13 deletions

View File

@@ -100,6 +100,13 @@ void ReaderBase::DisplayInfo() {
cout << "--> Audio Stream Index: " << info.audio_stream_index << endl;
cout << "--> Audio Timebase: " << info.audio_timebase.ToDouble() << " (" << info.audio_timebase.num << "/" << info.audio_timebase.den << ")" << endl;
cout << "----------------------------" << endl;
cout << "--------- Metadata ---------" << endl;
cout << "----------------------------" << endl;
// Iterate through metadata
map<string, string>::iterator it;
for (it = info.metadata.begin(); it != info.metadata.end(); it++)
cout << "--> " << it->first << ": " << it->second << endl;
}
// Generate Json::JsonValue for this object
@@ -147,6 +154,12 @@ Json::Value ReaderBase::JsonValue() {
root["audio_timebase"]["num"] = info.audio_timebase.num;
root["audio_timebase"]["den"] = info.audio_timebase.den;
// Append metadata map
root["metadata"] = Json::Value(Json::objectValue);
map<string, string>::iterator it;
for (it = info.metadata.begin(); it != info.metadata.end(); it++)
root["metadata"][it->first] = it->second;
// return JsonValue
return root;
}
@@ -226,4 +239,10 @@ void ReaderBase::SetJsonValue(Json::Value root) {
if (!root["audio_timebase"]["den"].isNull())
info.audio_timebase.den = root["audio_timebase"]["den"].asInt();
}
if (!root["metadata"].isNull() && root["metadata"].isObject()) {
for( Json::Value::iterator itr = root["metadata"].begin() ; itr != root["metadata"].end() ; itr++ ) {
string key = itr.key().asString();
info.metadata[key] = root["metadata"][key].asString();
}
}
}