From 8bba898010f1a8f728a0a7e91be93a0671a4efed Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Tue, 5 Nov 2013 12:02:21 +0000 Subject: video bank simple --- rotord/src/rotor.h | 103 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 65 insertions(+), 38 deletions(-) diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index ea9d144..6c03ea0 100644 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -512,37 +512,6 @@ namespace Rotor { } } } - protected: - Image in1,in2,in2t,temp; //for blend frames; - libav::video_decoder player; - int lastframe; - bool isLoaded; - }; - //relative timelines used to stretch video - //1. make a video position input for video node - seconds and stretch modes - //2. video mode that maps to duration- timeline remapping from cycler and others - class Video_loader: public Base_video { - public: - Video_loader(){ - create_attribute("filename","name of video file to load","File name",""); - create_attribute("media_id","media_id","media_id","media_id"); //for rotorW - title="Video loader"; - description="Loads a video file"; - UID="5b64b8ca-2d0a-11e3-92ed-4b7420b40040"; - }; - Video_loader(map &settings): Video_loader() { - base_settings(settings); - if (attributes["filename"]->value!="") { - isLoaded=load(find_setting(settings,"media_path","")+attributes["filename"]->value); - } - - }; - ~Video_loader(){}; - void init_attribute(const string &attr){ - if (attr=="filename") { - load(attributes["media_path"]->value+attributes[attr]->value); - } - }; Image *output(const Frame_spec &frame){ if (isLoaded){ float clipframerate=(parameters["framerate"]->value==0.0f?player.get_framerate():parameters["framerate"]->value); @@ -575,6 +544,37 @@ namespace Rotor { } return nullptr; }; + protected: + Image in1,in2,in2t,temp; //for blend frames; + libav::video_decoder player; + int lastframe; + bool isLoaded; + }; + //relative timelines used to stretch video + //1. make a video position input for video node - seconds and stretch modes + //2. video mode that maps to duration- timeline remapping from cycler and others + class Video_loader: public Base_video { + public: + Video_loader(){ + create_attribute("filename","name of video file to load","File name",""); + create_attribute("media_id","media_id","media_id","media_id"); //for rotorW + title="Video loader"; + description="Loads a video file"; + UID="5b64b8ca-2d0a-11e3-92ed-4b7420b40040"; + }; + Video_loader(map &settings): Video_loader() { + base_settings(settings); + if (attributes["filename"]->value!="") { + isLoaded=load(find_setting(settings,"media_path","")+attributes["filename"]->value); + } + + }; + ~Video_loader(){}; + void init_attribute(const string &attr){ + if (attr=="filename") { + load(attributes["media_path"]->value+attributes[attr]->value); + } + }; Video_loader* clone(map &_settings) { return new Video_loader(_settings);}; bool isLoaded; private: @@ -592,26 +592,53 @@ namespace Rotor { UID="73616e66-4306-11e3-981e-74d02b29f6a6"; title="Video bank"; description="Loads a banks of video files"; - clip_loaded=0; //uses 1-index + clip_loaded=-1; + isLoaded=false; }; Video_bank(map &settings): Video_bank() { base_settings(settings); media_path=find_setting(settings,"media_path",""); }; Image *output(const Frame_spec &frame){ + if (!inputs[0]->connection){ //default to single loader + if (!isLoaded){ + if (load(media_path+attributes["filenames"]->vals[0] )) { + isLoaded=true; + } + else { + isLoaded=false; + } + } + if (isLoaded){ + return Base_video::output(frame); + } + return nullptr; + } if (attributes["filenames"]->vals.size()){ float ph=inputs[0]->get((Time_spec)frame); int wv=((int)ph)%attributes["filenames"]->vals.size(); ph=fmod(ph,wv); - if (clip_loaded!=wv+1){ + if (clip_loaded!=wv){ if (load(media_path+attributes["filenames"]->vals[wv] )) { - clip_loaded=wv+1; + clip_loaded=wv; + isLoaded=true; + } + else { + //cerr<<"Video bank could not load "<<(media_path+attributes["filenames"]->vals[wv])<intVal){ + case VIDEOTIME_play: + wanted=ph*player.get_number_frames(); + break; + case VIDEOTIME_stretch: + wanted=ph*player.get_number_frames(); + break; + } + if (Base_video::get_frame(wanted,frame)) return ℑ } } -- cgit v1.2.3