summaryrefslogtreecommitdiff
path: root/rotord/rotor.cpp
diff options
context:
space:
mode:
authorTim Redfern <tim@herge.(none)>2013-04-30 15:31:00 +0100
committerTim Redfern <tim@herge.(none)>2013-04-30 15:31:00 +0100
commit836848622f85231c3ff6b9af49704fec4c035df4 (patch)
treef36cd2e9bd98e2712807c1a5f1be311b5733f6aa /rotord/rotor.cpp
parentcaf495afbda7c12da090a9fc7b08c4e7d44420ff (diff)
first synced render
Diffstat (limited to 'rotord/rotor.cpp')
-rwxr-xr-xrotord/rotor.cpp33
1 files changed, 27 insertions, 6 deletions
diff --git a/rotord/rotor.cpp b/rotord/rotor.cpp
index d295c9f..c79a9c7 100755
--- a/rotord/rotor.cpp
+++ b/rotord/rotor.cpp
@@ -6,6 +6,11 @@ bool fequal(const float u,const float v){
if (abs(u-v)<.001) return true;
else return false;
};
+bool flessorequal(const float u,const float v){
+ //v is less or equal to u
+ if (u-v>-.001) return true;
+ else return false;
+};
using namespace Rotor;
@@ -175,13 +180,28 @@ bool Video_output::render(const float duration, const float framerate,const stri
if (exporter->setup(outW,outH,bitRate,frameRate,container)) { //codecId,
if (exporter->record(output_filename)) {
- cerr << "Rotor: Video_output rendering " << duration << " seconds at " << framerate << " fps" << endl;
- float step=1.0f/framerate;
+ cerr << "Rotor: Video_output rendering " << duration << " seconds at " << framerate << " fps, audio frame size: " << exporter->get_audio_framesize()<<endl;
+ //25fps video and 43.06640625fps audio? hmm
+ //how to get the timecodes correct for the interleaved files
+
+ float vstep=1.0f/framerate;
float v=0.0f;
- for (float f=0.0f;f<duration;f+=step) {
- 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)){
+ float vf=0.0f;
+ float af=0.0f;
+ while (vf<duration) { //float f=0.0f;f<duration;f+=step) {
+ //seems to be that the audio frames have to be a little ahead
+ //and the frame->pts comes from video
+ while (flessorequal(vf,af)) {
+ //insert audio frames until we are ahead of the video
+ uint16_t* s=audioloader.get_samples(exporter->get_audio_framesize());
+ exporter->encodeFrame(s);
+ af+=exporter->get_audio_step();
+ }
+ Image* i=get_output(Frame_spec(vf,framerate,outW,outH));
+ exporter->encodeFrame(i->RGBdata);
+ vf+=vstep;
+ /*
+ if (!exporter->encodeFrame(i->RGBdata)){
//if (!exporter->encodeFrame(get_output(Frame_spec(f,framerate,outW,outH))->RGBdata,audioloader.get_packet())){
cerr << "Rotor: video output failed"<<endl;
break;
@@ -193,6 +213,7 @@ bool Video_output::render(const float duration, const float framerate,const stri
cerr<<"stop here"<<endl;
}
}
+ */
}
exporter->finishRecord();
cerr << "Rotor: Video_output finished "<< endl;