diff options
Diffstat (limited to 'rotord')
| -rw-r--r-- | rotord/src/graph.cpp | 25 | ||||
| -rw-r--r-- | rotord/src/libavwrapper.h | 9 |
2 files changed, 21 insertions, 13 deletions
diff --git a/rotord/src/graph.cpp b/rotord/src/graph.cpp index 6994614..9088a8a 100644 --- a/rotord/src/graph.cpp +++ b/rotord/src/graph.cpp @@ -478,7 +478,8 @@ bool Graph::parseJson(string &data,string &media_path){ //this always falls over on DDs 3404.json file WHY? //is there way to make a json value safe? - //analysis_seed=root.get("seed","0").asInt(); + // + analysis_seed=root.get("seed",0).asInt(); check_audio(root.get("audio","").asString(),media_path); init(root.get("ID","").asString(),root.get("description","").asString()); Json::Value jnodes = root["nodeDefinitions"]; @@ -487,27 +488,27 @@ bool Graph::parseJson(string &data,string &media_path){ //cerr<<"json found node: "<<jnodes[i]["type"].asString()<<endl; map<string,string> settings; vector<string> attrs; - settings["type"]=jnodes[i]["type"].asString(); + settings["type"]=jnodes[i].get("type","").asString(); settings["Log_name"]=Log_name; //attributes settings["media_path"]=media_path; for (uint32_t m=0;m<jnodes[i]["attributes"].size();m++) { - if (jnodes[i]["attributes"][m]["type"].asString()!="array") { - settings[jnodes[i]["attributes"][m]["name"].asString()]=jnodes[i]["attributes"][m]["value"].asString(); + if (jnodes[i]["attributes"][m].get("type","").asString()!="array") { + settings[jnodes[i]["attributes"][m].get("name","").asString()]=jnodes[i]["attributes"][m].get("value","").asString(); } } Node* node=factory.create(settings); for (uint32_t m=0;m<jnodes[i]["attributes"].size();m++){ - string attribute=jnodes[i]["attributes"][m]["name"].asString(); + string attribute=jnodes[i]["attributes"][m].get("name","").asString(); string val=""; if (node->attributes.find(attribute)!=node->attributes.end()){ Attribute *attr=node->attributes.find(attribute)->second; if (attr->type=="enum"){ - val=jnodes[i]["attributes"][m]["value"].asString(); + val=jnodes[i]["attributes"][m].get("value","").asString(); attr->init(val); } if (attr->type=="string") { - val=jnodes[i]["attributes"][m]["value"].asString(); + val=jnodes[i]["attributes"][m].get("value","").asString(); attr->init(val); } if (attr->type=="array"){ @@ -542,7 +543,7 @@ bool Graph::parseJson(string &data,string &media_path){ //signal inputs for (uint32_t j=0;j< jnodes[i]["signal_inputs"].size();j++){ if ((nodes[nodeID])->inputs.size()>j) { - string fromID=jnodes[i]["signal_inputs"][j]["from"].asString(); + string fromID=jnodes[i]["signal_inputs"][j].get("from","").asString(); if (fromID!=""){ if (nodes.find(fromID)!=nodes.end()) { if (!nodes[nodeID]->inputs[j]->connect((Signal_node*)nodes[fromID])){ @@ -582,7 +583,7 @@ bool Graph::parseJson(string &data,string &media_path){ } } if (((Image_node*)nodes[nodeID])->image_inputs.size()>k) { - string fromID=jnodes[i]["image_inputs"][k]["from"].asString(); + string fromID=jnodes[i]["image_inputs"][k].get("from","").asString(); if (fromID!=""){ if (nodes.find(fromID)!=nodes.end()) { if (dynamic_cast<Image_node*>(nodes[fromID])!=nullptr) { @@ -603,15 +604,15 @@ bool Graph::parseJson(string &data,string &media_path){ //parameters for (uint32_t l=0;l<jnodes[i]["parameters"].size();l++){ - string parameter=jnodes[i]["parameters"][l]["name"].asString(); + string parameter=jnodes[i]["parameters"][l].get("name","").asString(); if (nodes[nodeID]->parameters.find(parameter)!=nodes[nodeID]->parameters.end()) { - double val=jnodes[i]["parameters"][l]["value"].asFloat(); + double val=jnodes[i]["parameters"][l].get("value",0.0).asFloat(); if (val!=nodes[nodeID]->parameters.find(parameter)->second->value){ nodes[nodeID]->parameters.find(parameter)->second->value=val; cerr << "Rotor: set parameter '"<<parameter<<"' of "<<nodeID<<" to "<<val<<endl; } - string fromID=jnodes[i]["parameters"][l]["from"].asString(); + string fromID=jnodes[i]["parameters"][l].get("from","").asString(); if (nodes.find(fromID)!=nodes.end()) { if (!nodes[nodeID]->parameters[parameter]->connect(nodes[fromID])){ cerr << "ERROR: graph loader cannot connect parameter " << parameter << " of node '" << nodeID << "' to node '" << fromID << "'" << endl; diff --git a/rotord/src/libavwrapper.h b/rotord/src/libavwrapper.h index fc628c0..d6f411d 100644 --- a/rotord/src/libavwrapper.h +++ b/rotord/src/libavwrapper.h @@ -31,7 +31,7 @@ extern "C" { namespace libav { - // Some libavcodec calls are not reentrant + // Some libavcodec calls are not reentrant void maybeInitFFMpegLib(); class video_decoder @@ -77,6 +77,13 @@ namespace libav { std::cerr<<"ffmpegsource: "<<err.Buffer<<std::endl; return false; } + std::cerr<<"fetching frame: "<<wanted<<" of "<<props->NumFrames<<" error: "<<err.Buffer<<std::endl; + //FFMS can crash inexplicably with some long mp4 files - examples are rosetest.mp4 ninahynes.mp4 + //whatever the problem is it survives recompressing to mp4 + //but converting to mov solves the problem + //weird, are the files actually damaged? + //need to test on a different machine + //best solution might be try/catch - how is this actually used? still crashes frame = FFMS_GetFrame(source, std::max(0,wanted%props->NumFrames), &err); if (frame == NULL) { std::cerr<<"ffmpegsource: "<<err.Buffer<<std::endl; |
