summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xrotord/libavwrapper.cpp23
-rwxr-xr-xrotord/rotor.cpp3
-rwxr-xr-xrotord/rotor.h4
3 files changed, 25 insertions, 5 deletions
diff --git a/rotord/libavwrapper.cpp b/rotord/libavwrapper.cpp
index 97315a6..08d943f 100755
--- a/rotord/libavwrapper.cpp
+++ b/rotord/libavwrapper.cpp
@@ -211,9 +211,30 @@ bool libav::decoder::openUsingInitializedContainer(enum PixelFormat formatParam)
if( pCtx->time_base.num > 1000 && pCtx->time_base.den == 1 )
pCtx->time_base.den = 1000;
+ //cerr<<"stream frame rate:"<<container->streams[videoStream]->r_frame_rate.num<<"/"<<container->streams[videoStream]->r_frame_rate.den<<endl;
+
+ //cerr<<"video duration: "<<container->duration<<endl;
+ //cerr<<"video time base: "<<pCtx->time_base.num<<"/"<<pCtx->time_base.den<<endl;
+ //cerr<<"AV time base: "<<AV_TIME_BASE<<endl;
+
/* Compute the total number of frames in the file */
/* duration is in microsecs */
- numFrames = (int)(( container->duration / (double)AV_TIME_BASE ) * pCtx->time_base.den + 0.5);
+ //numFrames = (int)(( container->duration / (double)AV_TIME_BASE ) * pCtx->time_base.den + 0.5);
+ //this approach just seems wrong!
+
+
+
+ numFrames=container->streams[videoStream]->nb_frames-1;
+
+ if (numFrames<1){
+ //some codecs don't keep this info in the header
+ float fr=((float)container->streams[videoStream]->r_frame_rate.num)/container->streams[videoStream]->r_frame_rate.den;
+ numFrames = (int)(( container->duration / (double)AV_TIME_BASE ) * fr );
+ //this approach still doesn't seem to give quite the right answer- comes out a little too big
+ //could alternatively just redefine the length if the reader fails
+ }
+
+
init_buffers_and_scaler();
diff --git a/rotord/rotor.cpp b/rotord/rotor.cpp
index 67918f5..c929fae 100755
--- a/rotord/rotor.cpp
+++ b/rotord/rotor.cpp
@@ -250,7 +250,6 @@ bool Video_output::render(const float duration, const float framerate,const stri
//
//setup defaults
int bitRate=5000000;
- int frameRate=25;
AVCodecID codecId=AV_CODEC_ID_H264; //MPEG4;
std::string container ="mp4";
@@ -260,7 +259,7 @@ bool Video_output::render(const float duration, const float framerate,const stri
float spct=100.0f/duration;
- if (exporter.setup(outW,outH,bitRate,frameRate,container)) { //codecId,
+ if (exporter.setup(outW,outH,bitRate,framerate,container)) { //codecId,
if (exporter.record(output_filename)) {
libav::audioloader audioloader;
diff --git a/rotord/rotor.h b/rotord/rotor.h
index 92d6e45..b24ae51 100755
--- a/rotord/rotor.h
+++ b/rotord/rotor.h
@@ -1178,9 +1178,9 @@ namespace Rotor {
};
class Graph{
public:
- Graph(){duration=5.0f;loaded = false;outW=640;outH=360;};
+ Graph(){duration=20.0f;loaded = false;outW=640;outH=360;};
Graph(const string& _uid,const string& _desc){init(_uid,_desc);};
- void init(const string& _uid,const string& _desc){ uid=_uid;description=_desc;duration=5.0f;};
+ void init(const string& _uid,const string& _desc){ uid=_uid;description=_desc;duration=20.0f;};
string uid; //every version of a graph has a UUID, no particular need to actually read its data(?)
//?? is it faster than using strings??
string description;