diff options
Diffstat (limited to 'rotord/src')
| -rw-r--r-- | rotord/src/graph.cpp | 29 | ||||
| -rw-r--r-- | rotord/src/graph.h | 5 | ||||
| -rw-r--r-- | rotord/src/rendercontext.cpp | 20 | ||||
| -rw-r--r-- | rotord/src/rotor.h | 4 |
4 files changed, 56 insertions, 2 deletions
diff --git a/rotord/src/graph.cpp b/rotord/src/graph.cpp index 521a18e..b1406b5 100644 --- a/rotord/src/graph.cpp +++ b/rotord/src/graph.cpp @@ -96,6 +96,9 @@ bool Graph::preview(xmlIO &XML,string &node,string &_format,int frame,int w,int } bool Graph::video_render(const string &output_filename,const double framerate,int start, int stop) { + Logger& logger = Logger::get(Log_name); + + if (output_filename.size()==0) return false; //https://www.adobe.com/devnet/video/articles/mp4_movie_atom.html //https://www.google.ie/search?q=ffmbc&aq=f&oq=ffmbc&aqs=chrome.0.57j0l2j60j0j60.4360j0&sourceid=chrome&ie=UTF-8#q=ffmbc+git @@ -122,16 +125,38 @@ bool Graph::video_render(const string &output_filename,const double framerate,in //setup defaults std::string container; + std::string filestub; Poco::StringTokenizer t(output_filename,"."); if (t.count()>1){ + filestub=t[t.count()-2]; container="."+t[t.count()-1]; } - else container=".mp4"; + else { + filestub=output_filename; + container=".mp4"; + } + + if (container==".mpd") use_dash=true; libav::exporter exporter; Image* i; + + + //dash implementation - write into a subfolder + + if (use_dash){ + struct stat st = {0}; + if (stat(filestub.c_str(), &st) == -1) { + if (mkdir(filestub.c_str(), 0700)!=0){ + logger.error("MPEG-DASH output: error creating directory "+filestub); + return false; + } + } + //directory exists + } + if (exporter.setup(outW,outH,bitRate,framerate,container,use_fragmentation)) { //codecId, if (exporter.record(output_filename)) { @@ -139,7 +164,7 @@ bool Graph::video_render(const string &output_filename,const double framerate,in bool usingaudio=audioloader.open(audio_filename); - Logger& logger = Logger::get(Log_name); + logger.information("Video_output rendering "+output_filename+": "+toString(duration)+" seconds at "+toString(framerate)+" fps, audio frame size: "+toString(exporter.get_audio_framesize())); //25fps video and 43.06640625fps audio? hmm //how to get the timecodes correct for the interleaved files diff --git a/rotord/src/graph.h b/rotord/src/graph.h index dc24c84..bb8f83f 100644 --- a/rotord/src/graph.h +++ b/rotord/src/graph.h @@ -74,6 +74,10 @@ namespace Rotor { use_fragmentation=f; return true; } + bool set_dash(bool f){ + use_dash=f; + return true; + } bool loaded; double duration; double framerate; @@ -94,6 +98,7 @@ namespace Rotor { private: int outW,outH; bool use_fragmentation; + bool use_dash; int analysis_seed; string Log_name; diff --git a/rotord/src/rendercontext.cpp b/rotord/src/rendercontext.cpp index 6d76fbc..813573b 100644 --- a/rotord/src/rendercontext.cpp +++ b/rotord/src/rendercontext.cpp @@ -152,6 +152,26 @@ void Render_context::session_command(const Session_command& command,xmlIO& XML,H XML.addValue("error","Bad request"); } } + if (command.commands[1]=="dash") { + if (command.method=="PUT") { + bool f=(toInt(command.body)!=0); + if (graph.set_dash(f)){ + string fs=f?"on":"off"; + logger.information("MPEG-DASH output "+fs); + XML.addValue("status","MPEG-DASH output "+fs); + status=HTTPResponse::HTTP_OK; + } + else { + logger.error("ERROR: Could not set MPEG-DASH output"); + XML.addValue("error","Could not set MPEG-DASH output"); + } + } + else { + status=HTTPResponse::HTTP_BAD_REQUEST; + logger.error("ERROR: Bad request"); + XML.addValue("error","Bad request"); + } + } if (command.commands[1]=="audio") { if (command.method=="PUT") { //get audio file location and initiate analysis if (command.body!="") { diff --git a/rotord/src/rotor.h b/rotord/src/rotor.h index 27d3820..65f06ac 100644 --- a/rotord/src/rotor.h +++ b/rotord/src/rotor.h @@ -128,6 +128,10 @@ inputs: [ #include <json/json.h> #include <rsvg.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> + #include "Poco/Net/HTTPResponse.h" #include "Poco/Logger.h" #include "Poco/File.h" |
