diff options
Diffstat (limited to 'rotord/src/rotor.cpp')
| -rwxr-xr-x | rotord/src/rotor.cpp | 77 |
1 files changed, 17 insertions, 60 deletions
diff --git a/rotord/src/rotor.cpp b/rotord/src/rotor.cpp index 8b72c50..77433ac 100755 --- a/rotord/src/rotor.cpp +++ b/rotord/src/rotor.cpp @@ -268,22 +268,7 @@ bool Video_output::render(const float duration, const float framerate,const stri } bool Video_loader::load(const string &filename){ - /* - //gstreamer needs absolute paths ALWAYS - //string uri="file:///home/tim/workspace/rotor/rotord/"+filename; - Poco::Path path; - string uri="file://"+path.current()+filename; - //cerr << "video input: loading "<<uri<<endl; - if (player->loadMovie(uri)){ - player->play(); - player->setPaused(true); - player->setFrameByFrame(true); - player->update(); - cerr<<"Rotor::Video_loader: "<<filename<<", "<<player->getDuration()<<" seconds "<<", "<<player->getWidth()<<"x"<<player->getHeight()<<endl; - image->setup_fromRGB(player->getWidth(),player->getHeight(),(uint8_t*) player->getPixels()); - return true; - } - */ + if (isLoaded) { player.cleanup(); ///should be in decoder class? isLoaded=false; @@ -299,63 +284,35 @@ bool Video_loader::load(const string &filename){ return false; } Image* Video_loader::output(const Frame_spec &frame){ - //wonder about the actual mechanism used by gstreamer - //have to implment callback when seek is ready? - //presume gstreamer caches a loaded frame? - - - //deal with reolution: swscale from avcodec or put scaler in pipeline? - //can image node point to buffer in gst rather than copying the pixels? - - //to test using fp time to seek: need a short movie with synced audio - - //fix actual duration and audio file - //trace frame that is being read - /* - if (player->isLoaded()){ - //player->setPosition(frame.time); - int wanted=((int) (frame.time*frame.framerate))%(player->getTotalNumFrames()-2); //-2?? - player->setFrame(wanted); - //while (player->getCurrentFrame()!=wanted){ - // cerr << "seeking to "<<wanted<<" :"<<player->getCurrentFrame()<<endl; - //player->setFrame(wanted); - //player->update(); - // sleep(.001); - //} - player->update(); - image->RGBdata=player->getPixels(); //don't really know why this is needed every frame - //cerr<<"Video_loader: retrieving frame "<<((int) (frame.time*frame.framerate))<<endl; - return image; - } - */ if (isLoaded){ int wanted=(((int) ((frame.time*frame.framerate)+0.5))%(player.getNumberOfFrames())); //+1 is necessary because 1st frame in a video is number 1? - - //if (wanted==99){ - // cerr<<"videoloader: near the end"<<endl; - //} - - //cerr<<"videoloader: requesting frame "<<wanted<<endl; - //if (wanted==68) { - // int nothing=0; - //} - if (!player.fetchFrame(frame.w,frame.h,wanted)) { //seek fail cerr<<"Rotor: failed to seek frame"<<endl; if (image.w>0) return ℑ //just return the previous frame if possible else return nullptr; }; - //cerr<<"Video_loader: setting up frame: lineoffset="<<(player.pFrameRGB->linesize[0]-(frame.w*3))<<endl; image.setup_fromRGB(frame.w,frame.h,player.pFrameRGB->data[0],player.pFrameRGB->linesize[0]-(frame.w*3)); return ℑ } + return nullptr; +}; +/* +bool CVideo_loader::load(const string &filename){ - //confusingly, crashes with files not made with short files? - //seems to be on last frame? - returns nullptr - still tries to clone? - //can't really return 1st frame instead, should get # of frames right 1st? - //think about what echo trails does on the last frame + Poco::Path path; + string uri="file://"+filename; + isLoaded=player.open(filename); + if (isLoaded){ + cerr<<"Rotor::Video_loader: "<<filename<<", "<<player.get(CV_CAP_PROP_FRAME_COUNT)<<" frames "<<", "<<player.get(CV_CAP_PROP_FRAME_WIDTH)<<"x"<<player.get(CV_CAP_PROP_FRAME_HEIGHT)<<endl; + return true; + } + cerr<<"Rotor::Video_loader: failed to load "<<filename<<endl; + return false; +} +Image* CVideo_loader::output(const Frame_spec &frame){ return nullptr; }; +*/
\ No newline at end of file |
