diff options
| author | Tim Redfern <tim@eclectronics.org> | 2014-02-15 11:42:19 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2014-02-15 11:42:19 +0000 |
| commit | ad86bb9b35c8f2e96982b99356909e604b1058e2 (patch) | |
| tree | c447969bbd73792a34fd4da47a1d2dbf277ff0f8 /rotord/src | |
| parent | 0b453608ed7a658ee7c6ad0cf8bb3fc322a1b666 (diff) | |
media proxies not quite right
Diffstat (limited to 'rotord/src')
| -rw-r--r-- | rotord/src/rotor.h | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index fd59c68..8499408 100644 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -788,23 +788,27 @@ namespace Rotor { create_attribute("media_id","media_id","media_id","media_id"); //for rotorW NODEID="e92255a0-447a-11e3-b0ce-3fc7ff4bdac9"; isLoaded=false; + isLoadable=true; }; bool load(const string &filename,const int h=0){ Poco::Logger& logger = Poco::Logger::get(Log_name); + std::string file_use; if (h>0&&h<721){ Poco::Path path(filename); - std::string stub(path.getBaseName()); + std::string stub(path.getBaseName()+".proxies/"); std::string suffix(path.getExtension()); - std::string size=h>359?"/720.":h>179?"/360.":"/180."; - Poco::File file_to_use(stub+size+suffix); - if (file_to_use.exists()){ - cerr<<"using prescaled file: "<<stub<<size<<suffix<<endl; + std::string pathto="/"; + for (int i=0;i<path.depth();i++){ + pathto=pathto+path[i]+"/"; } - else cerr<<"could not find prescaled file: "<<stub<<size<<suffix<<" for "<<filename<<endl; + std::string size=h>360?"720.":h>180?"360.":"180."; + Poco::File file_to_use(pathto+stub+size+suffix); + if (file_to_use.exists()) file_use=pathto+stub+size+suffix; + else file_use=filename; } - isLoaded=player.open(filename); + isLoaded=player.open(file_use); if (isLoaded){ - logger.information("libav::decoder loaded "+filename+": "\ + logger.information("libav::decoder loaded "+file_use+": "\ +toString(player.get_number_frames())+" frames, "\ +toString(player.get_framerate())+" fps, "\ +toString(player.get_width())+"x"+toString(player.get_height())\ @@ -812,7 +816,8 @@ namespace Rotor { lastframe=-2; return true; } - logger.error("libav::decoder failed to load "+filename); + logger.error("libav::decoder failed to load "+file_use); + isLoadable=false; return false; } bool get_frame(double wanted,const Frame_spec &frame){ @@ -894,6 +899,7 @@ namespace Rotor { libav::video_decoder player; int lastframe; bool isLoaded; + bool isLoadable; string media_path; }; //relative timelines used to stretch video @@ -920,6 +926,12 @@ namespace Rotor { }; ~Video_loader(){}; + Image *output(const Frame_spec &frame){ + if (!isLoaded&&isLoadable){ + isLoaded=load(media_path+attributes["filename"]->value,frame.h); + } + Base_video::output(frame); + } //void init_attribute(const string &attr){ // if (attr=="filename") { // isLoaded=load(media_path+attributes[attr]->value); @@ -957,7 +969,7 @@ namespace Rotor { if (!inputs[0]->connection){ //default to single loader if the selector isn't in use if (!isLoaded){ if (attributes["filenames"]->vals.size()){ - if (load(media_path+attributes["filenames"]->vals[0])) { + if (load(media_path+attributes["filenames"]->vals[0],frame.h)) { isLoaded=true; } } @@ -973,7 +985,7 @@ namespace Rotor { int wv=seg%attributes["filenames"]->vals.size(); ph=seg==0?ph:fmod(ph,seg); if (clip_loaded!=wv){ - if (load(media_path+attributes["filenames"]->vals[wv])) { //check if loading is succesful + if (load(media_path+attributes["filenames"]->vals[wv],frame.h)) { //check if loading is succesful clip_loaded=wv; isLoaded=true; lastframe=-2; |
