diff options
Diffstat (limited to 'rotord/rotor.cpp')
| -rwxr-xr-x | rotord/rotor.cpp | 89 |
1 files changed, 50 insertions, 39 deletions
diff --git a/rotord/rotor.cpp b/rotord/rotor.cpp index e38e8d3..da5614a 100755 --- a/rotord/rotor.cpp +++ b/rotord/rotor.cpp @@ -177,9 +177,9 @@ void Audio_analysis::print_features(){ } cerr<<endl; } - /* -bool Video_output::render_encoder(const float duration, const float framerate,const string &output_filename,const string &audio_filename,float& progress){ + +bool Video_output::render(const float duration, const float framerate,const string &output_filename,const string &audio_filename,float& progress){ // //setup defaults @@ -208,15 +208,17 @@ bool Video_output::render_encoder(const float duration, const float framerate,co float vf=0.0f; float af=0.0f; while (vf<duration-vstep) { - while (!fless(af,vf)) { - //insert audio frames until we are ahead of the video - //exporter->encodeFrame(audioloader.get_samples(exporter->get_audio_framesize())); - //af+=exporter->get_audio_step(); - uint16_t *s=audioloader.get_samples(encoder.get_audio_framesize()); - encoder.write_frame(af,s); //crashes - af+=encoder.get_audio_step(); - } - + if (usingaudio) { + while (!fless(af,vf)) { + //insert audio frames until we are ahead of the video + //exporter->encodeFrame(audioloader.get_samples(exporter->get_audio_framesize())); + //af+=exporter->get_audio_step(); + int fs=encoder.get_audio_framesize(); + uint16_t *s=audioloader.get_samples(fs); + encoder.write_frame(af,s); //crashes - s seems to be 0x00 + af+=encoder.get_audio_step(); + } + } Image* i=get_output(Frame_spec(vf,framerate,duration,outW,outH)); if (i) { //exporter->encodeFrame(i->RGBdata); @@ -234,7 +236,7 @@ bool Video_output::render_encoder(const float duration, const float framerate,co // } //} - return false; + //return false; } */ @@ -247,17 +249,22 @@ bool Video_output::render(const float duration, const float framerate,const stri int bitRate=4000000; int frameRate=25; AVCodecID codecId=AV_CODEC_ID_H264; //MPEG4; - std::string container ="mov"; + std::string container ="mp4"; - bool usingaudio=audioloader.setup(audio_filename); - //at the moment it crashes if you render before audio is loaded + + //at the moment it crashes if you render before audio is loaded and also on 2nd render + libav::exporter exporter; float spct=100.0f/duration; - if (exporter->setup(outW,outH,bitRate,frameRate,container)) { //codecId, - if (exporter->record(output_filename)) { + if (exporter.setup(outW,outH,bitRate,frameRate,container)) { //codecId, + if (exporter.record(output_filename)) { + + libav::audioloader audioloader; - cerr << "Rotor: Video_output rendering " << duration << " seconds at " << framerate << " fps, audio frame size: " << exporter->get_audio_framesize()<<endl; + bool usingaudio=audioloader.setup(audio_filename); + + 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 @@ -266,44 +273,44 @@ bool Video_output::render(const float duration, const float framerate,const stri float vf=0.0f; float af=0.0f; while (vf<duration){ //-vstep) { - while (!fless(af,vf)) { - //insert audio frames until we are ahead of the video - exporter->encodeFrame(audioloader.get_samples(exporter->get_audio_framesize())); - af+=exporter->get_audio_step(); - - } - - /* - [mp3 @ 0x7fffe40330e0] max_analyze_duration 5000000 reached at 5015510 microseconds - [mp3 @ 0x7fffe4033ec0] Insufficient thread locking around avcodec_open/close() - [mp3 @ 0x7fffe40330e0] Estimating duration from bitrate, this may be inaccurate - [libx264 @ 0x7fffe8003940] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 - [libx264 @ 0x7fffe8003940] profile High, level 3.0 - [libx264 @ 0x7fffe8003940] 264 - core 123 r2189 35cf912 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=10 keyint_min=1 scenecut=40 intra_refresh=0 rc_lookahead=10 rc=abr mbtree=1 bitrate=400 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00 - Assertion ff_avcodec_locked failed at libavcodec/utils.c:2967 - */ + if (usingaudio) { + while (!fless(af,vf)) { + //insert audio frames until we are ahead of the video + exporter.encodeFrame(audioloader.get_samples(exporter.get_audio_framesize())); + af+=exporter.get_audio_step(); + + } + } + + + //[mp3 @ 0x7fffe40330e0] max_analyze_duration 5000000 reached at 5015510 microseconds + //[mp3 @ 0x7fffe4033ec0] Insufficient thread locking around avcodec_open/close() + //[mp3 @ 0x7fffe40330e0] Estimating duration from bitrate, this may be inaccurate + //[libx264 @ 0x7fffe8003940] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 + //[libx264 @ 0x7fffe8003940] profile High, level 3.0 + //[libx264 @ 0x7fffe8003940] 264 - core 123 r2189 35cf912 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=10 keyint_min=1 scenecut=40 intra_refresh=0 rc_lookahead=10 rc=abr mbtree=1 bitrate=400 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00 + //Assertion ff_avcodec_locked failed at libavcodec/utils.c:2967 + Image* i=get_output(Frame_spec(vf,framerate,duration,outW,outH)); if (i) { - exporter->encodeFrame(i->RGBdata); + exporter.encodeFrame(i->RGBdata); } vf+=vstep; progress=vf/duration; } - exporter->finishRecord(); + exporter.finishRecord(); cerr << "Rotor: Video_output finished "<< endl; - audioloader.close(); + if (usingaudio) audioloader.close(); return true; } } - audioloader.close(); - return false; } @@ -324,6 +331,10 @@ bool Video_loader::load(const string &filename){ return true; } */ + if (isLoaded) { + player.cleanup(); ///should be in decoder class? + isLoaded=false; + } Poco::Path path; string uri="file://"+filename; isLoaded=player.open(uri); |
