summaryrefslogtreecommitdiff
path: root/rotord/src
diff options
context:
space:
mode:
Diffstat (limited to 'rotord/src')
-rw-r--r--rotord/src/rotor.h103
1 files 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<string,string> &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<string,string> &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<string,string> &_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<string,string> &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])<<endl;
+ clip_loaded=-1;
}
- else clip_loaded=0;
}
- if (clip_loaded){
- int wanted=ph*player.get_number_frames();
-
+ if (isLoaded){
+ int wanted;
+ switch (attributes["frame_mode"]->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 &image;
}
}