From a2254447b138af7fc0719e5a107816487255736b Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Thu, 8 Aug 2013 13:32:46 +0100 Subject: basic speed control for video_loader --- rotord/src/libavwrapper.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'rotord/src/libavwrapper.cpp') 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))<streams[videoStream]->r_frame_rate.num<<"/"<streams[videoStream]->r_frame_rate.den<duration<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 } -- cgit v1.2.3