diff options
| -rw-r--r-- | rotord/src/graph.cpp | 2 | ||||
| -rw-r--r-- | rotord/src/graph.h | 7 | ||||
| -rw-r--r-- | rotord/src/libavwrapper.cpp | 8 | ||||
| -rw-r--r-- | rotord/src/libavwrapper.h | 4 | ||||
| -rw-r--r-- | rotord/src/rendercontext.cpp | 20 |
5 files changed, 36 insertions, 5 deletions
diff --git a/rotord/src/graph.cpp b/rotord/src/graph.cpp index 2930953..b94d04c 100644 --- a/rotord/src/graph.cpp +++ b/rotord/src/graph.cpp @@ -117,7 +117,7 @@ bool Graph::video_render(const string &output_filename,const float framerate) { float spct=100.0f/duration; - if (exporter.setup(outW,outH,bitRate,framerate,container)) { //codecId, + if (exporter.setup(outW,outH,bitRate,framerate,container,use_fragmentation)) { //codecId, if (exporter.record(output_filename)) { libav::audio_decoder audioloader; diff --git a/rotord/src/graph.h b/rotord/src/graph.h index 60e61db..3267bb3 100644 --- a/rotord/src/graph.h +++ b/rotord/src/graph.h @@ -16,7 +16,7 @@ Graph is an instance of a rotor renderer namespace Rotor { class Graph{ public: - Graph(){duration=20.0f;loaded = false;outW=640;outH=360;audio_thumb=new Audio_thumbnailer();}; + Graph(){duration=20.0f;loaded = false;outW=640;outH=360;audio_thumb=new Audio_thumbnailer();use_fragmentation=true;}; Graph(const string& _uid,const string& _desc){ init(_uid,_desc); audio_loaded=false; @@ -62,6 +62,10 @@ namespace Rotor { } else return false; } + bool set_fragmentation(bool f){ + use_fragmentation=f; + return true; + } bool loaded; float duration; float framerate; @@ -76,6 +80,7 @@ namespace Rotor { Audio_thumbnailer *audio_thumb; private: int outW,outH; + bool use_fragmentation; }; class Thumbnailer{ diff --git a/rotord/src/libavwrapper.cpp b/rotord/src/libavwrapper.cpp index 5525c44..e439075 100644 --- a/rotord/src/libavwrapper.cpp +++ b/rotord/src/libavwrapper.cpp @@ -110,9 +110,11 @@ bool libav::audio_decoder::open(const std::string& filename){ } } -bool libav::exporter::setup(int w,int h, int bitRate, int frameRate, std::string container){ +bool libav::exporter::setup(int w,int h, int bitRate, int frameRate, std::string container, bool _fragmentation){ maybeInitFFMpegLib(); + + fragmentation=_fragmentation; this->w=w; this->h=h; @@ -212,7 +214,9 @@ bool libav::exporter::record(std::string filename){ //THIS DOES SEEM TO SET CONTAINER OPTS= AS MOOV_SIZE MAKES THE MOVIE BANJAXED //av_dict_set(&opts, "moov_size", "20000", 0); - av_dict_set(&opts, "movflags","frag_keyframe", 0); + if (fragmentation) { + av_dict_set(&opts, "movflags","frag_keyframe", 0); + } // Write the stream header, if any. // diff --git a/rotord/src/libavwrapper.h b/rotord/src/libavwrapper.h index 77832a7..0d40503 100644 --- a/rotord/src/libavwrapper.h +++ b/rotord/src/libavwrapper.h @@ -170,7 +170,7 @@ namespace libav { sws_ctx = NULL; } }; - bool setup(int w,int h, int bitRate, int frameRate, std::string container); + bool setup(int w,int h, int bitRate, int frameRate, std::string container, bool _fragmentation); bool record(std::string filename); bool encodeFrame(unsigned char *pixels, uint16_t *samples); bool encodeFrame(unsigned char *pixels,AVPacket *audiopkt); //is possible to just copy the packets? @@ -217,6 +217,8 @@ namespace libav { int frame_count; uint8_t *outPixels; + bool fragmentation; + //************************************************************// // audio output // diff --git a/rotord/src/rendercontext.cpp b/rotord/src/rendercontext.cpp index e0a962c..53c7c64 100644 --- a/rotord/src/rendercontext.cpp +++ b/rotord/src/rendercontext.cpp @@ -134,6 +134,26 @@ void Render_context::session_command(const Session_command& command,xmlIO& XML,H XML.addValue("error","Bad request"); } } + if (command.commands[1]=="fragmentation") { + if (command.method=="PUT") { + bool f=(toInt(command.body)!=0); + if (graph.set_fragmentation(f)){ + string fs=f?"on":"off"; + logger.information("MP4 fragmentation "+fs); + XML.addValue("status","MP4 fragmentation "+fs); + status=HTTPResponse::HTTP_OK; + } + else { + logger.error("ERROR: Could not set MP4 fragmentation"); + XML.addValue("error","Could not set MP4 fragmentation"); + } + } + 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!="") { |
