diff options
Diffstat (limited to 'rotord/src/libavwrapper.cpp')
| -rwxr-xr-x | rotord/src/libavwrapper.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/rotord/src/libavwrapper.cpp b/rotord/src/libavwrapper.cpp index 7c00b91..c21d077 100755 --- a/rotord/src/libavwrapper.cpp +++ b/rotord/src/libavwrapper.cpp @@ -223,6 +223,10 @@ bool libav::decoder::openUsingInitializedContainer(enum PixelFormat formatParam) if( pCtx->time_base.num > 1000 && pCtx->time_base.den == 1 ) pCtx->time_base.den = 1000; + framerate=(((float)container->streams[videoStream]->r_frame_rate.num)/((float)container->streams[videoStream]->r_frame_rate.den)); + + //cerr<<"codecContext timebase: "<<(((float)pCtx->time_base.num)/((float)pCtx->time_base.den))<<" videostream framerate: "<<(((float)container->streams[videoStream]->r_frame_rate.num)/((float)container->streams[videoStream]->r_frame_rate.den))<<endl; + //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; @@ -240,8 +244,7 @@ bool libav::decoder::openUsingInitializedContainer(enum PixelFormat formatParam) 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 ); + numFrames = (int)(( container->duration / (double)AV_TIME_BASE ) * framerate ); //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 } |
