summaryrefslogtreecommitdiff
path: root/rotord/rotor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'rotord/rotor.cpp')
-rwxr-xr-xrotord/rotor.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/rotord/rotor.cpp b/rotord/rotor.cpp
index 23e2196..84578db 100755
--- a/rotord/rotor.cpp
+++ b/rotord/rotor.cpp
@@ -166,9 +166,9 @@ bool Video_output::render(const float duration, const float framerate,const stri
int frameRate=25;
AVCodecID codecId=AV_CODEC_ID_MPEG4;
std::string container ="mov";
- std::string input ="01.mp3";
- bool usingaudio=audioloader.setup(input);
+ bool usingaudio=audioloader.setup(audio_filename);
+ //at the moment it crashes if you render before audio is loaded
if (exporter->setup(outW,outH,bitRate,frameRate,container)) { //codecId,
if (exporter->record(output_filename)) {
@@ -177,7 +177,9 @@ bool Video_output::render(const float duration, const float framerate,const stri
float step=1.0f/framerate;
float v=0.0f;
for (float f=0.0f;f<duration;f+=step) {
- if (!exporter->encodeFrame(get_output(Frame_spec(f,framerate,outW,outH))->RGBdata,audioloader.get_samples(exporter->get_audio_framesize()))){
+ uint16_t* s=audioloader.get_samples(exporter->get_audio_framesize());
+ Image* i=get_output(Frame_spec(f,framerate,outW,outH));
+ if (!exporter->encodeFrame(i->RGBdata,s)){
//if (!exporter->encodeFrame(get_output(Frame_spec(f,framerate,outW,outH))->RGBdata,audioloader.get_packet())){
cerr << "Rotor: video output failed"<<endl;
break;
@@ -193,10 +195,17 @@ bool Video_output::render(const float duration, const float framerate,const stri
}
bool Video_input::load(const string &filename){
- if (player->loadMovie(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);
- cerr<<"loaded "<<filename<<", "<<player->getDuration()<<" seconds "<<", "<<player->getWidth()<<"x"<<player->getWidth()<<endl;
+ player->update();
+ cerr<<"Rotor::Video_input loaded "<<filename<<", "<<player->getDuration()<<" seconds "<<", "<<player->getWidth()<<"x"<<player->getHeight()<<endl;
+ image->setup_fromRGB(player->getWidth(),player->getHeight(),(uint8_t*) player->getPixels());
return true;
}
return false;
@@ -209,5 +218,20 @@ Image* Video_input::get_output(const Frame_spec &frame){
// image.setup(player)
//}
+
+ //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);
+ player->setFrame((int) (frame.time*frame.framerate));
+ player->update();
+ cerr<<"Video_input: retrieving frame "<<((int) (frame.time*frame.framerate))<<endl;
+ return image;
+ }
return nullptr;
};