From 836848622f85231c3ff6b9af49704fec4c035df4 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Tue, 30 Apr 2013 15:31:00 +0100 Subject: first synced render --- rotord/rotor.cpp | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'rotord/rotor.cpp') 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()<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 (vfpts 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"<finishRecord(); cerr << "Rotor: Video_output finished "<< endl; -- cgit v1.2.3