From c2b62131b0e6984f8fea7f44e364ae5c886c211a Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Thu, 30 Jan 2014 18:13:45 +0000 Subject: making fragmenting exporter --- rotord/src/graph.cpp | 169 +++++++++++++++++++++++++++++++++++-------- rotord/src/graph.h | 17 ++++- rotord/src/rendercontext.cpp | 2 +- 3 files changed, 154 insertions(+), 34 deletions(-) (limited to 'rotord') diff --git a/rotord/src/graph.cpp b/rotord/src/graph.cpp index 7c61c3e..5dd6e0b 100644 --- a/rotord/src/graph.cpp +++ b/rotord/src/graph.cpp @@ -124,52 +124,31 @@ bool Graph::video_render(const string &output_filename,const double framerate,in // //setup defaults - std::string container; - std::string filestub; + std::string suffix; + std::string namestub; Poco::StringTokenizer t(output_filename,"."); if (t.count()>1){ - filestub=t[t.count()-2]; - container="."+t[t.count()-1]; + namestub=t[t.count()-2]; + suffix="."+t[t.count()-1]; } else { - filestub=output_filename; - container=".mp4"; - } - - if (container==".mpd") { - use_dash=true; - container=".mp4"; - cerr<<"found mpd, writing "<time_taken)+" seconds"); for (auto n:nodes) { @@ -296,6 +275,132 @@ bool Graph::video_render(const string &output_filename,const double framerate,in return false; } +bool Graph::video_render2(const string &output_filename,const double framerate,int start, int stop) { + + // + //rewrite the video render process to: + //include the possibility of writing fragmented files into a subdirectory + // + + Logger& logger = Logger::get(Log_name); + + if (output_filename.size()==0) { + logger.error("ERROR: video render passed empty filename"); + return false; + } + + if (!find_node("video_output")) { + logger.error("ERROR: video output node not found"); + return false; + } + + Video_output *video_output=dynamic_cast(find_node("video_output")); + + // + //should text handling and verification happen outside of here? + // + + //first seperate path, name and suffix + std::string suffix=""; + std::string path=""; + std::string namestub=""; + + int pathsep=output_filename.find_last_of("/"); + if (pathsepcreate_envelope(audio_thumb->audiodata); + } + + //time render + struct timeval _start, _end; + gettimeofday(&_start, NULL); + uint16_t *audioframe=nullptr; + uint16_t *audio=nullptr; + int samples_in_frame; + + for (auto n:nodes) n.second->reset(); + + if (usingaudio){ + samples_in_frame=(audioloader.get_sample_rate())/framerate; + string whether=usingaudio?"Loading":"Cannot load"; + logger.information(whether+" audio file: "+audio_filename+", each frame contains "+toString(samples_in_frame)+" samples at "+toString(audioloader.get_sample_rate())+" hz"); + audioframe=new uint16_t[(samples_in_frame+exporter.get_audio_framesize())*audioloader.get_number_channels()]; + audio=new uint16_t[samples_in_frame*audioloader.get_number_channels()]; + } + + double vstep=1.0/framerate; + double vf=start*vstep; + double af=start*vstep; + int aoffs=0; + int audioend=0; + Audio_frame *a; + int64_t sample_start=(start*audioloader.get_sample_rate())/framerate; + + double end=duration; + if (use_dash) end=vf+mpd_chunk_length; + + while (vf64&&h>48){ outW=w; diff --git a/rotord/src/graph.h b/rotord/src/graph.h index bb8f83f..bfd175b 100644 --- a/rotord/src/graph.h +++ b/rotord/src/graph.h @@ -25,7 +25,19 @@ copy nodes ` namespace Rotor { class Graph{ public: - Graph(){duration=20.0;loaded = false;audio_loaded=false;bitRate=0;outW=640;outH=360;audio_thumb=new Audio_thumbnailer();use_fragmentation=false;analysis_seed=0;Log_name="";}; + Graph(){ + duration=20.0; + loaded = false; + audio_loaded=false; + bitRate=0; + outW=640; + outH=360; + audio_thumb=new Audio_thumbnailer(); + use_fragmentation=false; + analysis_seed=0; + Log_name=""; + mpd_chunk_length=2.0; + }; Graph(const string& _uid,const string& _desc){ Graph(); init(_uid,_desc); @@ -53,6 +65,7 @@ namespace Rotor { Node* find_node(const string &type); bool signal_render(xmlIO &XML,const string &node,const double framerate); bool video_render(const string &output_filename,const double framerate,int start, int end); + bool video_render2(const string &output_filename,const double framerate,int start, int end); bool load(string data,string media_path); bool loadFile(string &filename,string media_path); bool parseXml(string media_path); @@ -102,6 +115,8 @@ namespace Rotor { int analysis_seed; string Log_name; + double mpd_chunk_length; + }; class Thumbnailer{ public: diff --git a/rotord/src/rendercontext.cpp b/rotord/src/rendercontext.cpp index 813573b..39f9c9b 100644 --- a/rotord/src/rendercontext.cpp +++ b/rotord/src/rendercontext.cpp @@ -36,7 +36,7 @@ void Render_context::runTask() { if(cmd.task==RENDER) { state=RENDERING; renders[cmd.uid]=Render_status(RENDERING); - if(graph.video_render(output_filename,output_framerate,start,stop)){ + if(graph.video_render2(output_filename,output_framerate,start,stop)){ state=IDLE; if (graph.cancelled) renders[cmd.uid].status=CANCELLED; else renders[cmd.uid].status=RENDER_READY; -- cgit v1.2.3