diff options
| author | Tim Redfern <tim@eclectronics.org> | 2013-08-20 14:49:48 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2013-08-20 14:49:48 +0100 |
| commit | b79752f96f9e58c0b4636cc024add698e0ce0c5f (patch) | |
| tree | ad3fa86f4bf806df98780c65e5eac5bcac3e09e7 /rotord/src/rotor.cpp | |
| parent | ad0e8b3e7f1d8889244f15134a00d1ac4803d9c3 (diff) | |
frame mode for video loader + audio output bugfix
Diffstat (limited to 'rotord/src/rotor.cpp')
| -rwxr-xr-x | rotord/src/rotor.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/rotord/src/rotor.cpp b/rotord/src/rotor.cpp index 7ab9e54..73ef0cc 100755 --- a/rotord/src/rotor.cpp +++ b/rotord/src/rotor.cpp @@ -199,12 +199,8 @@ bool Video_output::render(const float duration, const float framerate,const stri libav::audioloader audioloader; - bool usingaudio=false; + bool usingaudio=audioloader.setup(audio_filename); float *avframe=nullptr; - if (audioloader.setup(audio_filename)){ - bool usingaudio=true; - //avframe=new float[audioloader.channels*] - } Logger& logger = Logger::get("Rotor"); @@ -216,6 +212,11 @@ bool Video_output::render(const float duration, const float framerate,const stri gettimeofday(&start, NULL); + //does audioloader output interleaved samples? + int samples_in_frame=(audioloader.codecContext->channels*audioloader.codecContext->sample_rate)/framerate; + string whether=usingaudio?"Loading":"Cannot load"; + logger.information(whether+" audio file: "+audio_filename+", each frame contains "+ofToString(samples_in_frame)+" samples at "+ofToString(audioloader.codecContext->sample_rate)+" hz"); + float vstep=1.0f/framerate; float v=0.0f; float vf=0.0f; @@ -302,7 +303,16 @@ Image* Video_loader::output(const Frame_spec &frame){ float clipspeed=(clipframerate/frame.framerate)*parameters["speed"]->value; - int wanted=(((int) ((frame.time*frame.framerate*clipspeed)+0.5))%(player.getNumberOfFrames()-1))+1; //+1 is necessary because 1st frame in a video is number 1? + int wanted; + if (attributes["mode"]->intVal==VIDEOFRAMES_frame) { + wanted=(((int) ((frame.time*frame.framerate)+0.5))%(player.getNumberOfFrames()-1))+1; //+1 is necessary because 1st frame in a video is number 1? + } + if (attributes["mode"]->intVal==VIDEOFRAMES_blend) { + wanted=(((int) ((frame.time*frame.framerate*clipspeed)+0.5))%(player.getNumberOfFrames()-1))+1; //+1 is necessary because 1st frame in a video is number 1? + } + + cerr<<"Video_loader: wanted frame "<<wanted<<endl; + if (wanted!=lastframe){ if (!player.fetchFrame(frame.w,frame.h,wanted)) { //seek fail Logger& logger = Logger::get("Rotor"); |
